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 RCSDiscoveryManager class which provides APIs to discover the
25 * Resource in the network
29 #ifndef RCS_DISCOVERYMANAGER_H_
30 #define RCS_DISCOVERYMANAGER_H_
41 class RCSRemoteResourceObject;
43 * This class contains the resource discovery methods.
45 * @see RCSRemoteResourceObject
47 class RCSDiscoveryManager
52 * This class represents a discovery task.
58 typedef std::unique_ptr< DiscoveryTask > Ptr;
62 DiscoveryTask(const DiscoveryTask&) = delete;
63 DiscoveryTask(DiscoveryTask&&) = delete;
64 DiscoveryTask& operator =(const DiscoveryTask&) const = delete;
65 DiscoveryTask& operator =(DiscoveryTask&&) const = delete;
68 * It cancels the task of discovery.
69 * If it is already canceled, the operation is ignored.
74 * Returns whether the discovery request is canceled or not.
79 explicit DiscoveryTask(unsigned int);
84 friend class RCSDiscoveryManagerImpl;
90 * Typedef for callback of discoverResource APIs
92 * @see discoverResource
94 typedef std::function< void(std::shared_ptr< RCSRemoteResourceObject >) >
95 ResourceDiscoveredCallback;
98 * @return RCSDiscoveryManager instance.
101 static RCSDiscoveryManager* getInstance();
104 * Discovers resources of interest, regardless of uri and resource type.
105 * It will consistently discover resources until the discovery task is canceled.
107 * @param address A RCSAddress object
108 * @param cb A callback to obtain discovered resource
110 * @throws InvalidParameterException If cb is empty.
112 * @note The callback will be invoked in an internal thread.
115 DiscoveryTask::Ptr discoverResource(const RCSAddress& address,
116 ResourceDiscoveredCallback cb);
119 * Discovers resources of interest, regardless of resource type.
120 * It will consistently discover resources until the discovery task is canceled.
122 * @param address A RCSAddress object
123 * @param relativeUri The relative uri of resource to be searched
124 * @param cb A callback to obtain discovered resource
126 * @throws InvalidParameterException If cb is empty.
128 * @note The callback will be invoked in an internal thread.
131 DiscoveryTask::Ptr discoverResource(const RCSAddress& address,
132 const std::string& relativeUri, ResourceDiscoveredCallback cb);
135 * Discovers resources of interest by resource type.
136 * It will consistently discover resources until the discovery task is canceled.
138 * @param address A RCSAddress object
139 * @param resourceType Resource Type
140 * @param cb A callback to obtain discovered resource
142 * @throws InvalidParameterException If cb is empty.
144 * @note The callback will be invoked in an internal thread.
147 DiscoveryTask::Ptr discoverResourceByType(const RCSAddress& address,
148 const std::string& resourceType, ResourceDiscoveredCallback cb);
151 * Discovers resources of interest by resource types.
152 * It will consistently discover resources until the discovery task is canceled.
154 * @param address A RCSAddress object
155 * @param resourceTypes List of Resource Types
156 * @param cb A callback to obtain discovered resource
158 * @throws InvalidParameterException If cb is empty.
159 * @throws RCSBadRequestException If resourceTypes contain more than one element and
160 * any of them is empty.
162 * @note The callback will be invoked in an internal thread.
163 * @note If resourceTypes is empty, discovers resource by all resource types.
166 DiscoveryTask::Ptr discoverResourceByTypes(const RCSAddress& address,
167 const std::vector< std::string >& resourceTypes,
168 ResourceDiscoveredCallback cb);
171 * Discovers resources of interest by a resource type with provided relativeUri.
172 * It will consistently discover resources until the discovery task is canceled.
174 * @param address A RCSAddress object
175 * @param relativeUri The relative uri of resource to be searched
176 * @param resourceType Resource Type
177 * @param cb A callback to obtain discovered resource
179 * @throws InvalidParameterException If cb is empty.
181 * @note The callback will be invoked in an internal thread.
184 DiscoveryTask::Ptr discoverResourceByType(const RCSAddress& address,
185 const std::string& relativeUri, const std::string& resourceType,
186 ResourceDiscoveredCallback cb);
189 * Discovers resources of interest by resource types with provided relativeUri.
190 * It will consistently discover resources until the discovery task is canceled.
192 * @param address A RCSAddress object
193 * @param relativeUri The relative uri of resource to be searched
194 * @param resourceTypes List of Resource Types
195 * @param cb A callback to obtain discovered resource
197 * @throws InvalidParameterException If cb is empty.
198 * @throws RCSBadRequestException If resourceTypes contain more than one element and
199 * any of them is empty.
201 * @note The callback will be invoked in an internal thread.
202 * @note If resourceTypes is empty, discovers resource by all resource types.
205 DiscoveryTask::Ptr discoverResourceByTypes(const RCSAddress& address,
206 const std::string& relativeUri,
207 const std::vector< std::string >& resourceTypes,
208 ResourceDiscoveredCallback cb);
212 RCSDiscoveryManager() = default;
213 ~RCSDiscoveryManager() = default;
217 #endif // RCSDISCOVERYMANAGER_H