9f1dde2aefee2d9f972faa9e3bd04b8103261e4d
[platform/upstream/iotivity.git] / service / scene-manager / include / RemoteSceneAction.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_SCENEACTION_H_
22 #define SM_REMOTE_SCENEACTION_H_
23
24 #include <memory>
25 #include <string>
26 #include <mutex>
27
28 #include "RCSRemoteResourceObject.h"
29
30 namespace OIC
31 {
32     namespace Service
33     {
34
35         class SceneMemberResourceRequestor;
36
37         class RemoteSceneAction
38         {
39             public:
40                 typedef std::shared_ptr< RemoteSceneAction > Ptr;
41
42                 typedef std::function< void(int eCode) > UpdateCallback;
43
44             public:
45                 ~RemoteSceneAction() = default;
46
47                 void setExecutionParameter(const std::string &key,
48                     const RCSResourceAttributes::Value &value, UpdateCallback);
49                 void setExecutionParameter(const RCSResourceAttributes &attr, UpdateCallback);
50
51                 RCSResourceAttributes getExecutionParameter() const;
52
53                 RCSRemoteResourceObject::Ptr getRemoteResourceObject() const;
54
55             private:
56                 RemoteSceneAction(std::shared_ptr< SceneMemberResourceRequestor >,
57                                   const std::string &sceneName, const RCSResourceAttributes &);
58                 RemoteSceneAction(std::shared_ptr< SceneMemberResourceRequestor >,
59                                   const std::string &sceneName,
60                                   const std::string &key, const RCSResourceAttributes::Value &);
61
62                 void onUpdated(int, const RCSResourceAttributes &, const UpdateCallback &);
63
64             private:
65                 std::string m_sceneName;
66                 std::mutex m_attributeLock;
67                 RCSResourceAttributes m_attributes;
68                 std::shared_ptr< SceneMemberResourceRequestor > m_requestor;
69
70                 friend class RemoteScene;
71         };
72
73     }
74 }
75
76 #endif /* SM_REMOTE_SCENEACTION_H_ */