1 //******************************************************************
3 // Copyright 2014 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 #include "RegistrationManager.h"
23 RegistrationManager *RegistrationManager::s_instance = NULL;
24 mutex RegistrationManager::s_mutexForCreation;
26 RegistrationManager::RegistrationManager()
30 RegistrationManager::~RegistrationManager()
34 RegistrationManager *RegistrationManager::getInstance()
38 s_mutexForCreation.lock();
41 s_instance = new RegistrationManager();
43 s_mutexForCreation.unlock();
49 int RegistrationManager::addResource()
54 int RegistrationManager::removeResource()
59 int RegistrationManager::updateResource()
64 bool RegistrationManager::registerNMResource(VirtualRepresentation &resourceObject ,
65 std::shared_ptr< OCResource > resource)
67 std::string uri = resourceObject.getUri();
68 std::string type = resourceObject.getResourceTypeName();
69 std::string interface = resourceObject.getResourceInterface();
71 OCResourceHandle resourceHandle;
74 result = registerResource(resourceHandle , uri , type ,
77 OCEntityHandlerResult(const std::shared_ptr< OCResourceRequest > request ,
78 const std::shared_ptr< OCResourceResponse > response) >(
79 std::bind(&VirtualRepresentation::entityHandler , resourceObject ,
80 std::placeholders::_1 , std::placeholders::_2)) ,
81 resourceObject.getResourceProperty());
83 resourceObject.setResourceHandle(resourceHandle);
85 if(OC_STACK_OK != result)
91 QueryParamsMap queryParmaMap;
92 resource->observe(ObserveType::Observe , queryParmaMap ,
94 void(const HeaderOptions headerOption,
95 const OCRepresentation& rep , const int& eCode ,
96 const int& sequenceNumber) >(
97 std::bind(&VirtualRepresentation::onObserve , resourceObject ,
98 std::placeholders::_1 , std::placeholders::_2 ,
99 std::placeholders::_3 , std::placeholders::_4)));
105 bool RegistrationManager::unregisterResource()