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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25 * This file contains the declaration of classes and its members related to RCSResponse
27 #ifndef SERVERBUILDER_RCSRESPONSE_H
28 #define SERVERBUILDER_RCSRESPONSE_H
36 class RCSResourceAttributes;
39 class SetRequestHandler;
42 * This class provides factory methods to create the response for a received get request.
43 * The response consists of an error code and result attributes.
45 * @see RCSResourceObject
51 * Creates a default RCSGetResponse.
52 * The response will have 200 for the errorCode and the attributes of RCSResourceObject
53 * will be set as the result attributes.
56 static RCSGetResponse defaultAction();
59 * Creates a RCSGetResponse with error code passed.
60 * The attributes of the RCSResourceObject will be set as the result attributes.
62 * @param errorCode The error code to set in response.
63 * @see create(const RCSResourceAttributes&)
64 * @see create(RCSResourceAttributes&&)
65 * @see create(const RCSResourceAttributes&, int)
66 * @see create(RCSResourceAttributes&&, int)
68 static RCSGetResponse create(int errorCode);
71 * Creates a RCSGetResponse with custom attributes.
72 * This sends the passed attributes as the result attributes
73 * instead of the one the RCSResourceObject holds.
76 * @param attrs The attributes to set.
78 * @see RCSResourceAttributes
80 * @see create(RCSResourceAttributes&&)
81 * @see create(const RCSResourceAttributes&, int)
82 * @see create(RCSResourceAttributes&&, int)
85 static RCSGetResponse create(const RCSResourceAttributes& attrs);
89 * @param attrs The attributes to set.
91 * @see RCSResourceAttributes
93 * @see create(const RCSResourceAttributes&)
94 * @see create(const RCSResourceAttributes&, int)
95 * @see create(RCSResourceAttributes&&, int)
97 static RCSGetResponse create(RCSResourceAttributes&& attrs);
100 * Creates a RCSGetResponse with error code passed.
101 * This sends the passed attributes as the result attributes
102 * instead of the one the RCSResourceObject holds.
105 * @param attrs The attributes to set.
106 * @param errorCode The error code for response.
108 * @see RCSResourceAttributes
110 * @see create(const RCSResourceAttributes&)
111 * @see create(RCSResourceAttributes&&)
112 * @see create(const RCSResourceAttributes&, int)
113 * @see create(RCSResourceAttributes&&, int)
115 static RCSGetResponse create(const RCSResourceAttributes& attrs, int errorCode);
119 * @param attrs The attributes to set.
120 * @param errorCode The error code for response.
122 * @see RCSResourceAttributes
124 * @see create(const RCSResourceAttributes&)
125 * @see create(RCSResourceAttributes&&)
126 * @see create(const RCSResourceAttributes&, int)
128 static RCSGetResponse create(RCSResourceAttributes&& attrs, int errorCode);
131 RequestHandler* getHandler() const;
135 RCSGetResponse(std::shared_ptr< RequestHandler >&&);
138 std::shared_ptr< RequestHandler > m_handler;
142 * This class provides factory methods to create the response for a received set request.
143 * The response consists of an error code and result attributes.
145 * AcceptanceMethod provides ways how the request will be handled.
147 * @see RCSResourceObject
153 * Options for handling a set request.
155 * This overrides SetRequestHandlerPolicy.
157 * @see SetRequestHandlerPolicy
160 enum class AcceptanceMethod
163 * Follow SetRequestHandlerPolicy of the RCSResourceObject.
168 * Accept the request attributes even if there is an unknown key or mismatched type.
173 * Ignore the request attributes.
179 * Creates a default RCSSetResponse that has AcceptanceMethod::DEFAULT.
180 * The response will have 200 for the errorCode.
181 * The attributes of RCSResourceObject will be set as the result attributes.
184 static RCSSetResponse defaultAction();
187 * Creates a default RCSSetResponse that has AcceptanceMethod::ACCEPT.
188 * The response will have 200 for the errorCode.
189 * The attributes of RCSResourceObject will be set as the result attributes.
193 static RCSSetResponse accept();
196 * Creates a RCSSetResponse that has AcceptanceMethod::ACCEPT and error code passed.
197 * The attributes of the RCSResourceObject will be set as the result attributes.
200 * @param errorCode The error code to set in response.
204 static RCSSetResponse accept(int errorCode);
207 * Creates a default RCSSetResponse that has AcceptanceMethod::IGNORE.
208 * The response will have 200 for the errorCode.
209 * The attributes of RCSResourceObject will be set as the result attributes.
212 static RCSSetResponse ignore();
215 * Creates a RCSSetResponse that has AcceptanceMethod::IGNORE and error code passed.
216 * The attributes of the RCSResourceObject will be set as the result attributes.
218 * @param errorCode The error code to set in response.
221 static RCSSetResponse ignore(int errorCode);
224 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT and error code passed.
225 * The attributes of the RCSResourceObject will be set as the result attributes.
228 * @param errorCode The error code to set in response.
229 * @see create(const RCSResourceAttributes&)
230 * @see create(RCSResourceAttributes&&)
231 * @see create(const RCSResourceAttributes&, int)
232 * @see create(RCSResourceAttributes&&, int)
234 static RCSSetResponse create(int errorCode);
237 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT with custom attributes.
238 * This sends the passed attributes as the result attributes
239 * instead of the one the RCSResourceObject holds.
242 * @param attrs The attributes to set.
244 * @see RCSResourceAttributes
246 * @see create(RCSResourceAttributes&&)
247 * @see create(const RCSResourceAttributes&, int)
248 * @see create(RCSResourceAttributes&&, int)
250 static RCSSetResponse create(const RCSResourceAttributes& attrs);
254 * @param attrs The attributes to set.
255 * @see RCSResourceAttributes
257 * @see create(const RCSResourceAttributes&)
258 * @see create(const RCSResourceAttributes&, int)
259 * @see create(RCSResourceAttributes&&, int)
261 static RCSSetResponse create(RCSResourceAttributes&& attrs);
264 * Creates a RCSSetResponse with error code passed.
265 * This sends the passed attributes as the result attributes
266 * instead of the one the RCSResourceObject holds.
269 * @param attrs The attributes to set.
270 * @param errorCode The error code for response.
272 * @see RCSResourceAttributes
274 * @see create(const RCSResourceAttributes&)
275 * @see create(RCSResourceAttributes&&)
276 * @see create(RCSResourceAttributes&&, int)
278 static RCSSetResponse create(const RCSResourceAttributes& attrs, int errorCode);
282 * @param attrs The attributes to set.
283 * @param errorCode The error code for response.
284 * @see RCSResourceAttributes
286 * @see create(const RCSResourceAttributes&)
287 * @see create(RCSResourceAttributes&&)
288 * @see create(const RCSResourceAttributes&, int)
290 static RCSSetResponse create(RCSResourceAttributes&& attrs, int errorCode);
294 SetRequestHandler* getHandler() const;
298 * Returns the acceptance method.
301 AcceptanceMethod getAcceptanceMethod() const;
304 * Sets the acceptance method for the RCSSetResponse.
306 * @param method AcceptanceMethod value to set
308 * @return The reference to this RCSSetResponse
310 * @see AcceptanceMethod
313 RCSSetResponse& setAcceptanceMethod(AcceptanceMethod method);
316 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
317 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
320 AcceptanceMethod m_acceptanceMethod;
321 std::shared_ptr< SetRequestHandler > m_handler;
326 #endif // SERVERBUILDER_RCSRESPONSE_H