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"
23 #include "SceneCommons.h"
24 #include "RemoteSceneUtils.h"
25 #include "SceneMemberResourceRequestor.h"
32 RemoteSceneAction::RemoteSceneAction
33 (std::shared_ptr< SceneMemberResourceRequestor > pRequestor,
34 const std::string &sceneName, const RCSResourceAttributes &attrs)
35 : m_sceneName{ sceneName }, m_attributes{ attrs }, m_requestorPtr{ pRequestor }
37 // TODO: check pRequestor not null
40 RemoteSceneAction::RemoteSceneAction
41 (std::shared_ptr< SceneMemberResourceRequestor > pRequestor,
42 const std::string &sceneName,
43 const std::string &key, const RCSResourceAttributes::Value &value)
44 : m_sceneName{ sceneName }, m_requestorPtr{ pRequestor }
46 // TODO: check pRequestor not null
47 m_attributes[key] = value;
50 void RemoteSceneAction::update(const RCSResourceAttributes &attr,
51 UpdateCallback clientCB)
53 SceneMemberResourceRequestor::InternalAddSceneActionCallback internalCB
54 = std::bind(&RemoteSceneAction::onUpdated, this,
55 std::placeholders::_1, attr, std::move(clientCB));
57 m_requestorPtr->requestSceneActionCreation(m_sceneName,
61 void RemoteSceneAction::update(const std::string &key,
62 const RCSResourceAttributes::Value &value,
63 UpdateCallback clientCB)
65 RCSResourceAttributes attr;
66 attr[key] = RCSResourceAttributes::Value(value);
68 update(attr, std::move(clientCB));
71 RCSResourceAttributes RemoteSceneAction::getAction() const
76 RCSRemoteResourceObject::Ptr RemoteSceneAction::getRemoteResourceObject() const
78 return m_requestorPtr->getRemoteResourceObject();
81 void RemoteSceneAction::onUpdated(int eCode, const RCSResourceAttributes &attr,
82 const UpdateCallback &clientCB)
84 if (eCode == SCENE_RESPONSE_SUCCESS)