Removed execute permissions from non-executable files.
[platform/upstream/iotivity.git] / service / things-manager / sdk / src / 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 /// @file   GroupManager.h
22
23 /// @brief  This file contains the declaration of classes and its members related to TGMClient.
24
25 #ifndef __OC_GROUPMANAGER__
26 #define __OC_GROUPMANAGER__
27
28 #include <string>
29 #include <vector>
30 #include <map>
31 #include <cstdlib>
32 #include "OCPlatform.h"
33 #include "OCApi.h"
34
35 using namespace OC;
36
37 typedef std::function< void(std::vector< std::shared_ptr< OCResource > >) > CandidateCallback;
38 typedef std::function< void(std::string, OCStackResult) > CollectionPresenceCallback;
39
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;
43
44
45 class Capability
46 {
47 public:
48     std::string capability;
49     std::string status;
50 };
51
52 class Action
53 {
54 public:
55     Action() : target("")
56     {
57     }
58     ~Action()
59     {
60         listOfCapability.clear();
61     }
62     std::string target;
63
64     std::vector<Capability*> listOfCapability;
65 };
66
67 class ActionSet
68 {
69 public:
70     ActionSet() : actionsetName("")
71     {
72     }
73     ~ActionSet()
74     {
75         listOfAction.clear();
76     }
77     std::string actionsetName;
78
79     std::vector<Action*> listOfAction;
80 };
81
82
83 class GroupManager
84 {
85 public:
86     /**
87      * Constructor for TGMClient. Constructs a new TGMClient
88      */
89     GroupManager(void);
90
91     /**
92      * Virtual destructor
93      */
94     ~GroupManager(void);
95
96     /**
97      * API for candidate resources discovery.
98      * Callback only call when all resource types found.
99      *
100      * @param resourceTypes - required resource types(called "candidate")
101      * @param candidateCallback - callback. OCResource vector.
102      *
103      * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.
104      *
105      * NOTE: OCStackResult is defined in ocstack.h.
106      */
107     OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
108             CandidateCallback callback, int waitsec = -1);
109
110     /**
111      * API for Collection member's state subscribe.
112      *
113      * NOTE: NOT IMPLEMENT YET
114      */
115     OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource, CollectionPresenceCallback);
116
117 private:
118
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);
122
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);
126
127
128
129
130
131     /**
132     *   API for Collection(Group) action.
133     */
134
135 public:
136     std::string getStringFromActionSet(const ActionSet *newActionSet);
137     ActionSet* getActionSetfromString(std::string desc);
138
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);
143 };
144
145
146
147
148
149 #endif  /* __OC_GROUPMANAGER__*/