IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemoteScene.h
Go to the documentation of this file.
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 
21 #ifndef SM_REMOTE_SCENE_H_
22 #define SM_REMOTE_SCENE_H_
23 
24 #include <memory>
25 #include <string>
26 #include <unordered_map>
27 #include <mutex>
28 
29 #include "RemoteSceneAction.h"
31 
32 namespace OIC
33 {
34  namespace Service
35  {
36  class SceneCollectionResourceRequestor;
37  class SceneMemberResourceRequestor;
38 
39  /*
40  * @class RemoteScene
41  *
42  * @brief RemoteScene class is an interface class to send a request to a Scene provided by
43  * SceneCollection resource on remote side. This class provides APIs for adding new
44  * SceneAction to the Scene and creating a new SceneAction instance, retrieving all
45  * SceneAction instances created before. And it also provides an API to execute a Scene
46  * on remote side.
47  */
49  {
50  public:
51  typedef std::shared_ptr< RemoteScene > Ptr;
52 
65  typedef std::function< void(RemoteSceneAction::Ptr action, int eCode) >
67 
80  typedef std::function< void(const std::string &sceneName, int eCode) >
82 
83  public:
84  ~RemoteScene() = default;
85 
103 
121  const std::string &key,
122  const RCSResourceAttributes::Value &value,
124 
130  std::vector< RemoteSceneAction::Ptr > getRemoteSceneActions() const;
131 
142  const RCSRemoteResourceObject::Ptr targetResource) const;
143 
149  std::string getName() const;
150 
160 
161  private:
162  RemoteScene(
163  const std::string &name, std::shared_ptr< SceneCollectionResourceRequestor >);
164 
165  RemoteSceneAction::Ptr createRemoteSceneAction(
166  const std::string &, const RCSResourceAttributes &);
167 
168  void addExistingRemoteSceneAction(const std::string &, const std::string &,
169  RCSRemoteResourceObject::Ptr, const std::string &key,
171 
172  void onSceneActionAdded(
175 
176  void onSceneExecuted(const std::string &name, int,
178 
179  private:
180  std::string m_name;
181  mutable std::mutex m_sceneActionLock;
182  std::unordered_map < std::string, RemoteSceneAction::Ptr >
183  m_remoteSceneActions;
184 
185  std::shared_ptr< SceneCollectionResourceRequestor > m_requestor;
186 
187  friend class RemoteSceneCollection;
188  };
189 
190  }
191 }
192 
193 #endif /* SM_REMOTE_SCENE_H_ */
void addNewSceneAction(RCSRemoteResourceObject::Ptr targetResource, const RCSResourceAttributes &attrs, AddNewSceneActionCallback cb)
Requests to add new SceneAction to the Scene on remote side and creates RemoteSceneAction instance co...
std::vector< RemoteSceneAction::Ptr > getRemoteSceneActions() const
Gets all RemoteSceneAction instances included in the Scene.
std::function< void(RemoteSceneAction::Ptr action, int eCode) > AddNewSceneActionCallback
Callback definition to be invoked a the response of addNewSceneAction is received.
Definition: RemoteScene.h:66
Definition: RemoteScene.h:48
RemoteSceneAction::Ptr getRemoteSceneAction(const RCSRemoteResourceObject::Ptr targetResource) const
Gets RemoteSceneAction instance by using a certain discovered resource.
Value holds a value among various types at a time.
Definition: RCSResourceAttributes.h:432
std::shared_ptr< RemoteScene > Ptr
Definition: RemoteScene.h:51
std::shared_ptr< RCSRemoteResourceObject > Ptr
Definition: RCSRemoteResourceObject.h:175
std::shared_ptr< RemoteSceneAction > Ptr
Definition: RemoteSceneAction.h:50
std::function< void(const std::string &sceneName, int eCode) > RemoteSceneExecuteCallback
Callback definition to be invoked when a response of execute is received.
Definition: RemoteScene.h:81
This represents the attributes for a resource.
Definition: RCSResourceAttributes.h:195
RemoteSceneCollection class is an interface class to send a request to SceneCollection resource on re...
Definition: RemoteSceneCollection.h:50
void execute(RemoteSceneExecuteCallback cb)
Requests to execute the Scene on remote side.
std::string getName() const
Gets a name attribute of the Scene.
This file contains the declaration of classes and its members related to RCSRemoteResourceObject.