Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / serverBuilder / src / RCSRequest.cpp
1 //******************************************************************
2 //
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include "RCSRequest.h"
22
23 #include "OCResourceRequest.h"
24
25 namespace OIC
26 {
27     namespace Service
28     {
29
30         RCSRequest::RCSRequest(const std::shared_ptr< RCSResourceObject >& resourceObject,
31                 const std::shared_ptr< OC::OCResourceRequest >& ocRequest) :
32                 m_resourceObject{ resourceObject },
33                 m_ocRequest{ ocRequest }
34         {
35         }
36
37         RCSRequest::RCSRequest(const std::string& resourceUri) :
38                 m_ocRequest{ std::make_shared< OC::OCResourceRequest >() }
39         {
40             m_ocRequest->setResourceUri(resourceUri);
41         }
42
43
44         std::weak_ptr< RCSResourceObject > RCSRequest::getResourceObject() const noexcept
45         {
46             return m_resourceObject;
47         }
48
49         std::string RCSRequest::getResourceUri() const
50         {
51             return m_ocRequest->getResourceUri();
52         }
53
54         std::shared_ptr< OC::OCResourceRequest > RCSRequest::getOCRequest() const noexcept
55         {
56             return m_ocRequest;
57         }
58
59         const std::map< std::string, std::string >& RCSRequest::getQueryParams() const
60         {
61             return m_ocRequest->getQueryParameters();
62         }
63
64         std::string RCSRequest::getInterface() const
65         {
66             const auto& params = m_ocRequest->getQueryParameters();
67
68             auto it = params.find(OC::Key::INTERFACESKEY);
69
70             if (it == params.end()) return "";
71
72             return it->second;
73         }
74
75     }
76 }