IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OCResourceRequest.h
Go to the documentation of this file.
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH 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 
28 #ifndef OC_RESOURCEREQUEST_H_
29 #define OC_RESOURCEREQUEST_H_
30 
31 #include "OCApi.h"
32 #include "OCRepresentation.h"
33 
36  std::shared_ptr<OC::OCResourceRequest>);
37 
38 
39 namespace OC
40 {
45  {
46  public:
47  typedef std::shared_ptr<OCResourceRequest> Ptr;
48 
50  m_requestType(""),
51  m_resourceUri(""),
52  m_queryParameters(QueryParamsMap()),
53  m_requestHandlerFlag(0),
54  m_messageID(0),
55  m_representation(OCRepresentation()),
56  m_headerOptions(HeaderOptions()),
57  m_requestHandle(nullptr),
58  m_resourceHandle(nullptr)
59  {
60  m_observationInfo.action = ObserveAction::ObserveRegister;
61  m_observationInfo.obsId = 0;
63  m_observationInfo.address = "";
64  m_observationInfo.port = 0;
65  }
66 
67 #if defined(_MSC_VER) && (_MSC_VER < 1900)
69  m_requestType(std::move(o.m_requestType)),
70  m_resourceUri(std::move(o.m_resourceUri)),
71  m_queryParameters(std::move(o.m_queryParameters)),
72  m_requestHandlerFlag(o.m_requestHandlerFlag),
73  m_representation(std::move(o.m_representation)),
74  m_observationInfo(std::move(o.m_observationInfo)),
75  m_headerOptions(std::move(o.m_headerOptions)),
76  m_requestHandle(std::move(o.m_requestHandle)),
77  m_resourceHandle(std::move(o.m_resourceHandle))
78  {
79  }
81  {
82  m_requestType = std::move(o.m_requestType);
83  m_resourceUri = std::move(o.m_resourceUri);
84  m_queryParameters = std::move(o.m_queryParameters);
85  m_requestHandlerFlag = o.m_requestHandlerFlag;
86  m_representation = std::move(o.m_representation);
87  m_observationInfo = std::move(o.m_observationInfo);
88  m_headerOptions = std::move(o.m_headerOptions);
89  m_requestHandle = std::move(o.m_requestHandle);
90  m_resourceHandle = std::move(o.m_resourceHandle);
91  }
92 #else
95 #endif
96 
100  virtual ~OCResourceRequest(void)
101  {
102  }
103 
108  std::string getRequestType() const {return m_requestType;}
109 
114  const QueryParamsMap& getQueryParameters() const {return m_queryParameters;}
115 
128  int getRequestHandlerFlag() const {return m_requestHandlerFlag;}
129 
135  const OCRepresentation& getResourceRepresentation() const {return m_representation;}
136 
140  const ObservationInfo& getObservationInfo() const {return m_observationInfo;}
141 
146  void setResourceUri(const std::string resourceUri)
147  {
148  m_resourceUri = resourceUri;
149  }
150 
155  std::string getResourceUri(void)
156  {
157  return m_resourceUri;
158  }
159 
166  {
167  return m_headerOptions;
168  }
169 
176  {
177  return m_requestHandle;
178  }
179 
186  {
187  return m_resourceHandle;
188  }
189 
195  int16_t getMessageID() const {return m_messageID;}
196 
197  private:
198  std::string m_requestType;
199  std::string m_resourceUri;
200  QueryParamsMap m_queryParameters;
201  int m_requestHandlerFlag;
202  int16_t m_messageID;
203  OCRepresentation m_representation;
204  ObservationInfo m_observationInfo;
205  HeaderOptions m_headerOptions;
206  OCRequestHandle m_requestHandle;
207  OCResourceHandle m_resourceHandle;
208 
209 
210  private:
212  std::shared_ptr<OC::OCResourceRequest>);
213  void setRequestType(const std::string& requestType)
214  {
215  m_requestType = requestType;
216  }
217 
218  void setPayload(OCPayload* requestPayload);
219 
220  void setQueryParams(QueryParamsMap& queryParams)
221  {
222  m_queryParameters = queryParams;
223  }
224 
225  void setRequestHandlerFlag(int requestHandlerFlag)
226  {
227  m_requestHandlerFlag = requestHandlerFlag;
228  }
229 
230  void setMessageID(int16_t messageID)
231  {
232  m_messageID = messageID;
233  }
234 
235  void setObservationInfo(const ObservationInfo& observationInfo)
236  {
237  m_observationInfo = observationInfo;
238  }
239 
240  void setHeaderOptions(const HeaderOptions& headerOptions)
241  {
242  m_headerOptions = headerOptions;
243  }
244 
250  void setRequestHandle(const OCRequestHandle& requestHandle)
251  {
252  m_requestHandle = requestHandle;
253  }
254 
260  void setResourceHandle(const OCResourceHandle& resourceHandle)
261  {
262  m_resourceHandle = resourceHandle;
263  }
264 
265  };
266  }// namespace OC
267 
268 #endif // OC_RESOURCEREQUEST_H_
void formResourceRequest(OCEntityHandlerFlag, OCEntityHandlerRequest *, std::shared_ptr< OC::OCResourceRequest >)
const HeaderOptions & getHeaderOptions() const
This API retrieves headerOptions which was sent from a client.
Definition: OCResourceRequest.h:165
const ObservationInfo & getObservationInfo() const
Definition: OCResourceRequest.h:140
OCResourceRequest provides APIs to extract details from a request URI.
Definition: OCResourceRequest.h:44
friend void() formResourceRequest(OCEntityHandlerFlag, OCEntityHandlerRequest *, std::shared_ptr< OC::OCResourceRequest >)
const OCRequestHandle & getRequestHandle() const
This API retrieves the request handle.
Definition: OCResourceRequest.h:175
std::shared_ptr< OCResourceRequest > Ptr
Definition: OCResourceRequest.h:47
OCConnectivityType connectivityType
Definition: OCApi.h:337
std::vector< HeaderOption::OCHeaderOption > HeaderOptions
Definition: OCApi.h:313
const QueryParamsMap & getQueryParameters() const
Retrieves the query parameters from the request.
Definition: OCResourceRequest.h:114
This file contains the declaration of classes and its members related to OCRepresentation.
void * OCResourceHandle
Handle to an OCResource object owned by the OCStack.
Definition: octypes.h:1152
Definition: OCApi.h:330
void setResourceUri(const std::string resourceUri)
sets resource uri
Definition: OCResourceRequest.h:146
OCEntityHandlerFlag
Entity's state.
Definition: octypes.h:1728
int16_t getMessageID() const
This API retrieves the request message ID.
Definition: OCResourceRequest.h:195
uint16_t port
Definition: OCApi.h:339
const OCRepresentation & getResourceRepresentation() const
Provides the entire resource attribute representation.
Definition: OCResourceRequest.h:135
Incoming requests handled by the server.
Definition: octypes.h:1622
use when defaults are ok.
Definition: octypes.h:832
std::string getRequestType() const
Retrieves the type of request string for the entity handler function to operate.
Definition: OCResourceRequest.h:108
A generic struct representing a payload returned from a resource operation.
Definition: octypes.h:1453
std::map< std::string, std::string > QueryParamsMap
Definition: OCApi.h:316
virtual ~OCResourceRequest(void)
Virtual destructor.
Definition: OCResourceRequest.h:100
std::string getResourceUri(void)
gets resource uri
Definition: OCResourceRequest.h:155
void * OCRequestHandle
Handle to an OCRequest object owned by the OCStack.
Definition: octypes.h:1157
int getRequestHandlerFlag() const
Retrieves the request handler flag type.
Definition: OCResourceRequest.h:128
const OCResourceHandle & getResourceHandle() const
This API retrieves the resource handle.
Definition: OCResourceRequest.h:185
ObserveAction action
Definition: OCApi.h:333
OCResourceRequest & operator=(OCResourceRequest &&)=default
OCObservationId obsId
Definition: OCApi.h:335
OCResourceRequest()
Definition: OCResourceRequest.h:49
Definition: OCRepresentation.h:84
std::string address
Definition: OCApi.h:338