1 //******************************************************************
3 // Copyright 2015 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 "RCSDiscoveryManager.h"
23 #include "RCSRemoteResourceObject.h"
24 #include "PrimitiveResource.h"
26 #include "ScopeLogger.h"
28 #define TAG PCF("RCSDiscoveryManager")
30 using namespace OIC::Service;
34 void findCallback(std::shared_ptr< PrimitiveResource > primitiveResource,
35 RCSDiscoveryManager::ResourceDiscoveredCallback cb)
37 SCOPE_LOG_F(DEBUG, TAG);
39 if (!primitiveResource)
41 OC_LOG(ERROR, TAG, "findCallback : primitiveResource is null.");
45 cb(std::make_shared< RCSRemoteResourceObject >(primitiveResource));
53 RCSDiscoveryManager* RCSDiscoveryManager::getInstance()
55 static RCSDiscoveryManager instance;
59 void RCSDiscoveryManager::discoverResource(const RCSAddress& address,
60 const std::string& resourceURI, ResourceDiscoveredCallback cb)
62 SCOPE_LOG_F(DEBUG, TAG);
66 OC_LOG(ERROR, TAG, "discoverResource NULL Callback");
67 throw InvalidParameterException{ "discoverResource NULL Callback'" };
70 OIC::Service::discoverResource(address, resourceURI,
71 std::bind(findCallback, std::placeholders::_1, std::move(cb)));