Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / scene-manager / src / SceneListResourceRequestor.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_SCENELIST_RESOURCE_REQUESTOR_H_
22 #define SM_SCENELIST_RESOURCE_REQUESTOR_H_
23
24 #include "SceneCommons.h"
25 #include "RCSRemoteResourceObject.h"
26 #include "RCSRepresentation.h"
27 #include "RemoteSceneUtils.h"
28
29 namespace OIC
30 {
31     namespace Service
32     {
33
34         class SceneListResourceRequestor
35             : public std::enable_shared_from_this< SceneListResourceRequestor >
36         {
37             public:
38                 typedef std::shared_ptr< SceneListResourceRequestor > Ptr;
39                 typedef std::weak_ptr< SceneListResourceRequestor > wPtr;
40
41                 typedef std::function<
42                     void(const std::string &link, const std::string &id,
43                             const std::string &name, int eCode) >
44                     InternalCreateSceneCollectionCallback;
45
46                 typedef std::function < void(int eCode) > InternalSetNameCallback;
47
48             public:
49                 SceneListResourceRequestor(RCSRemoteResourceObject::Ptr listResource);
50                 ~SceneListResourceRequestor() = default;
51
52                 void requestSceneCollectionCreation(
53                     const std::string &name, InternalCreateSceneCollectionCallback);
54
55                 void requestSetName(const std::string &, InternalSetNameCallback);
56
57                 void requestGet(const std::string &, RCSRemoteResourceObject::GetCallback);
58
59                 RCSRemoteResourceObject::Ptr getRemoteResourceObject() const;
60
61             private:
62                 static void onSceneCollectionCreated(
63                     const RCSRepresentation &, int eCode,
64                     const std::string &name, const InternalCreateSceneCollectionCallback &,
65                     SceneListResourceRequestor::wPtr);
66
67                 void onSceneCollectionCreated_impl(
68                     const RCSRepresentation &, int eCode,
69                     const std::string &name, const InternalCreateSceneCollectionCallback &);
70
71                 static void onNameSet(const RCSRepresentation &, int eCode, const std::string &,
72                     const InternalSetNameCallback &, SceneListResourceRequestor::wPtr);
73
74                 void onNameSet_impl(const RCSRepresentation &, int eCode, const std::string &,
75                     const InternalSetNameCallback &);
76
77             private:
78                 RCSRemoteResourceObject::Ptr m_sceneListResource;
79         };
80
81     }
82 }
83
84 #endif /* SM_SCENELIST_RESOURCE_REQUESTOR_H_ */
85