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_SCENEACTION_H_
22 #define SM_REMOTE_SCENEACTION_H_
28 #include "RCSRemoteResourceObject.h"
35 class SceneMemberResourceRequestor;
38 * @class RemoteSceneAction
40 * @brief RemoteSceneAction class indicates a unit of actions when a scene is executed.
41 * RemoteSceneAction instance is initialized with 3 essential parameters:
42 * a target resource, target attribute key, and its target value.
43 * And this class also provides APIs to update a target attribute information if one wants.
44 * Note that, adding a new RemoteSceneAction is done by sending a CoAP request to update a
45 * SceneMember resource's attribute.
47 class RemoteSceneAction
50 typedef std::shared_ptr< RemoteSceneAction > Ptr;
53 * Callback definition to be invoked when a response of resetExecutionParameter is
56 * @param eCode the error code received on a remote-side scene resource server
58 * @note Error code '200' stands for success, '400' for bad request,
59 * and '500' for internal error.
61 * @see resetExecutionParameter
63 typedef std::function< void(int eCode) > ResetExecutionParameterCallback;
66 ~RemoteSceneAction() = default;
69 * Requests to reset the RemoteSceneAction parameters like
70 * a target attribute key and its value.
72 * @param key key of attribute
73 * @param value value to be mapped against the key
74 * @param cb A callback to receive the response
76 * @throws RCSInvalidParameterException If parameter is invalid.
77 * @throws PlatformException If the platform operation failed
79 * @see RCSResourceAttributes::Value
81 void resetExecutionParameter(const std::string &key,
82 const RCSResourceAttributes::Value &value, ResetExecutionParameterCallback cb);
85 * Requests to reset the RemoteSceneAction parameters like
86 * a target attribute key and its value.
88 * @param attr Attributes to set
89 * @param cb A callback to receive the response
91 * @throws RCSInvalidParameterException If parameter is invalid.
92 * @throws PlatformException If the platform operation failed
94 * @see RCSResourceAttributes
96 void resetExecutionParameter(
97 const RCSResourceAttributes &attr, ResetExecutionParameterCallback cb);
100 * Returns an execution parameter of the SceneAction.
102 * @return RCSResourceAttributes
104 RCSResourceAttributes getExecutionParameter() const;
107 * Returns a target remote resource object of the RemoteSceneAction instance
109 * @return pointer of RCSRemoteResourceObject
111 RCSRemoteResourceObject::Ptr getRemoteResourceObject() const;
114 RemoteSceneAction(std::shared_ptr< SceneMemberResourceRequestor >,
115 const std::string &sceneName, const RCSResourceAttributes &);
116 RemoteSceneAction(std::shared_ptr< SceneMemberResourceRequestor >,
117 const std::string &sceneName,
118 const std::string &key, const RCSResourceAttributes::Value &);
120 void onExecutionParameterSet(int, const RCSResourceAttributes &,
121 const ResetExecutionParameterCallback &);
124 std::string m_sceneName;
125 mutable std::mutex m_attributeLock;
126 RCSResourceAttributes m_attributes;
127 std::shared_ptr< SceneMemberResourceRequestor > m_requestor;
129 friend class RemoteScene;
135 #endif /* SM_REMOTE_SCENEACTION_H_ */