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);
130 static RCSGetResponse separate();
132 bool isSeparate() const;
135 RequestHandler* getHandler() const;
140 RCSGetResponse(std::shared_ptr< RequestHandler >&&);
143 std::shared_ptr< RequestHandler > m_handler;
147 * This class provides factory methods to create the response for a received set request.
148 * The response consists of an error code and result attributes.
150 * AcceptanceMethod provides ways how the request will be handled.
152 * @see RCSResourceObject
158 * Options for handling a set request.
160 * This overrides SetRequestHandlerPolicy.
162 * @see SetRequestHandlerPolicy
165 enum class AcceptanceMethod
168 * Follow SetRequestHandlerPolicy of the RCSResourceObject.
173 * Accept the request attributes even if there is an unknown key or mismatched type.
178 * Ignore the request attributes.
184 * Creates a default RCSSetResponse that has AcceptanceMethod::DEFAULT.
185 * The response will have 200 for the errorCode.
186 * The attributes of RCSResourceObject will be set as the result attributes.
189 static RCSSetResponse defaultAction();
192 * Creates a default RCSSetResponse that has AcceptanceMethod::ACCEPT.
193 * The response will have 200 for the errorCode.
194 * The attributes of RCSResourceObject will be set as the result attributes.
198 static RCSSetResponse accept();
201 * Creates a RCSSetResponse that has AcceptanceMethod::ACCEPT and error code passed.
202 * The attributes of the RCSResourceObject will be set as the result attributes.
205 * @param errorCode The error code to set in response.
209 static RCSSetResponse accept(int errorCode);
212 * Creates a default RCSSetResponse that has AcceptanceMethod::IGNORE.
213 * The response will have 200 for the errorCode.
214 * The attributes of RCSResourceObject will be set as the result attributes.
217 static RCSSetResponse ignore();
220 * Creates a RCSSetResponse that has AcceptanceMethod::IGNORE and error code passed.
221 * The attributes of the RCSResourceObject will be set as the result attributes.
223 * @param errorCode The error code to set in response.
226 static RCSSetResponse ignore(int errorCode);
229 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT and error code passed.
230 * The attributes of the RCSResourceObject will be set as the result attributes.
233 * @param errorCode The error code to set in response.
234 * @see create(const RCSResourceAttributes&)
235 * @see create(RCSResourceAttributes&&)
236 * @see create(const RCSResourceAttributes&, int)
237 * @see create(RCSResourceAttributes&&, int)
239 static RCSSetResponse create(int errorCode);
242 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT with custom attributes.
243 * This sends the passed attributes as the result attributes
244 * instead of the one the RCSResourceObject holds.
247 * @param attrs The attributes to set.
249 * @see RCSResourceAttributes
251 * @see create(RCSResourceAttributes&&)
252 * @see create(const RCSResourceAttributes&, int)
253 * @see create(RCSResourceAttributes&&, int)
255 static RCSSetResponse create(const RCSResourceAttributes& attrs);
259 * @param attrs The attributes to set.
260 * @see RCSResourceAttributes
262 * @see create(const RCSResourceAttributes&)
263 * @see create(const RCSResourceAttributes&, int)
264 * @see create(RCSResourceAttributes&&, int)
266 static RCSSetResponse create(RCSResourceAttributes&& attrs);
269 * Creates a RCSSetResponse with error code passed.
270 * This sends the passed attributes as the result attributes
271 * instead of the one the RCSResourceObject holds.
274 * @param attrs The attributes to set.
275 * @param errorCode The error code for response.
277 * @see RCSResourceAttributes
279 * @see create(const RCSResourceAttributes&)
280 * @see create(RCSResourceAttributes&&)
281 * @see create(RCSResourceAttributes&&, int)
283 static RCSSetResponse create(const RCSResourceAttributes& attrs, int errorCode);
287 * @param attrs The attributes to set.
288 * @param errorCode The error code for response.
289 * @see RCSResourceAttributes
291 * @see create(const RCSResourceAttributes&)
292 * @see create(RCSResourceAttributes&&)
293 * @see create(const RCSResourceAttributes&, int)
295 static RCSSetResponse create(RCSResourceAttributes&& attrs, int errorCode);
297 static RCSSetResponse separate();
299 bool isSeparate() const;
302 SetRequestHandler* getHandler() const;
306 * Returns the acceptance method.
309 AcceptanceMethod getAcceptanceMethod() const;
312 * Sets the acceptance method for the RCSSetResponse.
314 * @param method AcceptanceMethod value to set
316 * @return The reference to this RCSSetResponse
318 * @see AcceptanceMethod
321 RCSSetResponse& setAcceptanceMethod(AcceptanceMethod method);
325 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
326 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
329 AcceptanceMethod m_acceptanceMethod;
330 std::shared_ptr< SetRequestHandler > m_handler;
335 #endif // SERVERBUILDER_RCSRESPONSE_H