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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 #include "SceneAction.h"
33 class SceneCollectionResource;
38 * @brief Scene class is an interface class to manage scenes provided by SceneCollection
39 * resource. This class provide APIs for creating a new SceneAction instance, retrieving all
40 * SceneAction instances created before. And it provides an API to execute a scene.
46 typedef std::shared_ptr< Scene > Ptr;
49 * Typedef for callback of execute APIs
53 typedef std::function< void(int) > ExecuteCallback;
56 Scene(const Scene&) = default;
57 Scene(const std::string&, std::shared_ptr<SceneCollectionResource>);
58 friend class SceneCollection;
63 * Adds new SceneAction instance to the Scene instance
65 * @param pRCSRemoteResourceObject A pointer of discovered resource
66 * @param key A key of attributes
67 * @param value A value to be mapped against the key
69 * @return A shared pointer of SceneAction instance
71 * @throws RCSInvalidParameterException if pRCSRemoteResourceObject is nullptr
72 * @throws RCSBadRequestException if scene member resource is already registered
74 * @note SceneAction instance is only produced by Scene class
76 * @see RCSResourceAttributes
78 SceneAction::Ptr addNewSceneAction(
79 const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject,
80 std::string key, RCSResourceAttributes::Value value);
83 * Adds new SceneAction instance to the Scene instance
85 * @param pRCSRemoteResourceObject A pointer of discovered resource
86 * @param attr A attribute set of key and value
88 * @return A shared pointer of SceneAction instance
90 * @throws RCSInvalidParameterException if pRCSRemoteResourceObject is nullptr
91 * @throws RCSBadRequestException if SceneMember is already registered
93 * @note SceneAction instance is only produced by Scene class
95 * @see RCSResourceAttributes
97 SceneAction::Ptr addNewSceneAction(
98 const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject,
99 RCSResourceAttributes attr);
102 * Gets SceneAction using discovered resource
104 * @param pRCSRemoteResourceObject A pointer of discovered resource
106 * @return A shared pointer of SceneAction
108 * @throws RCSInvalidParameterException
109 * if pRCSRemoteResourceObject is unknown resource
111 SceneAction::Ptr getSceneAction(
112 const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject) const;
115 * Gets all SceneActions include current Scene
117 * @return A vector of shared pointer of SceneAction instance
120 std::vector<SceneAction::Ptr> getSceneActions() const ;
123 * Gets Scene's name provided SceneCollection resource
125 * @return Scene's name
127 std::string getName() const;
130 * Requests executing Scene to SceneCollection resource
132 * @param cb A callback to execute Scene
134 void execute(ExecuteCallback cb);
138 std::shared_ptr< SceneCollectionResource > m_sceneCollectionResource;
141 } /* namespace Service */
142 } /* namespace OIC */
144 #endif /* SM_SCENE_H_ */