1 //******************************************************************
3 // Copyright 2014 Intel Corporation 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 /// @brief This file contains the declaration of classes and its members required to provide
24 /// functionality of a server. A server role supports resoruce registration, binding
25 /// and advertisement.
34 #include "OCSecurityModel.h"
36 namespace OC { namespace OCReflect {
38 struct method_binding;
39 struct property_binding;
41 }} // namespace OC::OCReflect
46 @brief A server instance which is the starting point for a UB device that wishes to host a
47 set of resource(s) for other devices.
52 std::map<std::string, OC::OCReflect::method_binding> method_bindings;
56 virtual ~OCServer(void);
59 * @fn This registers a security model for access control to resources under this service.
61 * @param model - Security Model required for access to this service and control/view of it's
64 void setSecurityModel(OCSecurityModel model) ;
67 * @fn Registers a resource with the service.
69 * @param object - The OCObject that handles the resource requests
70 * @param url - The URL under the resource.
71 * @param accessControl - The access control handler that determines whether the remote device is
72 * allowed to access this resource. If NULL, all access is granted.
74 void registerResource(OCObject *object, std::string url/* TODO: , AccessControl accessControl */);
77 * @fn Unregisters a resource with the service.
79 * @param object - The OCObject to be unregistered.
81 void unregisterResource(OCObject *object);
84 * @fn Starts the open connectivity service.
86 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
91 * Stops the open connectivity service.
93 * Thread-Safety: TODO Determine if it is going to be safe to call in a UI thread
98 void bind(const OC::OCReflect::method_binding& mb);
100 void bind(const OC::OCReflect::property_binding& pb)
104 void registerResource(T *object, const std::string& base_URI)
108 const std::map<std::string, OC::OCReflect::method_binding>& methods() const { return method_bindings; }
112 #endif //__OCSERVER_H