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(std::shared_ptr< RequestHandler >&& handler) :
65 m_handler{ std::move(handler) }
70 RequestHandler* RCSGetResponse::getHandler() const
72 return m_handler.get();
76 RCSSetResponse RCSSetResponse::defaultAction()
78 return std::make_shared< SetRequestHandler >();
81 RCSSetResponse RCSSetResponse::accept()
83 return defaultAction().setAcceptanceMethod(AcceptanceMethod::ACCEPT);
86 RCSSetResponse RCSSetResponse::accept(int errorCode)
88 return create(errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
91 RCSSetResponse RCSSetResponse::ignore()
93 return defaultAction().setAcceptanceMethod(AcceptanceMethod::IGNORE);
96 RCSSetResponse RCSSetResponse::ignore(int errorCode)
98 return create(errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
101 RCSSetResponse RCSSetResponse::create(int errorCode)
103 return std::make_shared< SetRequestHandler >(errorCode);
106 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs)
108 return std::make_shared< SetRequestHandler >(attrs);
111 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs, int errorCode)
113 return std::make_shared< SetRequestHandler >(attrs, errorCode);
116 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& result)
118 return std::make_shared< SetRequestHandler >(std::move(result));
121 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& attrs, int errorCode)
123 return std::make_shared< SetRequestHandler >(std::move(attrs), errorCode);
126 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
127 m_acceptanceMethod { AcceptanceMethod::DEFAULT },
128 m_handler{ std::move(handler) }
132 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler,
133 AcceptanceMethod method) :
134 m_acceptanceMethod{ method },
135 m_handler{ std::move(handler) }
140 SetRequestHandler* RCSSetResponse::getHandler() const
142 return m_handler.get();
145 auto RCSSetResponse::getAcceptanceMethod() const -> AcceptanceMethod
147 return m_acceptanceMethod;
150 RCSSetResponse& RCSSetResponse::setAcceptanceMethod(AcceptanceMethod method)
152 m_acceptanceMethod = method;