1 //******************************************************************
3 // Copyright 2014 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 declaration of classes and its members related to
28 #ifndef __OC_GROUPMANAGER__
29 #define __OC_GROUPMANAGER__
35 #include <ActionSet.h>
36 #include "OCPlatform.h"
43 typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
44 typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
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;
54 * Constructor for GroupManager. Constructs a new GroupManager
64 * API for candidate resources discovery.
65 * Callback only call when all resource types found.
67 * @param resourceTypes - required resource types(called "candidate")
68 * @param candidateCallback - callback. OCResource vector.
70 * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
72 * NOTE: OCStackResult is defined in ocstack.h.
74 OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
75 CandidateCallback callback, int waitsec = -1);
78 * API for Collection member's state subscribe.
80 * NOTE: NOT IMPLEMENT YET
82 OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
83 CollectionPresenceCallback);
85 OCStackResult bindResourceToGroup(OCResourceHandle& childHandle,
86 std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
90 void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
91 void findPreparedRequest(std::map< std::vector< std::string >, CandidateCallback > &request);
92 void lazyCallback(int second);
94 void onGetForPresence(const HeaderOptions& headerOptions, const OCRepresentation& rep,
95 const int eCode, CollectionPresenceCallback callback);
96 void checkCollectionRepresentation(const OCRepresentation& rep,
97 CollectionPresenceCallback callback);
98 void collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
99 const std::string& hostAddress, std::string host, std::string uri);
102 * API for Collection(Group) action.
106 std::string getStringFromActionSet(const ActionSet *newActionSet);
107 ActionSet* getActionSetfromString(std::string desc);
109 OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
110 const ActionSet* newActionSet, PutCallback cb);
111 OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
112 std::string actionsetName, PostCallback cb);
113 OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
114 std::string actionsetName, long int delay, PostCallback cb);
115 OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
116 std::string actionsetName, PostCallback cb);
117 OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
119 OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
123 #endif /* __OC_GROUPMANAGER__*/