1 //******************************************************************
3 // Copyright 2015 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 RH_HOSTINGOBJECT_H_
22 #define RH_HOSTINGOBJECT_H_
24 #include "ResourceClient.h"
25 #include "RCSResourceObject.h"
26 #include "RequestObject.h"
27 #include "ResourceBroker.h"
28 #include "ResourceCacheManager.h"
29 #include "PrimitiveResource.h"
36 void OIC_HOSTING_LOG(LogLevel level, const char * format, ...);
41 typedef std::shared_ptr<RCSResourceObject> ResourceObjectPtr;
42 typedef std::shared_ptr<RemoteResourceObject> RemoteObjectPtr;
43 typedef std::shared_ptr<RequestObject> RequestObjectPtr;
44 typedef std::shared_ptr<PrimitiveResource> PrimiteveResourcePtr;
46 typedef std::function<void(ResourceState)> BrokerCallback;
47 typedef std::function<void(const ResourceAttributes &)> CacheCallback;
48 typedef std::function<void()> DestroyedCallback;
50 typedef std::function<
51 RCSSetResponse(const RCSRequest&, ResourceAttributes&)> SetRequestHandler;
55 ~HostingObject() = default;
57 void initializeHostingObject(RemoteObjectPtr rResource, DestroyedCallback destroyCB);
59 RemoteObjectPtr getRemoteResource() const;
62 RemoteObjectPtr remoteObject;
63 ResourceObjectPtr mirroredServer;
65 ResourceState remoteState;
67 BrokerCallback pStateChangedCB;
68 CacheCallback pDataUpdateCB;
69 DestroyedCallback pDestroyCB;
71 SetRequestHandler pSetRequestHandler;
73 ResourceObjectPtr createMirroredServer(RemoteObjectPtr rObject);
75 void stateChangedCB(ResourceState state, RemoteObjectPtr rObject);
76 void dataChangedCB(const ResourceAttributes & attributes, RemoteObjectPtr rObject);
78 RCSSetResponse setRequestHandler(
79 const RCSRequest & request, ResourceAttributes & attributes);
81 void destroyHostingObject();
85 } /* namespace Service */
88 #endif /* RH_HOSTINGOBJECT_H_ */