fix all coding standard problem. This commit did NOT include logic changes .
Change-Id: I34f7a33374f137b8b641dff74e113b4941cb1391
uint8_t resourceProperties);
/**
- * Create a resource. with host ip address for rsrc_t
+ * Create a resource. with host ip address for remote resource
*
- * @param handle - pointer to handle to newly created resource. Set by ocstack. Used to refer to resource
+ * @param handle - pointer to handle to newly created resource. Set by ocstack.
+ * Used to refer to resource
* @param resourceTypeName - name of resource type. Example: "core.led"
* @param resourceInterfaceName - name of resource interface. Example: "core.rw"
- * @param host - HOST address of the resource. Example: "coap://xxx.xxx.xxx.xxx:xxxxx"
+ * @param host - HOST address of the remote resource. Example: "coap://xxx.xxx.xxx.xxx:xxxxx"
* @param uri - URI of the resource. Example: "/a/led"
* @param entityHandler - entity handler function that is called by ocstack to handle requests, etc
* NULL for default entity handler
- * @param resourceProperties - properties supported by resource. Example: OC_DISCOVERABLE|OC_OBSERVABLE
+ * @param resourceProperties - properties supported by resource.
+ * Example: OC_DISCOVERABLE|OC_OBSERVABLE
*
* @return
* OC_STACK_OK - no errors
/**
- * Create a resource. with host ip address for rsrc_t
+ * Create a resource. with host ip address for remote resource
*
- * @param handle - pointer to handle to newly created resource. Set by ocstack. Used to refer to resource
+ * @param handle - pointer to handle to newly created resource. Set by ocstack.
+ * Used to refer to resource
* @param resourceTypeName - name of resource type. Example: "core.led"
* @param resourceInterfaceName - name of resource interface. Example: "core.rw"
- * @param host - HOST address of the resource. Example: "coap://xxx.xxx.xxx.xxx:xxxxx"
+ * @param host - HOST address of the remote resource. Example: "coap://xxx.xxx.xxx.xxx:xxxxx"
* @param uri - URI of the resource. Example: "/a/led"
* @param entityHandler - entity handler function that is called by ocstack to handle requests, etc
* NULL for default entity handler
- * @param resourceProperties - properties supported by resource. Example: OC_DISCOVERABLE|OC_OBSERVABLE
+ * @param resourceProperties - properties supported by resource.
+ * Example: OC_DISCOVERABLE|OC_OBSERVABLE
*
* @return
* OC_STACK_OK - no errors
const char *host,
const char *uri,
OCEntityHandler entityHandler,
- uint8_t resourceProperties) {
-
-
- char *str = NULL;
- size_t size;
- OCStackResult result = OC_STACK_ERROR;
+ uint8_t resourceProperties)
+{
+ char *str = NULL;
+ size_t size;
+ OCStackResult result = OC_STACK_ERROR;
- result = OCCreateResource(handle,resourceTypeName,resourceInterfaceName,uri,entityHandler,resourceProperties);
+ result = OCCreateResource(handle, resourceTypeName, resourceInterfaceName,
+ uri, entityHandler, resourceProperties);
- if( result != OC_STACK_ERROR)
- {
- // Set the uri
- size = strlen(host) + 1;
- str = (char *) OCMalloc(size);
- if (!str) {
- return OC_STACK_ERROR;
- }
- strncpy(str, host, size);
- ((OCResource *)*handle)->host = str;
- }
+ if (result != OC_STACK_ERROR)
+ {
+ // Set the uri
+ size = strlen(host) + 1;
+ str = (char *) OCMalloc(size);
+ if (!str)
+ {
+ return OC_STACK_ERROR;
+ }
+ strncpy(str, host, size);
+ ((OCResource *) *handle)->host = str;
+ }
- return result;
+ return result;
}
/**
EntityHandler& entityHandler,
uint8_t resourceProperty) = 0;
-
- virtual OCStackResult registerResourceWithHost(
+ virtual OCStackResult registerResourceWithHost(
OCResourceHandle& resourceHandle,
std::string& resourceHOST,
std::string& resourceURI,
EntityHandler& entityHandler,
uint8_t resourceProperty);
- virtual OCStackResult registerResourceWithHost(
+ virtual OCStackResult registerResourceWithHost(
OCResourceHandle& resourceHandle,
std::string& resourceHOST,
std::string& resourceURI,
uint8_t resourceProperty);
/**
- * This API registers a resource with the server
- * NOTE: This API applies to server & client side.
+ * This API registers a resource with the server
+ * NOTE: This API applies to server & client side.
- * @param resourceHandle - Upon successful registration, resourceHandle will be filled
- * @param resource - The resource that all data filled.
- *
- * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
- */
+ * @param resourceHandle - Upon successful registration, resourceHandle will be filled
+ * @param OCResource - The instance of OCResource that all data filled.
+ *
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ */
- OCStackResult registerResource(OCResourceHandle& resourceHandle,
- const std::shared_ptr<OCResource> resource);
+ OCStackResult registerResource(OCResourceHandle& resourceHandle,
+ const std::shared_ptr< OCResource > resource);
/**
* Set default device entity handler
EntityHandler entityHandler,
uint8_t resourceProperty);
- /**
- * This API registers a resource with the server
- * NOTE: This API applies to server & client side.
+ /**
+ * This API registers a resource with the server
+ * NOTE: This API applies to server & client side.
- * @param resourceHandle - Upon successful registration, resourceHandle will be filled
- * @param resource - The resource that all data filled.
- *
- * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
- */
+ * @param resourceHandle - Upon successful registration, resourceHandle will be filled
+ * @param OCResource - The instance of OCResource that all data filled.
+ *
+ * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
+ */
- OCStackResult registerResource(OCResourceHandle& resourceHandle,
- const std::shared_ptr<OCResource> resource);
+ OCStackResult registerResource(OCResourceHandle& resourceHandle,
+ const std::shared_ptr<OCResource> resource);
/**
* Set default device entity handler
// Not implemented
return OC_STACK_NOTIMPL;
}
- virtual OCStackResult registerResourceWithHost(
+ virtual OCStackResult registerResourceWithHost(
OCResourceHandle& resourceHandle,
std::string& resourceHOST,
std::string& resourceURI,
const std::string& resourceInterface,
EntityHandler& entityHandler,
uint8_t resourceProperty)
- {
- return OC_STACK_NOTIMPL;
- }
+ {
+ // Not implemented
+ return OC_STACK_NOTIMPL;
+ }
virtual OCStackResult unregisterResource(
const OCResourceHandle& resourceHandle)
return result;
}
- OCStackResult InProcServerWrapper::registerResourceWithHost(
- OCResourceHandle& resourceHandle,
- std::string& resourceHOST,
- std::string& resourceURI,
- const std::string& resourceTypeName,
- const std::string& resourceInterface,
- EntityHandler& eHandler,
- uint8_t resourceProperties)
-
- {
- OCStackResult result = OC_STACK_ERROR;
-
- auto cLock = m_csdkLock.lock();
-
- if(cLock)
- {
- std::lock_guard<std::recursive_mutex> lock(*cLock);
-
- if(NULL != eHandler)
- {
- result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
- resourceTypeName.c_str(), // const char * resourceTypeName
- resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix this
- resourceHOST.c_str(), // const char * host
- resourceURI.c_str(), // const char * uri
- EntityHandlerWrapper, // OCEntityHandler entityHandler
- resourceProperties // uint8_t resourceProperties
- );
- }
- else
- {
- result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
- resourceTypeName.c_str(), // const char * resourceTypeName
- resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix this
- resourceHOST.c_str(), // const char * host
- resourceURI.c_str(), // const char * uri
- NULL, // OCEntityHandler entityHandler
- resourceProperties // uint8_t resourceProperties
- );
- }
-
- if(result != OC_STACK_OK)
- {
- resourceHandle = (OCResourceHandle) 0;
- }
- else
- {
- entityHandlerMap[resourceHandle] = eHandler;
- resourceUriMap[resourceHandle] = resourceURI;
- }
- }
- else
- {
- result = OC_STACK_ERROR;
- }
-
- return result;
- }
+ OCStackResult InProcServerWrapper::registerResourceWithHost(
+ OCResourceHandle& resourceHandle,
+ std::string& resourceHOST,
+ std::string& resourceURI,
+ const std::string& resourceTypeName,
+ const std::string& resourceInterface,
+ EntityHandler& eHandler,
+ uint8_t resourceProperties)
+
+ {
+ OCStackResult result = OC_STACK_ERROR;
+
+ auto cLock = m_csdkLock.lock();
+
+ if (cLock)
+ {
+ std::lock_guard < std::recursive_mutex > lock(*cLock);
+
+ if (NULL != eHandler)
+ {
+ result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
+ resourceTypeName.c_str(), // const char * resourceTypeName
+ resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
+ resourceHOST.c_str(), // const char * host
+ resourceURI.c_str(), // const char * uri
+ EntityHandlerWrapper, // OCEntityHandler entityHandler
+ resourceProperties // uint8_t resourceProperties
+ );
+ }
+ else
+ {
+ result = OCCreateResourceWithHost(&resourceHandle, // OCResourceHandle *handle
+ resourceTypeName.c_str(), // const char * resourceTypeName
+ resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix
+ resourceHOST.c_str(), // const char * host
+ resourceURI.c_str(), // const char * uri
+ nullptr, // OCEntityHandler entityHandler
+ resourceProperties // uint8_t resourceProperties
+ );
+ }
+
+ if (result != OC_STACK_OK)
+ {
+ resourceHandle = nullptr;
+ }
+ else
+ {
+ entityHandlerMap[resourceHandle] = eHandler;
+ resourceUriMap[resourceHandle] = resourceURI;
+ }
+ }
+ else
+ {
+ result = OC_STACK_ERROR;
+ }
+
+ return result;
+ }
OCStackResult InProcServerWrapper::setDefaultDeviceEntityHandler
(EntityHandler entityHandler)
{
entityHandler, resourceProperty);
}
- OCStackResult registerResource(OCResourceHandle& resourceHandle,
- const std::shared_ptr<OCResource> resource)
+ OCStackResult registerResource(OCResourceHandle& resourceHandle,
+ const std::shared_ptr< OCResource > resource)
{
return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
}
OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
- const std::shared_ptr<OCResource> resource)
- {
- uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
-
- return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
- ref(resourceHandle), resource->host(), resource->uri(), "core.remote",
- "oc.mi.def", (EntityHandler) NULL, resourceProperty);
+ const std::shared_ptr< OCResource > resource)
+ {
+ uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
+ return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
+ ref(resourceHandle), resource->host(), resource->uri(), "core.remote", "oc.mi.def",
+ (EntityHandler) nullptr, resourceProperty);
- }
+ }
OCStackResult OCPlatform_impl::unregisterResource(const OCResourceHandle& resourceHandle) const
{
return checked_guard(m_server, &IServerWrapper::unregisterResource,