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 #ifndef SM_SCENECOLLECTION_RESOURCE_REQUESTOR_H_
22 #define SM_SCENECOLLECTION_RESOURCE_REQUESTOR_H_
27 #include "SceneCommons.h"
28 #include "RCSRemoteResourceObject.h"
29 #include "RCSRepresentation.h"
30 #include "SceneMemberResourceRequestor.h"
37 class SceneCollectionResourceRequestor
38 : public std::enable_shared_from_this< SceneCollectionResourceRequestor >
41 typedef std::shared_ptr< SceneCollectionResourceRequestor > Ptr;
42 typedef std::weak_ptr< SceneCollectionResourceRequestor > wPtr;
46 ADD_SCENE, REMOVE_SCENE, EXECUTE_SCENE
49 typedef std::function<
50 void(REQUEST_TYPE, const std::string &name, int eCode) >
51 InternalSceneRequestCallback;
53 typedef std::function < void(int eCode) > InternalAddMemberCallback;
55 typedef std::function < void(int eCode) > InternalSetNameCallback;
58 SceneCollectionResourceRequestor(RCSRemoteResourceObject::Ptr collectionResource);
59 ~SceneCollectionResourceRequestor() = default;
61 void requestSceneCreation(const std::string &name, InternalSceneRequestCallback);
62 void requestSceneRemoval(const std::string &name, InternalSceneRequestCallback);
64 void requestSceneExecution(const std::string &name, InternalSceneRequestCallback);
66 void requestAddSceneMember(RCSRemoteResourceObject::Ptr targetResource,
67 const std::string &sceneName,
68 const RCSResourceAttributes &attr,
69 InternalAddMemberCallback);
71 void requestSetName(const std::string &, InternalSetNameCallback);
73 void requestGet(const std::string &, RCSRemoteResourceObject::GetCallback);
75 RCSRemoteResourceObject::Ptr getRemoteResourceObject() const;
77 SceneMemberResourceRequestor::Ptr createSceneMemberResourceRequestor(
78 const std::string &memHref, const std::string &id,
79 RCSRemoteResourceObject::Ptr target);
81 SceneMemberResourceRequestor::Ptr getSceneMemberResourceRequestor(
82 const std::string &targetHref) const;
85 static void onSetResponseForScene(
86 const RCSResourceAttributes &attrs, int eCode,
87 const std::string &name, const InternalSceneRequestCallback &,
88 REQUEST_TYPE, SceneCollectionResourceRequestor::wPtr);
90 void onSetResponseForScene_impl(
91 const RCSResourceAttributes &attrs, int eCode,
92 const std::string &name, const InternalSceneRequestCallback &,
95 static void onSceneMemberAdded(
96 const RCSRepresentation &, int eCode,
97 RCSRemoteResourceObject::Ptr, const InternalAddMemberCallback &,
98 SceneCollectionResourceRequestor::wPtr);
100 void onSceneMemberAdded_impl(
101 const RCSRepresentation &, int eCode,
102 RCSRemoteResourceObject::Ptr, const InternalAddMemberCallback &);
104 static void onNameSet(const RCSRepresentation &, int eCode, const std::string &,
105 const InternalSetNameCallback &, SceneCollectionResourceRequestor::wPtr);
107 void onNameSet_impl(const RCSRepresentation &, int eCode, const std::string &,
108 const InternalSetNameCallback &);
111 RCSRemoteResourceObject::Ptr m_sceneCollectionResource;
112 mutable std::mutex m_memberRequestorLock;
113 std::map< std::string, SceneMemberResourceRequestor::Ptr > m_memberRequestors;
119 #endif /* SM_SCENECOLLECTION_RESOURCE_REQUESTOR_H_ */