Updated Doxygen @param for OCResourceResponse::setResourceRepresentation
[platform/upstream/iotivity.git] / resource / include / OCResourceRequest.h
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
21 /// @file OCResourceRequest.h
22
23 /// @brief  This file contains the declaration of classes and its members related to
24 ///         ResourceRequest.
25
26 #ifndef __OCRESOURCEREQUEST_H
27 #define __OCRESOURCEREQUEST_H
28
29 #include "OCApi.h"
30 #include "OCRepresentation.h"
31
32 void formResourceRequest(OCEntityHandlerFlag,
33                          OCEntityHandlerRequest*,
34                          std::shared_ptr<OC::OCResourceRequest>);
35
36
37 namespace OC
38 {
39     /**
40     *   @brief  OCResourceRequest provides APIs to extract details from a request URI
41     */
42     class OCResourceRequest
43     {
44     public:
45         typedef std::shared_ptr<OCResourceRequest> Ptr;
46
47         OCResourceRequest():
48             m_requestType{},
49             m_resourceUri{},
50             m_queryParameters{},
51             m_requestHandlerFlag{},
52             m_representation{},
53             m_observationInfo{},
54             m_headerOptions{},
55             m_requestHandle{nullptr},
56             m_resourceHandle{nullptr}
57         {
58         }
59
60         OCResourceRequest(OCResourceRequest&&) = default;
61         OCResourceRequest& operator=(OCResourceRequest&&) = default;
62         /**
63         *  Virtual destructor
64         */
65         virtual ~OCResourceRequest(void)
66         {
67         }
68
69         /**
70         *  Retrieves the type of request string for the entity handler function to operate
71         *  @return std::string request type. This could be 'GET'/'PUT'/'POST'/'DELETE'
72         */
73         std::string getRequestType() const {return m_requestType;}
74
75         /**
76         *  Retrieves the query parameters from the request
77         *  @return std::string query parameters in the request
78         */
79         const QueryParamsMap& getQueryParameters() const {return m_queryParameters;}
80
81         /**
82         *  Retrieves the request handler flag type. This can be either INIT flag or
83         *  REQUEST flag or OBSERVE flag.
84         *  NOTE:
85         *  INIT indicates that the vendor's entity handler should go and perform
86         *  initialization operations
87         *  REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE)
88         *  and entity handler needs to perform corresponding operations
89         *  OBSERVE indicates that the request is of type Observe and entity handler
90         *  needs to perform corresponding operations
91         *  @return int type of request flag
92         */
93         int getRequestHandlerFlag() const {return m_requestHandlerFlag;}
94
95         /**
96         *  Provides the entire resource attribute representation
97         *  @return OCRepresentation reference containing the name value pairs
98         *   representing the resource's attributes
99         */
100         const OCRepresentation& getResourceRepresentation() const {return m_representation;}
101
102         /**
103         *  @return ObservationInfo reference provides observation information
104         */
105         const ObservationInfo& getObservationInfo() const {return m_observationInfo;}
106
107         /**
108         *  sets resource uri
109         *  @param resourceUri specifies the resource uri
110         */
111         void setResourceUri(const std::string resourceUri)
112         {
113             m_resourceUri = resourceUri;
114         }
115
116         /**
117         *  gets resource uri
118         *  @return std::string resource uri
119         */
120         std::string getResourceUri(void)
121         {
122             return m_resourceUri;
123         }
124
125         /**
126         * This API retrieves headerOptions which was sent from a client
127         *
128         * @return std::map HeaderOptions with the header options
129         */
130         const HeaderOptions& getHeaderOptions() const
131         {
132             return m_headerOptions;
133         }
134
135         /**
136         * This API retrieves the request handle
137         *
138         * @return OCRequestHandle
139         */
140         const OCRequestHandle& getRequestHandle() const
141         {
142             return m_requestHandle;
143         }
144
145         /**
146         * This API retrieves the resource handle
147         *
148         * return OCResourceHandle
149         */
150         const OCResourceHandle& getResourceHandle() const
151         {
152             return m_resourceHandle;
153         }
154
155     private:
156         std::string m_requestType;
157         std::string m_resourceUri;
158         QueryParamsMap m_queryParameters;
159         int m_requestHandlerFlag;
160         OCRepresentation m_representation;
161         ObservationInfo m_observationInfo;
162         HeaderOptions m_headerOptions;
163         OCRequestHandle m_requestHandle;
164         OCResourceHandle m_resourceHandle;
165
166
167     private:
168         friend void (::formResourceRequest)(OCEntityHandlerFlag, OCEntityHandlerRequest*,
169             std::shared_ptr<OC::OCResourceRequest>);
170         void setRequestType(const std::string& requestType)
171         {
172             m_requestType = requestType;
173         }
174
175         void setPayload(const std::string& requestPayload);
176
177         void setQueryParams(QueryParamsMap& queryParams)
178         {
179             m_queryParameters = queryParams;
180         }
181
182         void setRequestHandlerFlag(int requestHandlerFlag)
183         {
184             m_requestHandlerFlag = requestHandlerFlag;
185         }
186
187         void setObservationInfo(const ObservationInfo& observationInfo)
188         {
189             m_observationInfo = observationInfo;
190         }
191
192         void setHeaderOptions(const HeaderOptions& headerOptions)
193         {
194             m_headerOptions = headerOptions;
195         }
196
197         /**
198         * This API allows to set request handle
199         * @param requestHandle - OCRequestHandle type used to set the
200         * request handle
201         */
202         void setRequestHandle(const OCRequestHandle& requestHandle)
203         {
204             m_requestHandle = requestHandle;
205         }
206
207         /**
208         * This API allows to set the resource handle
209         * @param resourceHandle - OCResourceHandle type used to set the
210         * resource handle
211         */
212         void setResourceHandle(const OCResourceHandle& resourceHandle)
213         {
214             m_resourceHandle = resourceHandle;
215         }
216
217     };
218  }// namespace OC
219
220 #endif //__OCRESOURCEREQUEST_H