Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / service / resource-encapsulation / include / RCSDiscoveryManager.h
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This file contains the RCSDiscoveryManager class which provide API to discover the Resource in the network
25  *
26  */
27
28 #ifndef RCSDISCOVERYMANAGER_H
29 #define RCSDISCOVERYMANAGER_H
30
31 #include <memory>
32 #include <functional>
33
34 namespace OIC
35 {
36     namespace Service
37     {
38
39         class RCSRemoteResourceObject;
40         class RCSAddress;
41
42         /**
43          * This class contains the resource discovery method.
44          *
45          * @see RCSRemoteResourceObject
46          */
47         class RCSDiscoveryManager
48         {
49         public:
50
51             /**
52              * Typedef for callback of discoverResource API
53              *
54              * @see discoverResource
55              */
56             typedef std::function< void(std::shared_ptr< RCSRemoteResourceObject >) >
57                 ResourceDiscoveredCallback;
58
59             /**
60              * Returns RCSDiscoveryManager instance.
61              *
62              */
63             static RCSDiscoveryManager* getInstance();
64
65             /**
66              * API for discovering the resource of Interest.
67              *
68              * @param address A RCSAddress object
69              * @param resourceURI The uri of resource to be searched
70              * @param cb A callback to obtain discovered resource
71              *
72              * @throws InvalidParameterException If cb is empty.
73              *
74              * @note The callback will be invoked in an internal thread.
75              *
76              * @see RCSAddress
77              *
78              */
79             void discoverResource(const RCSAddress& address, const std::string& resourceURI,
80                     ResourceDiscoveredCallback cb);
81
82         private:
83             RCSDiscoveryManager() = default;
84             ~RCSDiscoveryManager() = default;
85
86         };
87     }
88 }
89 #endif // RCSDISCOVERYMANAGER_H