[IOT-1065][IOT-1069] RC - Tizen: sample application fix
[platform/upstream/iotivity.git] / service / scene-manager / src / SceneMemberResourceRequestor.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_SCENEMEMBER_RESOURCE_REQUESTOR_H_
22 #define SM_SCENEMEMBER_RESOURCE_REQUESTOR_H_
23
24 #include "SceneCommons.h"
25 #include "RCSRemoteResourceObject.h"
26
27 namespace OIC
28 {
29     namespace Service
30     {
31
32         class SceneMemberResourceRequestor
33             : public std::enable_shared_from_this< SceneMemberResourceRequestor >
34         {
35             public:
36                 typedef std::shared_ptr< SceneMemberResourceRequestor > Ptr;
37                 typedef std::weak_ptr< SceneMemberResourceRequestor > wPtr;
38
39                 typedef std::function < void(int eCode) > InternalAddSceneActionCallback;
40
41             public:
42                 SceneMemberResourceRequestor(RCSRemoteResourceObject::Ptr memberResource,
43                                              const std::string &id);
44                 ~SceneMemberResourceRequestor() = default;
45
46                 void requestSceneActionCreation(const std::string &sceneName,
47                                                 const RCSResourceAttributes &attr,
48                                                 InternalAddSceneActionCallback);
49
50                 void requestGet(const std::string &, RCSRemoteResourceObject::GetCallback);
51
52                 void setRemoteResourceObject(RCSRemoteResourceObject::Ptr);
53
54                 RCSRemoteResourceObject::Ptr getRemoteResourceObject() const;
55
56             private:
57                 static void onSceneActionCreated(
58                     const RCSResourceAttributes &, int eCode,
59                     const std::string &sceneName, const RCSResourceAttributes &requestedAttrs,
60                     const InternalAddSceneActionCallback &, SceneMemberResourceRequestor::wPtr);
61
62                 void onSceneActionCreated_impl(
63                     const RCSResourceAttributes &, int eCode,
64                     const std::string &sceneName, const RCSResourceAttributes &requestedAttrs,
65                     const InternalAddSceneActionCallback &);
66
67             private:
68                 std::string m_id;
69                 RCSRemoteResourceObject::Ptr m_remoteResource;
70                 RCSRemoteResourceObject::Ptr m_sceneMemberResource;
71         };
72
73     }
74 }
75
76 #endif /* SM_SCENEMEMBER_RESOURCE_REQUESTOR_H_ */
77