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 TGMClient.
25 #ifndef __OC_GROUPMANAGER__
26 #define __OC_GROUPMANAGER__
32 #include "OCPlatform.h"
37 typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
38 typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
40 typedef std::function<void(const HeaderOptions&, const OCRepresentation&, const int)> GetCallback;
41 typedef std::function<void(const HeaderOptions&, const OCRepresentation&, const int)> PostCallback;
42 typedef std::function<void(const HeaderOptions&, const OCRepresentation&, const int)> PutCallback;
48 std::string capability;
60 listOfCapability.clear();
64 std::vector<Capability*> listOfCapability;
70 ActionSet() : actionsetName("")
77 std::string actionsetName;
79 std::vector<Action*> listOfAction;
87 * Constructor for TGMClient. Constructs a new TGMClient
97 * API for candidate resources discovery.
98 * Callback only call when all resource types found.
100 * @param resourceTypes - required resource types(called "candidate")
101 * @param candidateCallback - callback. OCResource vector.
103 * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
105 * NOTE: OCStackResult is defined in ocstack.h.
107 OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
108 CandidateCallback callback, int waitsec = -1);
111 * API for Collection member's state subscribe.
113 * NOTE: NOT IMPLEMENT YET
115 OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource, CollectionPresenceCallback);
119 void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
120 void findPreparedRequest(std::map< std::vector< std::string >, CandidateCallback > &request);
121 void lazyCallback(int second);
123 void onGetForPresence(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode,CollectionPresenceCallback callback);
124 void checkCollectionRepresentation(const OCRepresentation& rep, CollectionPresenceCallback callback);
125 void collectionPresenceHandler(OCStackResult result, const unsigned int nonce, const std::string& hostAddress, std::string host, std::string uri);
132 * API for Collection(Group) action.
136 std::string getStringFromActionSet(const ActionSet *newActionSet);
137 ActionSet* getActionSetfromString(std::string desc);
139 OCStackResult addActionSet(std::shared_ptr< OCResource > resource, const ActionSet* newActionSet, PutCallback cb);
140 OCStackResult executeActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, PostCallback cb);
141 OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, GetCallback cb);
142 OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName, PostCallback);
149 #endif /* __OC_GROUPMANAGER__*/