1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 /// @brief This file contains the declaration of classes and its members required to provide
9 /// functionality of a server. A server role supports resoruce registration, binding
10 /// and advertisement.
19 #include "OCSecurityModel.h"
21 namespace OC { namespace OCReflect {
23 struct method_binding;
24 struct property_binding;
26 }} // namespace OC::OCReflect
31 @brief A server instance which is the starting point for a UB device that wishes to host a
32 set of resource(s) for other devices.
37 std::map<std::string, OC::OCReflect::method_binding> method_bindings;
41 virtual ~OCServer(void);
44 * @fn This registers a security model for access control to resources under this service.
46 * @param model - Security Model required for access to this service and control/view of it's
49 void setSecurityModel(OCSecurityModel model) ;
52 * @fn Registers a resource with the service.
54 * @param object - The OCObject that handles the resource requests
55 * @param url - The URL under the resource.
56 * @param accessControl - The access control handler that determines whether the remote device is
57 * allowed to access this resource. If NULL, all access is granted.
59 void registerResource(OCObject *object, std::string url/* TODO: , AccessControl accessControl */);
62 * @fn Unregisters a resource with the service.
64 * @param object - The OCObject to be unregistered.
66 void unregisterResource(OCObject *object);
69 * @fn Starts the open connectivity service.
71 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
76 * Stops the open connectivity service.
78 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
83 void bind(const OC::OCReflect::method_binding& mb);
85 void bind(const OC::OCReflect::property_binding& pb)
89 void registerResource(T *object, const std::string& base_URI)
93 const std::map<std::string, OC::OCReflect::method_binding>& methods() const { return method_bindings; }