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 ResourceAttributes;
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 -ResourceAttributes to set
76 * @return RCSGetResponse - instance of RCSGetResponse
78 * @see ResourceAttributes
80 * NOTE : ResourceAttributes is defined in ResourceAttributes.h
82 static RCSGetResponse create(const ResourceAttributes &attrs);
84 * Create RCSGetResponse using ResourceAttributes, OCEntityHandlerResult and error code.
86 * @param attrs - ResourceAttributes to set
88 * @param result - OCEntityHandlerResult
90 * @param errorCode - error code for response
92 * @return RCSGetResponse - instance of RCSGetResponse
94 * @see ResourceAttributes
96 *NOTE : OCEntityHandlerResult is defined in octypes.h.
97 * ResourceAttributes is defined in ResourceAttributes.h.
99 static RCSGetResponse create(const ResourceAttributes &attrs,
100 const OCEntityHandlerResult &result, int errorCode);
103 * Create RCSGetResponse using ResourceAttributes value.
105 * @param attrs - ResourceAttributes to set
107 * @return RCSGetResponse - instance of RCSGetResponse
109 * @see ResourceAttributes
111 *NOTE : ResourceAttributes is defined in ResourceAttributes.h.
113 static RCSGetResponse create(ResourceAttributes &&attrs);
115 * Create RCSGetResponse using ResourceAttributes value.
117 * @param attrs - ResourceAttributes to set
119 * @param result - OCEntityHandlerResult
121 * @param errorCode - error code for response
123 * @return RCSGetResponse - instance of RCSGetResponse
125 * @see ResourceAttributes
127 *NOTE : OCEntityHandlerResult is defined in octypes.h.
128 * ResourceAttributes is defined in ResourceAttributes.h.
130 static RCSGetResponse create(ResourceAttributes &&attrs, const OCEntityHandlerResult &result,
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
167 * Create default RCSSetResponse with default response.
169 * @return RCSSetResponse - instance of RCSSetResponse
171 static RCSSetResponse defaultAction();
174 * Internally it invokes the defaultAction() API.
175 * It sets the AcceptanceMethod as ACCEPT.
177 * @return RCSSetResponse - instance of RCSSetResponse
179 * @see AcceptanceMethod
181 static RCSSetResponse accept();
183 * Internally it invokes the create(const OCEntityHandlerResult&, int errorCode) API.
184 * It sets the AcceptanceMethod as ACCEPT.
186 * @param result - OCEntityHandlerResult value.
188 * @param errorCode - error code for the response
190 * @return RCSSetResponse - instance of RCSSetResponse
192 * @see AcceptanceMethod
194 *NOTE : OCEntityHandlerResult is defined in octypes.h
196 static RCSSetResponse accept(const OCEntityHandlerResult &result, int errorCode);
199 * Internally it invokes the defaultAction() API.
200 * It sets the AcceptanceMethod as IGNORE.
202 * @return RCSSetResponse - instance of RCSSetResponse.
204 * @see AcceptanceMethod
206 static RCSSetResponse ignore();
208 * Internaly it invokes the create(const OCEntityHandlerResult&, int errorCode) API.
209 * It sets the AcceptanceMethod as IGNORE.
211 * @param result - OCEntityHandlerResult value.
213 * @param errorCode - error code for the response.
215 * @return RCSSetResponse - instance of RCSSetResponse.
217 * @see AcceptanceMethod
219 *NOTE : OCEntityHandlerResult is defined in octypes.h
221 static RCSSetResponse ignore(const OCEntityHandlerResult &result, int errorCode);
224 * Create RCSSetResponse with OCEntityHandlerResult and errorCode.
226 * @param result - OCEntityHandlerResult value
228 * @param errorCode - error code for the response
230 * @return RCSSetResponse - instance of RCSSetResponse
232 *NOTE : OCEntityHandlerResult is defined in octypes.h
234 static RCSSetResponse create(const OCEntityHandlerResult &result, int errorCode);
237 * Create RCSSetResponse with ResourceAttributes.
239 * @param attrs - ResourceAttributes to set
241 * @return RCSSetResponse - instance of RCSSetResponse
243 * @see ResourceAttributes
245 static RCSSetResponse create(const ResourceAttributes &attrs);
247 * Create RCSSetResponse with ResourceAttributes, OCEntityHandlerResult and errorCode.
249 * @param attrs - ResourceAttributes to set.
251 * @param result - OCEntityHandlerResult value
253 * @param errorCode - error code for the response
255 * @return RCSSetResponse - instance of RCSSetResponse
257 * @see ResourceAttributes
259 *NOTE : OCEntityHandlerResult is defined in octypes.h.
261 static RCSSetResponse create(const ResourceAttributes &attrs,
262 const OCEntityHandlerResult &result, int errorCode);
265 * Create RCSSetResponse with ResourceAttributes.
267 * @param attrs - ResourceAttributes value to set
269 * @return RCSSetResponse - instance of RCSSetResponse
271 * @see ResourceAttributes
273 static RCSSetResponse create(ResourceAttributes &&attrs);
275 * Create RCSSetResponse with ResourceAttributes, OCEntityHandlerResult and errorCode.
277 * @param attrs - ResourceAttributes value to set
279 * @param result - OCEntityHandlerResult value
281 * @param errorCode - error code for the response
283 * @return RCSSetResponse - instance of RCSSetResponse
285 * @see ResourceAttributes
287 *NOTE : OCEntityHandlerResult is defined in octypes.h.
289 static RCSSetResponse create(ResourceAttributes &&attrs, const OCEntityHandlerResult &result,
293 * API to get the set request handler.
295 * @return SetRequestHandler - pointer to SetRequestHandler.
298 SetRequestHandler* getHandler() const;
301 * API to get the acceptance method of the RCSSetResponse.
303 * @return AcceptanceMethod - acceptance methods enum value.
305 * @see AcceptanceMethod
308 AcceptanceMethod getAcceptanceMethod() const;
311 * API to get the acceptance method of the RCSSetResponse.
313 * @param method - AcceptanceMethod value to set
315 * @return RCSSetResponse - reference to RCSSetResponse
317 * @see AcceptanceMethod
320 RCSSetResponse &setAcceptanceMethod(AcceptanceMethod method);
323 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
324 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
327 AcceptanceMethod m_acceptanceMethod;
328 std::shared_ptr< SetRequestHandler > m_handler;
333 #endif // SERVERBUILDER_RCSRESPONSE_H