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.
65 static RCSGetResponse create(int errorCode);
68 * Creates a RCSGetResponse with custom attributes.
69 * This sends the passed attributes as the result attributes
70 * instead of the one the RCSResourceObject holds.
72 * @param attrs The attributes to set.
74 * @see RCSResourceAttributes
77 static RCSGetResponse create(const RCSResourceAttributes& attrs);
82 static RCSGetResponse create(RCSResourceAttributes&& attrs);
85 * Creates a RCSGetResponse with error code passed.
86 * This sends the passed attributes as the result attributes
87 * instead of the one the RCSResourceObject holds.
89 * @param attrs The attributes to set.
90 * @param errorCode The error code for response.
92 * @see RCSResourceAttributes
95 static RCSGetResponse create(const RCSResourceAttributes& attrs, int errorCode);
100 static RCSGetResponse create(RCSResourceAttributes&& attrs, int errorCode);
103 RequestHandler* getHandler() const;
107 RCSGetResponse(std::shared_ptr< RequestHandler >&&);
110 std::shared_ptr< RequestHandler > m_handler;
114 * This class provides factory methods to create the response for a received set request.
115 * The response consists of an error code and result attributes.
117 * AcceptanceMethod provides ways how the request will be handled.
119 * @see RCSResourceObject
125 * Options for handling a set request.
127 * This overrides SetRequestHandlerPolicy.
129 * @see SetRequestHandlerPolicy
132 enum class AcceptanceMethod
135 * Follow SetRequestHandlerPolicy of the RCSResourceObject.
140 * Accept the request attributes even if there is an unknown key or mismatched type.
145 * Ignore the request attributes.
151 * Creates a default RCSSetResponse that has AcceptanceMethod::DEFAULT.
152 * The response will have 200 for the errorCode.
153 * The attributes of RCSResourceObject will be set as the result attributes.
156 static RCSSetResponse defaultAction();
159 * Creates a default RCSSetResponse that has AcceptanceMethod::ACCEPT.
160 * The response will have 200 for the errorCode.
161 * The attributes of RCSResourceObject will be set as the result attributes.
164 static RCSSetResponse accept();
167 * Creates a RCSSetResponse that has AcceptanceMethod::ACCEPT and error code passed.
168 * The attributes of the RCSResourceObject will be set as the result attributes.
170 * @param errorCode The error code to set in response.
173 static RCSSetResponse accept(int errorCode);
176 * Creates a default RCSSetResponse that has AcceptanceMethod::IGNORE.
177 * The response will have 200 for the errorCode.
178 * The attributes of RCSResourceObject will be set as the result attributes.
181 static RCSSetResponse ignore();
184 * Creates a RCSSetResponse that has AcceptanceMethod::IGNORE and error code passed.
185 * The attributes of the RCSResourceObject will be set as the result attributes.
187 * @param errorCode The error code to set in response.
190 static RCSSetResponse ignore(int errorCode);
193 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT and error code passed.
194 * The attributes of the RCSResourceObject will be set as the result attributes.
196 * @param errorCode The error code to set in response.
199 static RCSSetResponse create(int errorCode);
202 * Creates a RCSSetResponse that has AcceptanceMethod::DEFAULT with custom attributes.
203 * This sends the passed attributes as the result attributes
204 * instead of the one the RCSResourceObject holds.
206 * @param attrs The attributes to set.
208 * @see RCSResourceAttributes
211 static RCSSetResponse create(const RCSResourceAttributes& attrs);
216 static RCSSetResponse create(RCSResourceAttributes&& attrs);
219 * Creates a RCSSetResponse with error code passed.
220 * This sends the passed attributes as the result attributes
221 * instead of the one the RCSResourceObject holds.
223 * @param attrs The attributes to set.
224 * @param errorCode The error code for response.
226 * @see RCSResourceAttributes
229 static RCSSetResponse create(const RCSResourceAttributes& attrs, int errorCode);
234 static RCSSetResponse create(RCSResourceAttributes&& attrs, int errorCode);
238 SetRequestHandler* getHandler() const;
242 * Returns the acceptance method.
245 AcceptanceMethod getAcceptanceMethod() const;
248 * Sets the acceptance method for the RCSSetResponse.
250 * @param method AcceptanceMethod value to set
252 * @return The reference to this RCSSetResponse
254 * @see AcceptanceMethod
257 RCSSetResponse& setAcceptanceMethod(AcceptanceMethod method);
260 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&);
261 RCSSetResponse(std::shared_ptr< SetRequestHandler >&&, AcceptanceMethod);
264 AcceptanceMethod m_acceptanceMethod;
265 std::shared_ptr< SetRequestHandler > m_handler;
270 #endif // SERVERBUILDER_RCSRESPONSE_H