1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef SM_REMOTE_SCENELIST_H_
22 #define SM_REMOTE_SCENELIST_H_
28 #include "RemoteSceneCollection.h"
29 #include "RCSRemoteResourceObject.h"
36 class SceneListResourceRequestor;
39 : public std::enable_shared_from_this< RemoteSceneList >
42 typedef std::unique_ptr< RemoteSceneList > Ptr;
44 typedef std::function< void(RemoteSceneList::Ptr, int) >
45 CreateInstanceCallback;
47 typedef std::function< void(RemoteSceneCollection::Ptr, int) >
48 AddNewSceneCollectionCallback;
50 typedef std::function< void(int eCode) >
55 ~RemoteSceneList() = default;
57 static void createInstance
58 (RCSRemoteResourceObject::Ptr pSceneListResource, CreateInstanceCallback);
60 void addNewSceneCollection(AddNewSceneCollectionCallback);
61 void removeSceneCollection(RemoteSceneCollection::Ptr);
63 std::vector< RemoteSceneCollection::Ptr > getRemoteSceneCollections() const;
65 void setName(const std::string &name, SetNameCallback);
66 std::string getName() const;
70 class GetResponseHandler
73 typedef std::shared_ptr< GetResponseHandler > Ptr;
75 typedef std::function< void(int eCode) >
78 GetResponseHandler(std::shared_ptr< RemoteSceneList > ptr);
79 ~GetResponseHandler() = default;
81 int m_numOfCollections;
82 int m_respondedCollections;
84 std::weak_ptr< RemoteSceneList > m_owner;
87 void startGetResponseHandler(const std::string &host, GetCallback cb);
89 void onGetCollectionAttrs(const HeaderOpts &, const RCSRepresentation &,
90 int eCode, RemoteSceneCollection::Ptr,
93 void onGetListAttrs(const HeaderOpts &, const RCSRepresentation &, int,
99 RemoteSceneList(std::shared_ptr< SceneListResourceRequestor > pRequestor);
101 static void onInstanceCreated(int, std::shared_ptr< RemoteSceneList >,
102 CreateInstanceCallback);
104 RemoteSceneCollection::Ptr createRemoteSceneCollectionInstance
105 (const std::string &link, const std::string &id, const std::string &name);
107 void setGetResponseHandler(const std::string &, GetResponseHandler::GetCallback);
109 void onSceneCollectionCreated
110 (const std::string &link, const std::string &id, const std::string &name,
111 int eCode, AddNewSceneCollectionCallback);
113 void onNameSet(int, const std::string &, const SetNameCallback &);
118 std::vector< RemoteSceneCollection::Ptr > m_remoteSceneCollections;
119 std::shared_ptr< SceneListResourceRequestor > m_requestorPtr;
121 GetResponseHandler::Ptr m_getResponseHandler;
123 friend class GetResponseHandler;
129 #endif /* SM_REMOTE_SCENELIST_H_ */