IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemoteSceneCollection.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_SCENECOLLECTION_H_
22 #define SM_REMOTE_SCENECOLLECTION_H_
23 
24 #include <memory>
25 #include <functional>
26 #include <string>
27 #include <unordered_map>
28 #include <mutex>
29 
30 #include "RemoteScene.h"
32 
33 namespace OIC
34 {
35  namespace Service
36  {
37 
38  class SceneCollectionResourceRequestor;
39 
51  {
52  public:
53  typedef std::shared_ptr< RemoteSceneCollection > Ptr;
54 
67  typedef std::function< void(RemoteScene::Ptr scene, int eCode) >
69 
81  typedef std::function< void(int eCode) > SetNameCallback;
82 
83  public:
84  ~RemoteSceneCollection() = default;
85 
99  void addNewScene(const std::string &name, AddNewSceneCallback cb);
100 
106  std::unordered_map< std::string, RemoteScene::Ptr > getRemoteScenes() const;
107 
117  RemoteScene::Ptr getRemoteScene(const std::string &sceneName) const;
118 
128  void setName(const std::string &name, SetNameCallback cb);
129 
135  std::string getName() const;
136 
142  std::string getId() const;
143 
144  private:
146  std::shared_ptr< SceneCollectionResourceRequestor >,
147  const std::string &id, const std::string &name);
148 
149  void addExistingRemoteScenes(const std::vector< std::string > &);
150 
151  void initializeRemoteScenes(const std::vector< RCSResourceAttributes > &,
152  const std::string &);
153 
154  RemoteScene::Ptr createRemoteScene(const std::string &);
155 
156  void onSceneAddedRemoved(int, const std::string &name, int,
157  const AddNewSceneCallback &);
158 
159  void onNameSet(int, const std::string &, const SetNameCallback &);
160 
161  private:
162  std::string m_id;
163  std::string m_name;
164  mutable std::mutex m_nameLock;
165  mutable std::mutex m_sceneLock;
166  std::unordered_map< std::string, RemoteScene::Ptr > m_remoteScenes;
167  std::shared_ptr< SceneCollectionResourceRequestor > m_requestor;
168 
169  friend class RemoteSceneList;
170  };
171 
172  }
173 }
174 
175 #endif /* SM_REMOTE_SCENECOLLECTION_H_ */
void addNewScene(const std::string &name, AddNewSceneCallback cb)
Requests to add new Scene to the SceneCollection resource on remote side and creates RemoteScene inst...
void setName(const std::string &name, SetNameCallback cb)
Request to set a name attribute of the SceneCollection resource on remote side.
RemoteScene::Ptr getRemoteScene(const std::string &sceneName) const
Gets RemoteScene instance with a specific Scene name.
std::shared_ptr< RemoteScene > Ptr
Definition: RemoteScene.h:51
std::function< void(int eCode) > SetNameCallback
Callback definition to be invoked when a response of setName is received.
Definition: RemoteSceneCollection.h:81
RemoteSceneList class is an interface class to send a request to SceneList resource on remote side...
Definition: RemoteSceneList.h:48
std::shared_ptr< RemoteSceneCollection > Ptr
Definition: RemoteSceneCollection.h:53
std::unordered_map< std::string, RemoteScene::Ptr > getRemoteScenes() const
Gets all RemoteScene instances from RemoteSceneCollection instance.
std::function< void(RemoteScene::Ptr scene, int eCode) > AddNewSceneCallback
Callback definition to be invoked when a response of addNewScene is received.
Definition: RemoteSceneCollection.h:68
RemoteSceneCollection class is an interface class to send a request to SceneCollection resource on re...
Definition: RemoteSceneCollection.h:50
std::string getId() const
Gets an id attribute of the SceneCollection resource.
std::string getName() const
Gets a name attribute of the SceneCollection resource.
This file contains the declaration of classes and its members related to RCSRemoteResourceObject.