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;
25 RegistrationManager::RegistrationManager()
29 RegistrationManager::~RegistrationManager()
33 RegistrationManager *RegistrationManager::getInstance()
37 s_instance = new RegistrationManager();
42 int RegistrationManager::addResource()
47 int RegistrationManager::removeResource()
52 int RegistrationManager::updateResource()
57 bool RegistrationManager::registerNMResource(VirtualRepresentation &resourceObject ,
58 std::shared_ptr< OCResource > resource)
60 std::string uri = resourceObject.getUri();
61 std::string type = resourceObject.getResourceTypeName();
62 std::string interface = resourceObject.getResourceInterface();
64 OCResourceHandle resourceHandle;
68 result = registerResource(resourceHandle , uri , type ,
71 OCEntityHandlerResult(const std::shared_ptr< OCResourceRequest > request ,
72 const std::shared_ptr< OCResourceResponse > response) >(
73 std::bind(&VirtualRepresentation::entityHandler , resourceObject ,
74 std::placeholders::_1 , std::placeholders::_2)) ,
75 resourceObject.getResourceProperty());
76 resourceObject.setResourceHandle(resourceHandle);
78 if(OC_STACK_OK != result)
84 QueryParamsMap queryParmaMap;
85 resource->observe(ObserveType::Observe , queryParmaMap ,
87 void(const HeaderOptions headerOption,
88 const OCRepresentation& rep , const int eCode ,
89 const int sequenceNumber) >(
90 std::bind(&VirtualRepresentation::onObserve , resourceObject ,
91 std::placeholders::_1 , std::placeholders::_2 ,
92 std::placeholders::_3 , std::placeholders::_4)));
98 bool RegistrationManager::unregisterResource()