Fix wrong comments in groupmanager.h for doxygen
[platform/upstream/iotivity.git] / service / things-manager / sdk / inc / GroupManager.h
1 //******************************************************************
2 //
3 // Copyright 2014 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 declaration of classes and its members related to
25  * GroupManager.
26  */
27
28 #ifndef __OC_GROUPMANAGER__
29 #define __OC_GROUPMANAGER__
30
31 #include <string>
32 #include <vector>
33 #include <map>
34 #include <cstdlib>
35 #include <ActionSet.h>
36 #include "OCPlatform.h"
37 #include "OCApi.h"
38
39 using namespace OC;
40
41 namespace OIC
42 {
43 typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
44 typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
45
46 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > GetCallback;
47 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PostCallback;
48 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PutCallback;
49
50 /**
51  * @class GroupManager
52  * @brief
53  * This APIs provide functions for application to find appropriate devices (i.e. things) in network,
54  * create a group of the devices, check a presence of member devices in the group, and actuate a
55  * group action in a more convenient way.
56  */
57 class GroupManager
58 {
59 public:
60     /**
61      * Constructor for GroupManager. Constructs a new GroupManager
62      */
63     GroupManager(void);
64
65     /**
66      * Virtual destructor
67      */
68     ~GroupManager(void);
69
70     /**
71      * API for candidate resources discovery.
72      * Callback only call when all resource types found.
73      *
74      * @param resourceTypes required resource types(called "candidate")
75      * @param callback callback with OCResource vector.
76      * @param waitsec time to wait to finish finding resources
77      *
78      * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
79      *
80      * NOTE: OCStackResult is defined in ocstack.h.
81      */
82     OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
83             CandidateCallback callback, int waitsec = -1);
84
85     /**
86      * API for Collection member's state subscribe.
87      *
88      * NOTE: NOT IMPLEMENT YET
89      */
90     OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
91             CollectionPresenceCallback);
92
93     OCStackResult bindResourceToGroup(OCResourceHandle& childHandle,
94             std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
95
96 private:
97
98     void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
99     void findPreparedRequest(std::map< std::vector< std::string >, CandidateCallback > &request);
100     void lazyCallback(int second);
101
102     void onGetForPresence(const HeaderOptions& headerOptions, const OCRepresentation& rep,
103             const int eCode, CollectionPresenceCallback callback);
104     void checkCollectionRepresentation(const OCRepresentation& rep,
105             CollectionPresenceCallback callback);
106     void collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
107             const std::string& hostAddress, std::string host, std::string uri);
108
109     /**
110      *   API for Collection(Group) action.
111      */
112
113 public:
114     /**
115      * API for extracting an action set string from the ActionSet class instance
116      *
117      * @param newActionSet pointer of ActionSet class instance
118      *
119      * @return std::string return value of this API.
120      *                     It returns an action set String.
121      * @note OCStackResult is defined in ocstack.h.
122      */
123     std::string getStringFromActionSet(const ActionSet *newActionSet);
124
125     /**
126      * API for extrracting ActionSet class instance from an action set string.
127      *
128      * @param desc description of an action set string
129      *
130      * @return ActionSet* return value of this API.
131      *                      It returns pointer of ActionSet.
132      */
133     ActionSet* getActionSetfromString(std::string desc);
134
135     /**
136      * API for adding an action set.
137      * Callback is called when the response of PUT operation arrives.
138      *
139      * @param resource resource pointer of the group resource
140      * @param newActionSet pointer of ActionSet class instance
141      * @param cb callback for PUT operation.
142      *
143      * @return Returns ::OC_STACK_OK if success.
144      *
145      * @note OCStackResult is defined in ocstack.h.
146      */
147     OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
148             const ActionSet* newActionSet, PutCallback cb);
149
150     /**
151      * API for executing an existing action set.
152      * Callback is called when the response of  POST operation arrives.
153      *
154      * @param resource resource pointer of the group resource
155      * @param actionsetName the action set name for executing the action set
156      * @param cb callback for POST operation.
157      *
158      * @return Returns ::OC_STACK_OK if success.
159      * @note OCStackResult is defined in ocstack.h.
160      */
161     OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
162             std::string actionsetName, PostCallback cb);
163
164     /**
165      * API for executing an existing action set.
166      * Callback is called when the response of  POST operation arrives.
167      *
168      * @param resource resource pointer of the group resource
169      * @param actionsetName the action set name for executing the action set
170      * @param delay waiting time for until the action set run.
171      * @param cb callback for POST operation.
172      *
173      * @return Returns ::OC_STACK_OK if success.
174      * @note OCStackResult is defined in ocstack.h.
175      */
176     OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
177             std::string actionsetName, long int delay, PostCallback cb);
178
179     /**
180      * API for canceling an existing action set.
181      * Callback is called when the response of POST operation arrives.
182      *
183      * @param resource resource pointer of the group resource
184      * @param actionsetName the action set name for executing the action set
185      * @param cb callback for POST operation.
186      *
187      * @return Returns ::OC_STACK_OK if success.
188      * @note OCStackResult is defined in ocstack.h.
189      */
190     OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
191             std::string actionsetName, PostCallback cb);
192
193     /**
194      * API for reading an existing action set.
195      * Callback is called when the response of GET operation arrives.
196      *
197      * @param resource resource pointer of the group resource
198      * @param actionsetName the action set name for reading the action set
199      * @param cb callback for GET operation.
200      *
201      * @return Returns ::OC_STACK_OK if success.
202      * @note OCStackResult is defined in ocstack.h.
203      */
204     OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
205             PostCallback cb);
206
207     /**
208      * API for removing an existing action set.
209      * Callback is called when the response of  POST operation arrives.
210      *
211      * @param resource resource pointer of the group resource
212      * @param actionsetName the action set name for removing the action set
213      * @param cb callback for POST operation.
214      *
215      * @return Returns ::OC_STACK_OK if success.
216      * @note OCStackResult is defined in ocstack.h.
217      */
218     OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
219             PostCallback cb);
220 };
221 }
222 #endif  /* __OC_GROUPMANAGER__*/