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 "RCSRepresentation.h"
23 #include "ResourceAttributesConverter.h"
25 #include "OCRepresentation.h"
32 RCSRepresentation::RCSRepresentation() { }
34 RCSRepresentation::RCSRepresentation(const std::string& uri) :
39 RCSRepresentation::RCSRepresentation(const RCSResourceAttributes& attrs) :
47 RCSRepresentation::RCSRepresentation(const std::string& uri,
48 const std::vector< std::string >& interfaces,
49 const std::vector< std::string >& resourceTypes) :
51 m_interfaces{ interfaces },
52 m_resourceTypes{ resourceTypes }
56 RCSRepresentation::RCSRepresentation(const std::string& uri,
57 const std::vector< std::string >& interfaces,
58 const std::vector< std::string >& resourceTypes,
59 const RCSResourceAttributes& attrs) :
61 m_interfaces{ interfaces },
62 m_resourceTypes{ resourceTypes },
67 std::string RCSRepresentation::getUri() const
72 void RCSRepresentation::setUri(std::string uri)
74 m_uri = std::move(uri);
77 const std::vector< std::string >& RCSRepresentation::getInterfaces() const
82 void RCSRepresentation::addInterface(std::string interface)
84 m_interfaces.push_back(std::move(interface));
87 void RCSRepresentation::clearInterfaces()
92 const std::vector< std::string >& RCSRepresentation::getResourceTypes() const
94 return m_resourceTypes;
97 void RCSRepresentation::addResourceType(std::string resourceType)
99 m_resourceTypes.push_back(std::move(resourceType));
102 void RCSRepresentation::clearResourceTypes()
104 m_resourceTypes.clear();
107 const RCSResourceAttributes& RCSRepresentation::getAttributes() const
112 RCSResourceAttributes& RCSRepresentation::getAttributes()
117 void RCSRepresentation::setAttributes(const RCSResourceAttributes& attrs)
119 m_attributes = attrs;
122 void RCSRepresentation::setAttributes(RCSResourceAttributes&& attrs)
124 m_attributes = std::move(attrs);
127 void RCSRepresentation::addChild(RCSRepresentation child)
129 m_children.push_back(std::move(child));
132 void RCSRepresentation::setChildren(std::vector< RCSRepresentation > children)
134 m_children = std::move(children);
137 const std::vector< RCSRepresentation >& RCSRepresentation::getChildren() const
142 void RCSRepresentation::clearChildren()
148 RCSRepresentation RCSRepresentation::fromOCRepresentation(const OC::OCRepresentation& ocRep)
150 return RCSRepresentation(ocRep.getUri(), ocRep.getResourceInterfaces(),
151 ocRep.getResourceTypes(),
152 ResourceAttributesConverter::fromOCRepresentation(ocRep));
155 OC::OCRepresentation RCSRepresentation::toOCRepresentation(const RCSRepresentation& rcsRep)
157 return toOCRepresentation(RCSRepresentation{ rcsRep });
160 OC::OCRepresentation RCSRepresentation::toOCRepresentation(RCSRepresentation&& rcsRep)
163 ResourceAttributesConverter::toOCRepresentation(std::move(rcsRep.m_attributes));
165 ocRep.setUri(std::move(rcsRep.m_uri));
166 ocRep.setResourceInterfaces(std::move(rcsRep.m_interfaces));
167 ocRep.setResourceTypes(std::move(rcsRep.m_resourceTypes));
169 for (auto& child : rcsRep.m_children)
171 ocRep.addChild(toOCRepresentation(std::move(child)));