#include "RCSRemoteResourceObject.h"
#include "RCSResourceObject.h"
-#include "RequestObject.h"
+
+#define OIC_HOSTING_LOG(level, fmt, args...) OIC_LOG_V((level), PCF("Hosting"), fmt, ##args)
namespace OIC
{
-namespace Service
-{
+ namespace Service
+ {
-void OIC_HOSTING_LOG(LogLevel level, const char * format, ...);
-
-class HostingObject
-{
-private:
- typedef std::shared_ptr<RCSResourceObject> ResourceObjectPtr;
- typedef std::shared_ptr<RCSRemoteResourceObject> RemoteObjectPtr;
- typedef std::shared_ptr<RequestObject> RequestObjectPtr;
- typedef std::shared_ptr<PrimitiveResource> PrimiteveResourcePtr;
+ class HostingObject
+ {
+ private:
+ typedef RCSResourceObject::Ptr ResourceObjectPtr;
+ typedef RCSRemoteResourceObject::Ptr RemoteObjectPtr;
-public:
- typedef std::shared_ptr<HostingObject> Ptr;
- typedef std::function<void(ResourceState)> BrokerCallback;
- typedef std::function<void(const RCSResourceAttributes &)> CacheCallback;
- typedef std::function<void()> DestroyedCallback;
+ public:
+ typedef std::shared_ptr<HostingObject> Ptr;
+ typedef std::weak_ptr<HostingObject> wPtr;
- typedef std::function<
- RCSSetResponse(const RCSRequest&, RCSResourceAttributes&)> SetRequestHandler;
+ typedef std::function<void()> DestroyedCallback;
+ typedef RCSRemoteResourceObject::StateChangedCallback BrokerCallback;
+ typedef RCSRemoteResourceObject::CacheUpdatedCallback CacheCallback;
+ typedef RCSResourceObject::SetRequestHandler SetRequestHandler;
-public:
- HostingObject();
- ~HostingObject();
+ public:
+ HostingObject();
+ ~HostingObject();
- void initializeHostingObject(RemoteObjectPtr rResource, DestroyedCallback destroyCB);
+ HostingObject(const HostingObject &) = delete;
+ HostingObject & operator = (const HostingObject &) = delete;
- RemoteObjectPtr getRemoteResource() const;
+ HostingObject(HostingObject &&) = delete;
+ HostingObject & operator = (HostingObject &&) = delete;
-private:
- RemoteObjectPtr remoteObject;
- ResourceObjectPtr mirroredServer;
+ static HostingObject::Ptr createHostingObject(const RemoteObjectPtr & rResource,
+ DestroyedCallback destroyCB);
- ResourceState remoteState;
+ RemoteObjectPtr getRemoteResource() const;
- BrokerCallback pStateChangedCB;
- CacheCallback pDataUpdateCB;
- DestroyedCallback pDestroyCB;
+ private:
+ RemoteObjectPtr remoteObject;
+ ResourceObjectPtr mirroredServer;
- SetRequestHandler pSetRequestHandler;
+ CacheCallback pDataUpdateCB;
+ DestroyedCallback pDestroyCB;
- ResourceObjectPtr createMirroredServer(RemoteObjectPtr rObject);
+ std::mutex mutexForCB;
- void stateChangedCB(ResourceState state, RemoteObjectPtr rObject);
- void dataChangedCB(const RCSResourceAttributes & attributes, RemoteObjectPtr rObject);
+ ResourceObjectPtr createMirroredServer(RemoteObjectPtr rObject);
- RCSSetResponse setRequestHandler(
- const RCSRequest & request, RCSResourceAttributes & attributes);
+ RCSSetResponse setRequestHandler(
+ const RCSRequest & request, RCSResourceAttributes & attributes);
- void destroyHostingObject();
+ void destroyHostingObject();
-};
+ public:
+ void stateChangedCB(ResourceState state);
+ void dataChangedCB(const RCSResourceAttributes & attributes);
+ };
-} /* namespace Service */
+ } /* namespace Service */
} /* namespace OIC */
#endif /* RH_HOSTINGOBJECT_H_ */