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 static RCSGetResponse defaultRes { std::make_shared< RequestHandler >() };
38 RCSGetResponse RCSGetResponse::create(const OCEntityHandlerResult& result,
41 return RCSGetResponse {
42 std::make_shared< RequestHandler >( result, errorCode) };
45 RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs)
47 return RCSGetResponse { std::make_shared< RequestHandler >(attrs) };
50 RCSGetResponse RCSGetResponse::create(const RCSResourceAttributes& attrs,
51 const OCEntityHandlerResult& result, int errorCode)
53 return RCSGetResponse {
54 std::make_shared< RequestHandler >(attrs, result, errorCode) };
57 RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& result)
59 return RCSGetResponse {
60 std::make_shared< RequestHandler >(std::move(result)) };
63 RCSGetResponse RCSGetResponse::create(RCSResourceAttributes&& attrs,
64 const OCEntityHandlerResult& result, int errorCode)
66 return RCSGetResponse { std::make_shared< RequestHandler >(
67 std::move(attrs), result, errorCode) };
70 RCSGetResponse::RCSGetResponse(std::shared_ptr< RequestHandler >&& handler) :
71 m_handler{ std::move(handler) }
76 RequestHandler* RCSGetResponse::getHandler() const
78 return m_handler.get();
82 RCSSetResponse RCSSetResponse::defaultAction()
84 return std::make_shared< SetRequestHandler >();
87 RCSSetResponse RCSSetResponse::accept()
89 return defaultAction().setAcceptanceMethod(AcceptanceMethod::ACCEPT);
92 RCSSetResponse RCSSetResponse::accept(const OCEntityHandlerResult& result,
95 return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::ACCEPT);
98 RCSSetResponse RCSSetResponse::ignore()
100 return defaultAction().setAcceptanceMethod(AcceptanceMethod::IGNORE);
103 RCSSetResponse RCSSetResponse::ignore(const OCEntityHandlerResult& result,
106 return create(result, errorCode).setAcceptanceMethod(AcceptanceMethod::IGNORE);
109 RCSSetResponse RCSSetResponse::create(const OCEntityHandlerResult& result,
112 return std::make_shared< SetRequestHandler >(result, errorCode);
115 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs)
117 return std::make_shared< SetRequestHandler >(attrs);
120 RCSSetResponse RCSSetResponse::create(const RCSResourceAttributes& attrs,
121 const OCEntityHandlerResult& result, int errorCode)
123 return std::make_shared< SetRequestHandler >(attrs, result, errorCode);
126 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& result)
128 return std::make_shared< SetRequestHandler >(std::move(result));
131 RCSSetResponse RCSSetResponse::create(RCSResourceAttributes&& attrs,
132 const OCEntityHandlerResult& result, int errorCode)
134 return std::make_shared< SetRequestHandler >(std::move(attrs), result, errorCode);
137 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler) :
138 m_acceptanceMethod { AcceptanceMethod::DEFAULT },
139 m_handler{ std::move(handler) }
143 RCSSetResponse::RCSSetResponse(std::shared_ptr< SetRequestHandler >&& handler,
144 AcceptanceMethod method) :
145 m_acceptanceMethod{ method },
146 m_handler{ std::move(handler) }
151 SetRequestHandler* RCSSetResponse::getHandler() const
153 return m_handler.get();
156 auto RCSSetResponse::getAcceptanceMethod() const -> AcceptanceMethod
158 return m_acceptanceMethod;
161 RCSSetResponse& RCSSetResponse::setAcceptanceMethod(AcceptanceMethod method)
163 m_acceptanceMethod = method;