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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include <RCSResponse.h>
23 #include <RequestHandler.h>
31 RCSGetResponse RCSGetResponse::defaultAction()
33 return std::make_shared< RequestHandler >();
36 RCSGetResponse RCSGetResponse::create(int errorCode)
38 return RCSGetResponse {
39 std::make_shared< RequestHandler >( errorCode) };
42 RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs)
44 return RCSGetResponse { std::make_shared< RequestHandler >(attrs) };
47 RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs, int errorCode)
49 return RCSGetResponse { std::make_shared< RequestHandler >(attrs, errorCode) };
52 RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& result)
54 return RCSGetResponse {
55 std::make_shared< RequestHandler >(std::move(result)) };
58 RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& attrs, int errorCode)
60 return RCSGetResponse { std::make_shared< RequestHandler >(
61 std::move(attrs), errorCode) };
64 RCSGetResponse RCSGetResponse::separate()
66 return RCSGetResponse();
69 bool RCSGetResponse::isSeparate() const
74 RCSGetResponse::RCSGetResponse()
78 RCSGetResponse::RCSGetResponse(std::shared_ptr< RequestHandler >&& handler) :
79 m_handler{ std::move(handler) }
84 RequestHandler* RCSGetResponse::getHandler() const
86 return m_handler.get();
90 RCSSetResponse RCSSetResponse::defaultAction()
92 return std::make_shared< SetRequestHandler >();
95 RCSSetResponse RCSSetResponse::accept()
97 return defaultAction().setAcceptanceMethod(AcceptanceMethod::ACCEPT);
100 RCSSetResponse RCSSetResponse::accept(int errorCode)
102 return create(errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
105 RCSSetResponse RCSSetResponse::ignore()
107 return defaultAction().setAcceptanceMethod(AcceptanceMethod::IGNORE);
110 RCSSetResponse RCSSetResponse::ignore(int errorCode)
112 return create(errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
115 RCSSetResponse RCSSetResponse::create(int errorCode)
117 return std::make_shared< SetRequestHandler >(errorCode);
120 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs)
122 return std::make_shared< SetRequestHandler >(attrs);
125 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs, int errorCode)
127 return std::make_shared< SetRequestHandler >(attrs, errorCode);
130 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& result)
132 return std::make_shared< SetRequestHandler >(std::move(result));
135 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& attrs, int errorCode)
137 return std::make_shared< SetRequestHandler >(std::move(attrs), errorCode);
140 RCSSetResponse RCSSetResponse::separate()
142 return RCSSetResponse();
145 RCSSetResponse::RCSSetResponse() :
146 m_acceptanceMethod { AcceptanceMethod::DEFAULT }
150 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
151 m_acceptanceMethod { AcceptanceMethod::DEFAULT },
152 m_handler{ std::move(handler) }
156 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler,
157 AcceptanceMethod method) :
158 m_acceptanceMethod{ method },
159 m_handler{ std::move(handler) }
164 bool RCSSetResponse::isSeparate() const
170 SetRequestHandler* RCSSetResponse::getHandler() const
172 return m_handler.get();
175 auto RCSSetResponse::getAcceptanceMethod() const -> AcceptanceMethod
177 return m_acceptanceMethod;
180 RCSSetResponse& RCSSetResponse::setAcceptanceMethod(AcceptanceMethod method)
182 m_acceptanceMethod = method;