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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the RCSActiveDiscoveryManager class which provide APIs to discover the Resource in the network
28 #ifndef RCSDISCOVERYMANAGER_IMPL_H
29 #define RCSDISCOVERYMANAGER_IMPL_H
35 #include <unordered_map>
40 #include "RCSDiscoveryManager.h"
41 #include "RCSAddress.h"
42 #include "ExpiryTimer.h"
43 #include "PrimitiveResource.h"
44 #include "RCSRemoteResourceObject.h"
50 class RCSDiscoveryManager;
51 class PrimitiveResource;
53 class DiscoverRequestInfo
57 std::string m_address;
58 std::string m_relativeUri;
59 std::string m_resourceType;
60 std::list<std::string> m_receivedIds;
61 bool m_isReceivedFindCallback;
62 DiscoverCallback m_findCB;
63 RCSDiscoveryManager::ResourceDiscoveredCallback m_discoverCB;
66 class RCSDiscoveryManagerImpl
68 static unsigned int s_uniqueId;
72 typedef std::function<void(OCStackResult, const unsigned int,
73 const std::string&)> PresenceCallback;
74 typedef unsigned int ID;
75 typedef std::function<void(std::shared_ptr< PrimitiveResource >, ID)> FindCallback;
79 static RCSDiscoveryManagerImpl* getInstance();
81 DiscoverRequestInfo m_discoveryItem;
82 std::unordered_map<ID,DiscoverRequestInfo> m_discoveryMap;
83 PresenceCallback m_presenceCB;
84 ExpiryTimer::Callback m_pollingCB;
89 static RCSDiscoveryManagerImpl * s_instance;
90 static std::mutex s_mutexForCreation;
95 std::unique_ptr<RCSDiscoveryManager::DiscoveryTask> startDiscovery(const RCSAddress& address,
96 const std::string& relativeURI,const std::string& resourceType,
97 RCSDiscoveryManager::ResourceDiscoveredCallback cb);
101 void requestMulticastPresence();
102 void initializedDiscoveryEnvironment();
103 void findCallback(std::shared_ptr< PrimitiveResource > resource, ID discoverID);
104 void pollingCallback(unsigned int /*msg*/);
105 void presenceCallback(OCStackResult, const unsigned int,const std::string&);
106 bool isDuplicatedCallback(std::shared_ptr<PrimitiveResource> resource,ID discoverID);
111 RCSDiscoveryManagerImpl() = default;;
112 ~RCSDiscoveryManagerImpl() = default;
116 #endif // RCSDISCOVERYMANAGER_IMPL_H