[CONPRO-1430] BlockWiseTransfer Error
[platform/upstream/iotivity.git] / service / scene-manager / include / Scene.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_SCENE_H_
22 #define SM_SCENE_H_
23
24 #include "SceneAction.h"
25
26 #include <vector>
27
28 namespace OIC
29 {
30     namespace Service
31     {
32
33         class SceneCollectionResource;
34
35         /**
36          * @class Scene
37          *
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.
41          *
42          */
43         class Scene
44         {
45         public:
46             typedef std::shared_ptr< Scene > Ptr;
47
48             /**
49              * Typedef for callback of execute APIs
50              *
51              * @see execute
52              */
53             typedef std::function< void(int) >  ExecuteCallback;
54
55         private:
56             Scene(const Scene&) = default;
57             Scene(const std::string&, std::shared_ptr<SceneCollectionResource>);
58             friend class SceneCollection;
59
60         public:
61
62             /**
63              * Adds new SceneAction instance to the Scene instance
64              *
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
68              *
69              * @return A shared pointer of SceneAction instance
70              *
71              * @throws RCSInvalidParameterException if pRCSRemoteResourceObject is nullptr
72              * @throws RCSBadRequestException if scene member resource is already registered
73              *
74              * @note SceneAction instance is only produced by Scene class
75              *
76              * @see RCSResourceAttributes
77              */
78             SceneAction::Ptr addNewSceneAction(
79                     const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject,
80                     std::string key, RCSResourceAttributes::Value value);
81
82             /**
83              * Adds new SceneAction instance to the Scene instance
84              *
85              * @param pRCSRemoteResourceObject        A pointer of discovered resource
86              * @param attr                              A attribute set of key and value
87              *
88              * @return A shared pointer of SceneAction instance
89              *
90              * @throws RCSInvalidParameterException if pRCSRemoteResourceObject is nullptr
91              * @throws RCSBadRequestException if SceneMember is already registered
92              *
93              * @note SceneAction instance is only produced by Scene class
94              *
95              * @see RCSResourceAttributes
96              */
97             SceneAction::Ptr addNewSceneAction(
98                     const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject,
99                     RCSResourceAttributes attr);
100
101             /**
102              * Gets SceneAction using discovered resource
103              *
104              * @param pRCSRemoteResourceObject        A pointer of discovered resource
105              *
106              * @return A shared pointer of SceneAction
107              *
108              * @throws RCSInvalidParameterException
109              * if pRCSRemoteResourceObject is unknown resource
110              */
111             SceneAction::Ptr getSceneAction(
112                     const RCSRemoteResourceObject::Ptr& pRCSRemoteResourceObject) const;
113
114             /**
115              * Gets all SceneActions include current Scene
116              *
117              * @return A vector of shared pointer of SceneAction instance
118              *
119              */
120             std::vector<SceneAction::Ptr> getSceneActions() const ;
121
122             /**
123              * Gets Scene's name provided SceneCollection resource
124              *
125              * @return Scene's name
126              */
127             std::string getName() const;
128
129             /**
130              * Requests executing Scene to SceneCollection resource
131              *
132              * @param cb                        A callback to execute Scene
133              */
134             void execute(ExecuteCallback cb);
135
136         private:
137             std::string m_name;
138             std::shared_ptr< SceneCollectionResource > m_sceneCollectionResource;
139
140         };
141     } /* namespace Service */
142 } /* namespace OIC */
143
144 #endif /* SM_SCENE_H_ */
145