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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 /// @file GroupManager.h
23 /// @brief This file contains the declaration of classes and its members related to GroupManager
25 #ifndef __OC_GROUPMANAGER__
26 #define __OC_GROUPMANAGER__
32 #include "OCPlatform.h"
39 typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
40 typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
42 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > GetCallback;
43 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PostCallback;
44 typedef std::function< void(const HeaderOptions&, const OCRepresentation&, const int) > PutCallback;
49 std::string capability;
62 listOfCapability.clear();
66 std::vector< Capability* > listOfCapability;
80 std::string actionsetName;
82 std::vector< Action* > listOfAction;
89 * Constructor for GroupManager. Constructs a new GroupManager
99 * API for candidate resources discovery.
100 * Callback only call when all resource types found.
102 * @param resourceTypes - required resource types(called "candidate")
103 * @param candidateCallback - callback. OCResource vector.
105 * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
107 * NOTE: OCStackResult is defined in ocstack.h.
109 OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
110 CandidateCallback callback, int waitsec = -1);
113 * API for Collection member's state subscribe.
115 * NOTE: NOT IMPLEMENT YET
117 OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
118 CollectionPresenceCallback);
122 void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
123 void findPreparedRequest(std::map< std::vector< std::string >, CandidateCallback > &request);
124 void lazyCallback(int second);
126 void onGetForPresence(const HeaderOptions& headerOptions, const OCRepresentation& rep,
127 const int eCode, CollectionPresenceCallback callback);
128 void checkCollectionRepresentation(const OCRepresentation& rep,
129 CollectionPresenceCallback callback);
130 void collectionPresenceHandler(OCStackResult result, const unsigned int nonce,
131 const std::string& hostAddress, std::string host, std::string uri);
134 * API for Collection(Group) action.
138 std::string getStringFromActionSet(const ActionSet *newActionSet);
139 ActionSet* getActionSetfromString(std::string desc);
141 OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
142 const ActionSet* newActionSet, PutCallback cb);
143 OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
144 std::string actionsetName, PostCallback cb);
145 OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
147 OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
151 #endif /* __OC_GROUPMANAGER__*/