Merge branch 'upstream' into tizen
[platform/upstream/iotivity.git] / service / scene-manager / src / SceneListResource.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 /**
22  * @file
23  *
24  * This file contains the declaration of classes and its members related to SceneListResrouceObject
25  */
26
27 #ifndef SCENE_LIST_RESOURCE_OBJECT_H
28 #define SCENE_LIST_RESOURCE_OBJECT_H
29
30 #include <string>
31
32 #include "RCSResourceObject.h"
33 #include "SceneCollectionResource.h"
34 #include "SceneCommons.h"
35
36 namespace OIC
37 {
38     namespace Service
39     {
40         class SceneListResource
41         {
42         public:
43             /**
44              * Returns Scene List Resource object as single instance.
45              */
46             static SceneListResource * getInstance();
47
48             /**
49              * Add Scene Collection resource object to Scene List Resource.
50              *
51              * @param collectionObj created Scene Collection Resource Object by constructor of SceneCollectionResourceObject class
52              */
53             void addSceneCollectionResource(SceneCollectionResource::Ptr collectionObj);
54
55             /**
56              * Returns Scene List name.
57              */
58             std::string getName() const;
59
60             /**
61              * Sets Scene List name.
62              *
63              * @param name name to set
64              */
65             void setName(std::string && name);
66
67             /**
68              * @overload
69              */
70             void setName(const std::string &);
71
72             /**
73              * Returns all of Scene Collection Resource object.
74              */
75             std::vector<SceneCollectionResource::Ptr> getSceneCollections() const;
76
77             std::vector<RCSResourceAttributes> getChildrenAttributes() const;
78
79             RCSResourceObject::Ptr getResourceObject() const;
80
81         private:
82             class SceneListRequestHandler
83             {
84             public:
85                 SceneListRequestHandler() = default;
86                 ~SceneListRequestHandler() = default;
87
88                 static RCSSetResponse onSetRequest(const RCSRequest &, RCSResourceAttributes &);
89                 static RCSGetResponse onGetRequest(const RCSRequest &, RCSResourceAttributes &);
90             };
91
92             RCSResourceObject::Ptr m_sceneListObj;
93             mutable std::mutex m_sceneCollectionLock;
94             std::vector<SceneCollectionResource::Ptr> m_sceneCollections;
95
96             SceneListResource();
97             ~SceneListResource() = default;
98
99             SceneListResource(const SceneListResource &) = delete;
100             SceneListResource & operator = (const SceneListResource &) = delete;
101
102             SceneListResource(SceneListResource &&) = delete;
103             SceneListResource & operator = (SceneListResource &&) = delete;
104
105             RCSResourceObject::Ptr createResourceObject();
106         };
107     }
108 }
109
110 #endif // SCENE_LIST_RESOURCE_OBJECT_H