1 //******************************************************************
3 // Copyright 2015 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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the classes for creating Get & Set response for the Get & Set request.
26 #ifndef SERVERBUILDER_RCSRESPONSE_H
27 #define SERVERBUILDER_RCSRESPONSE_H
38 //forward declaration of classes
39 class RCSResourceAttributes;
42 class SetRequestHandler;
45 * @class RCSGetResponse
46 * @brief This class provides APIs to create the response for the recieved Get request.
52 * Create RCSGetResponse with default response.
54 * @return RCSGetResponse - instance of RCSGetResponse
56 static RCSGetResponse defaultAction();
59 * Create RCSGetResponse using OCEntityHandlerResult value and error code provided.
61 * @param result -OCEntityHandlerResult
63 * @param errorCode - error code to set in response
65 * @return RCSGetResponse - instance of RCSGetResponse
67 * NOTE : OCEntityHandlerResult is defined in octypes.h
69 static RCSGetResponse create(const OCEntityHandlerResult &result, int errorCode);
72 * Create RCSGetResponse using resource attributes.
74 * @param attrs -RCSResourceAttributes to set
76 * @return RCSGetResponse - instance of RCSGetResponse
78 * @see RCSResourceAttributes
80 * NOTE : RCSResourceAttributes is defined in RCSResourceAttributes.h
82 static RCSGetResponse create(const RCSResourceAttributes &attrs);
84 * Create RCSGetResponse using RCSResourceAttributes, OCEntityHandlerResult and error code.
86 * @param attrs - RCSResourceAttributes to set
88 * @param result - OCEntityHandlerResult
90 * @param errorCode - error code for response
92 * @return RCSGetResponse - instance of RCSGetResponse
94 * @see RCSResourceAttributes
96 *NOTE : OCEntityHandlerResult is defined in octypes.h.
97 * RCSResourceAttributes is defined in RCSResourceAttributes.h.
99 static RCSGetResponse create(const RCSResourceAttributes &attrs,
100 const OCEntityHandlerResult &result, int errorCode);
103 * Create RCSGetResponse using RCSResourceAttributes value.
105 * @param attrs - RCSResourceAttributes to set
107 * @return RCSGetResponse - instance of RCSGetResponse
109 * @see RCSResourceAttributes
111 *NOTE : RCSResourceAttributes is defined in RCSResourceAttributes.h.
113 static RCSGetResponse create(RCSResourceAttributes &&attrs);
115 * Create RCSGetResponse using RCSResourceAttributes value.
117 * @param attrs - RCSResourceAttributes to set
119 * @param result - OCEntityHandlerResult
121 * @param errorCode - error code for response
123 * @return RCSGetResponse - instance of RCSGetResponse
125 * @see RCSResourceAttributes
127 *NOTE : OCEntityHandlerResult is defined in octypes.h.
128 * RCSResourceAttributes is defined in RCSResourceAttributes.h.
130 static RCSGetResponse create(RCSResourceAttributes &&attrs,
131 const OCEntityHandlerResult &result, int errorCode);
134 * Get the request handler.
136 * @return RequestHandler - RequestHandler pointer.
139 RequestHandler* getHandler() const;
142 RCSGetResponse(std::shared_ptr< RequestHandler >&&);
145 std::shared_ptr< RequestHandler > m_handler;
149 * @class RCSSetResponse
150 * @brief This class provides API to create a response for received Set request.
156 * AcceptanceMethod enum provides values for different acceptance method policy to be
157 * used in setting response.
159 enum class AcceptanceMethod
161 DEFAULT, ACCEPT, IGNORE
165 * Create default RCSSetResponse with default response.
167 * @return RCSSetResponse - instance of RCSSetResponse
169 static RCSSetResponse defaultAction();
172 * Internally it invokes the defaultAction() API.
173 * It sets the AcceptanceMethod as ACCEPT.
175 * @return RCSSetResponse - instance of RCSSetResponse
177 * @see AcceptanceMethod
179 static RCSSetResponse accept();
181 * Internally it invokes the create(const OCEntityHandlerResult&, int errorCode) API.
182 * It sets the AcceptanceMethod as ACCEPT.
184 * @param result - OCEntityHandlerResult value.
186 * @param errorCode - error code for the response
188 * @return RCSSetResponse - instance of RCSSetResponse
190 * @see AcceptanceMethod
192 *NOTE : OCEntityHandlerResult is defined in octypes.h
194 static RCSSetResponse accept(const OCEntityHandlerResult &result, int errorCode);
197 * Internally it invokes the defaultAction() API.
198 * It sets the AcceptanceMethod as IGNORE.
200 * @return RCSSetResponse - instance of RCSSetResponse.
202 * @see AcceptanceMethod
204 static RCSSetResponse ignore();
206 * Internaly it invokes the create(const OCEntityHandlerResult&, int errorCode) API.
207 * It sets the AcceptanceMethod as IGNORE.
209 * @param result - OCEntityHandlerResult value.
211 * @param errorCode - error code for the response.
213 * @return RCSSetResponse - instance of RCSSetResponse.
215 * @see AcceptanceMethod
217 *NOTE : OCEntityHandlerResult is defined in octypes.h
219 static RCSSetResponse ignore(const OCEntityHandlerResult &result, int errorCode);
222 * Create RCSSetResponse with OCEntityHandlerResult and errorCode.
224 * @param result - OCEntityHandlerResult value
226 * @param errorCode - error code for the response
228 * @return RCSSetResponse - instance of RCSSetResponse
230 *NOTE : OCEntityHandlerResult is defined in octypes.h
232 static RCSSetResponse create(const OCEntityHandlerResult &result, int errorCode);
235 * Create RCSSetResponse with RCSResourceAttributes.
237 * @param attrs - RCSResourceAttributes to set
239 * @return RCSSetResponse - instance of RCSSetResponse
241 * @see RCSResourceAttributes
243 static RCSSetResponse create(const RCSResourceAttributes &attrs);
245 * Create RCSSetResponse with RCSResourceAttributes, OCEntityHandlerResult and errorCode.
247 * @param attrs - RCSResourceAttributes to set.
249 * @param result - OCEntityHandlerResult value
251 * @param errorCode - error code for the response
253 * @return RCSSetResponse - instance of RCSSetResponse
255 * @see RCSResourceAttributes
257 *NOTE : OCEntityHandlerResult is defined in octypes.h.
259 static RCSSetResponse create(const RCSResourceAttributes &attrs,
260 const OCEntityHandlerResult &result, int errorCode);
263 * Create RCSSetResponse with RCSResourceAttributes.
265 * @param attrs - RCSResourceAttributes value to set
267 * @return RCSSetResponse - instance of RCSSetResponse
269 * @see RCSResourceAttributes
271 static RCSSetResponse create(RCSResourceAttributes &&attrs);
273 * Create RCSSetResponse with RCSResourceAttributes, OCEntityHandlerResult and errorCode.
275 * @param attrs - RCSResourceAttributes value to set
277 * @param result - OCEntityHandlerResult value
279 * @param errorCode - error code for the response
281 * @return RCSSetResponse - instance of RCSSetResponse
283 * @see RCSResourceAttributes
285 *NOTE : OCEntityHandlerResult is defined in octypes.h.
287 static RCSSetResponse create(RCSResourceAttributes &&attrs,
288 const OCEntityHandlerResult &result, int errorCode);
291 * API to get the set request handler.
293 * @return SetRequestHandler - pointer to SetRequestHandler.
296 SetRequestHandler* getHandler() const;
299 * API to get the acceptance method of the RCSSetResponse.
301 * @return AcceptanceMethod - acceptance methods enum value.
303 * @see AcceptanceMethod
306 AcceptanceMethod getAcceptanceMethod() const;
309 * API to get the acceptance method of the RCSSetResponse.
311 * @param method - AcceptanceMethod value to set
313 * @return RCSSetResponse - reference to RCSSetResponse
315 * @see AcceptanceMethod
318 RCSSetResponse &setAcceptanceMethod(AcceptanceMethod method);
321 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
322 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
325 AcceptanceMethod m_acceptanceMethod;
326 std::shared_ptr< SetRequestHandler > m_handler;
331 #endif // SERVERBUILDER_RCSRESPONSE_H