add scene manager remote interface class implementation
[platform/upstream/iotivity.git] / service / scene-manager / include / RemoteSceneCollection.h
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 <map>
28
29 #include "RemoteScene.h"
30 #include "RCSRemoteResourceObject.h"
31
32 namespace OIC
33 {
34     namespace Service
35     {
36
37         class SceneCollectionResourceRequestor;
38
39         class RemoteSceneCollection
40         {
41             public:
42                 typedef std::shared_ptr< RemoteSceneCollection > Ptr;
43
44                 typedef std::function< void(RemoteScene::Ptr, int) >
45                 AddNewSceneCallback;
46
47                 typedef std::function< void(int eCode) >
48                 RemoveSceneCallback;
49
50                 typedef std::function< void(int eCode) >
51                 SetNameCallback;
52
53
54             public:
55                 ~RemoteSceneCollection() = default;
56
57                 void addNewScene(const std::string &name, AddNewSceneCallback);
58                 void removeScene(const std::string &name, RemoveSceneCallback);
59
60                 std::map< const std::string, RemoteScene::Ptr > getRemoteScenes() const;
61                 RemoteScene::Ptr getRemoteScene(const std::string &sceneName) const;
62
63                 void setName(const std::string &name, SetNameCallback);
64                 std::string getName() const;
65
66                 std::string getId() const;
67
68
69             private:
70                 RemoteSceneCollection
71                 (std::shared_ptr< SceneCollectionResourceRequestor > pRequestor,
72                  const std::string &id, const std::string &name);
73
74                 void initializeRemoteSceneCollection(const std::vector< RCSRepresentation > &,
75                                                      const std::string &);
76
77                 RemoteScene::Ptr createRemoteSceneInstance(const std::string &);
78
79                 void onSceneAddedRemoved(const int &reqType, const std::string &name, int eCode,
80                                          const AddNewSceneCallback &, const RemoveSceneCallback &);
81
82                 void onNameSet(int, const std::string &, const SetNameCallback &);
83
84
85             private:
86                 std::string m_id;
87                 std::string m_name;
88                 std::map< const std::string, RemoteScene::Ptr > m_remoteScenes;
89
90                 std::shared_ptr< SceneCollectionResourceRequestor > m_requestorPtr;
91
92                 friend class RemoteSceneList;
93         };
94
95     }
96 }
97
98 #endif /* SM_REMOTE_SCENECOLLECTION_H_ */
99