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 "RequestObject.h"
23 #include "RCSResourceObject.h"
24 #include "RCSSeparateResponse.h"
30 void RequestObject::invokeRequest(RCSRemoteResourceObject::Ptr remoteObject,
31 const RCSRequest & request, RequestMethod method,
32 const RCSResourceAttributes & resourceAttibutes, SetRequestCallback setCB)
34 RequestObject::Ptr createdRequestObject = std::make_shared<RequestObject>();
36 RCSRequest req(request.getResourceObject().lock(), request.getOCRequest());
39 case RequestMethod::Set:
43 remoteObject->setRemoteAttributes(resourceAttibutes,
44 std::bind(&RequestObject::setRequestCB, createdRequestObject,
45 std::placeholders::_1, std::placeholders::_2,
46 req, createdRequestObject));
50 remoteObject->setRemoteAttributes(resourceAttibutes,
51 std::bind(std::move(setCB),
52 std::placeholders::_1, std::placeholders::_2,
53 req, createdRequestObject));
57 case RequestMethod::Get:
58 case RequestMethod::Delete:
61 // unknown type of method.
67 void RequestObject::setRequestCB(
68 const RCSResourceAttributes & returnedAttributes, int /*eCode*/,
69 const RCSRequest & request, RequestObject::Ptr /*this_ptr*/)
71 auto server = request.getResourceObject().lock();
77 RCSResourceObject::LockGuard guard(server);
78 server->getAttributes() = RCSResourceAttributes(returnedAttributes);
80 // TODO need to set error code.
81 RCSSeparateResponse(request).set();
84 } /* namespace Service */