IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RemoteSceneList.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_SCENELIST_H_
22 #define SM_REMOTE_SCENELIST_H_
23 
24 #include <memory>
25 #include <vector>
26 #include <functional>
27 #include <mutex>
28 
29 #include "RemoteSceneCollection.h"
31 
32 namespace OIC
33 {
34  namespace Service
35  {
36  class SceneListResourceRequestor;
37 
49  {
50  public:
51  typedef std::unique_ptr< RemoteSceneList > Ptr;
52 
65  typedef std::function< void(RemoteSceneList::Ptr list, int eCode) >
67 
80  typedef std::function< void(RemoteSceneCollection::Ptr collection, int eCode) >
82 
94  typedef std::function< void(int eCode) > SetNameCallback;
95 
96  public:
97  ~RemoteSceneList() = default;
98 
118  static void createInstance(
120 
134 
140  std::vector< RemoteSceneCollection::Ptr > getRemoteSceneCollections() const;
141 
151  void setName(const std::string &name, SetNameCallback cb);
152 
158  std::string getName() const;
159 
160  private:
161  RemoteSceneList(std::shared_ptr< SceneListResourceRequestor >);
162 
163  static void onInstanceCreated(const RCSRepresentation &, int, const std::string &,
164  std::shared_ptr< SceneListResourceRequestor >, const CreateInstanceCallback &);
165 
166  static RemoteSceneList::Ptr buildSceneList(
167  std::shared_ptr< SceneListResourceRequestor >, const RCSResourceAttributes &);
168 
169  RemoteSceneCollection::Ptr createRemoteSceneCollection(
170  const std::string &link, const std::string &id, const std::string &name);
171 
172  std::shared_ptr< SceneListResourceRequestor > getListResourceRequestor() const;
173 
174  std::vector<std::pair<RCSResourceAttributes, std::vector<RCSResourceAttributes>>>
175  parseSceneListFromAttributes(const RCSResourceAttributes &);
176 
177  std::vector<RCSResourceAttributes> getChildrenAttributes(
178  const RCSResourceAttributes &) const;
179 
180  void onSceneCollectionCreated(
181  const std::string &link, const std::string &id, const std::string &name,
182  int, const AddNewSceneCollectionCallback &);
183 
184  void onNameSet(int, const std::string &, const SetNameCallback &);
185 
186  private:
187  std::string m_name;
188  std::vector< RemoteSceneCollection::Ptr > m_remoteSceneCollections;
189  mutable std::mutex m_nameLock;
190  mutable std::mutex m_collectionLock;
191  std::shared_ptr< SceneListResourceRequestor > m_requestor;
192  };
193 
194  }
195 }
196 
197 #endif /* SM_REMOTE_SCENELIST_H_ */
void addNewSceneCollection(AddNewSceneCollectionCallback cb)
Requests to add new SceneCollection resource to the SceneList resource on remote side and creates Rem...
std::function< void(RemoteSceneCollection::Ptr collection, int eCode) > AddNewSceneCollectionCallback
Callback definition to be invoked when a response of addNewSceneCollection is received.
Definition: RemoteSceneList.h:81
This class describes a resource representation.
Definition: RCSRepresentation.h:42
std::function< void(int eCode) > SetNameCallback
Callback definition to be invoked when a response of setName is received.
Definition: RemoteSceneList.h:94
void setName(const std::string &name, SetNameCallback cb)
Request to set a name attribute of the SceneList resource on remote side.
std::string getName() const
Gets a name attribute of the SceneList resource.
std::shared_ptr< RCSRemoteResourceObject > Ptr
Definition: RCSRemoteResourceObject.h:175
This represents the attributes for a resource.
Definition: RCSResourceAttributes.h:195
static void createInstance(RCSRemoteResourceObject::Ptr sceneListResource, CreateInstanceCallback cb)
Creates RemoteSceneList instance with provided RCSRemoteResourceObject of discovered SceneList resour...
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::function< void(RemoteSceneList::Ptr list, int eCode) > CreateInstanceCallback
Callback definition to be invoked when a response of createInstance is received.
Definition: RemoteSceneList.h:66
std::unique_ptr< RemoteSceneList > Ptr
Definition: RemoteSceneList.h:51
std::vector< RemoteSceneCollection::Ptr > getRemoteSceneCollections() const
Gets all RemoteSceneCollection instances stored in the RemoteSceneList instance.
This file contains the declaration of classes and its members related to RCSRemoteResourceObject.