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 #include "RemoteSceneAction.h"
25 #include "SceneCommons.h"
26 #include "SceneMemberResourceRequestor.h"
33 RemoteSceneAction::RemoteSceneAction(
34 SceneMemberResourceRequestor::Ptr requestor,
35 const std::string &sceneName, const RCSResourceAttributes &attrs)
36 : m_sceneName{ sceneName }, m_attributes{ attrs }, m_requestor{ requestor }
41 RemoteSceneAction::RemoteSceneAction(
42 SceneMemberResourceRequestor::Ptr requestor, const std::string &sceneName,
43 const std::string &key, const RCSResourceAttributes::Value &value)
44 : m_sceneName{ sceneName }, m_requestor{ requestor }
47 m_attributes[key] = value;
50 void RemoteSceneAction::resetExecutionParameter(const std::string &key,
51 const RCSResourceAttributes::Value &value,
52 ResetExecutionParameterCallback clientCB)
54 RCSResourceAttributes attr;
55 attr[key] = RCSResourceAttributes::Value(value);
57 resetExecutionParameter(attr, std::move(clientCB));
60 void RemoteSceneAction::resetExecutionParameter(const RCSResourceAttributes &attr,
61 ResetExecutionParameterCallback clientCB)
65 throw RCSInvalidParameterException{ "resetExecutionParameter : Callback is NULL" };
68 SceneMemberResourceRequestor::InternalAddSceneActionCallback internalCB
69 = std::bind(&RemoteSceneAction::onExecutionParameterSet, this,
70 std::placeholders::_1, attr, std::move(clientCB));
72 m_requestor->requestSceneActionCreation(
73 m_sceneName, attr, internalCB);
76 RCSResourceAttributes RemoteSceneAction::getExecutionParameter() const
78 std::lock_guard< std::mutex > lock(m_attributeLock);
82 RCSRemoteResourceObject::Ptr RemoteSceneAction::getRemoteResourceObject() const
84 return m_requestor->getRemoteResourceObject();
87 void RemoteSceneAction::onExecutionParameterSet(int eCode, const RCSResourceAttributes &attr,
88 const ResetExecutionParameterCallback &clientCB)
90 int result = SCENE_CLIENT_BADREQUEST;
91 if (eCode == SCENE_RESPONSE_SUCCESS)
93 std::lock_guard< std::mutex > lock(m_attributeLock);
95 result = SCENE_RESPONSE_SUCCESS;