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(const std::string& uri)
77 void RCSRepresentation::setUri(std::string&& uri)
79 m_uri = std::move(uri);
82 const std::vector< std::string >& RCSRepresentation::getInterfaces() const
87 void RCSRepresentation::addInterface(const std::string& interface)
89 m_interfaces.push_back(interface);
92 void RCSRepresentation::addInterface(std::string&& interface)
94 m_interfaces.push_back(std::move(interface));
97 void RCSRepresentation::clearInterfaces()
102 const std::vector< std::string >& RCSRepresentation::getResourceTypes() const
104 return m_resourceTypes;
107 void RCSRepresentation::addResourceType(const std::string& resourceType)
109 m_resourceTypes.push_back(resourceType);
112 void RCSRepresentation::addResourceType(std::string&& resourceType)
114 m_resourceTypes.push_back(std::move(resourceType));
117 void RCSRepresentation::clearResourceTypes()
119 m_resourceTypes.clear();
122 const RCSResourceAttributes& RCSRepresentation::getAttributes() const
127 RCSResourceAttributes& RCSRepresentation::getAttributes()
132 void RCSRepresentation::setAttributes(const RCSResourceAttributes& attrs)
134 m_attributes = attrs;
137 void RCSRepresentation::setAttributes(RCSResourceAttributes&& attrs)
139 m_attributes = std::move(attrs);
142 void RCSRepresentation::addChild(const RCSRepresentation& child)
144 m_children.push_back(child);
147 void RCSRepresentation::addChild(RCSRepresentation&& child)
149 m_children.push_back(std::move(child));
152 void RCSRepresentation::setChildren(const std::vector< RCSRepresentation >& children)
154 m_children = children;
157 void RCSRepresentation::setChildren(std::vector< RCSRepresentation >&& children)
159 m_children = std::move(children);
162 const std::vector< RCSRepresentation >& RCSRepresentation::getChildren() const
167 void RCSRepresentation::clearChildren()
173 RCSRepresentation RCSRepresentation::fromOCRepresentation(const OC::OCRepresentation& ocRep)
175 return RCSRepresentation(ocRep.getUri(), ocRep.getResourceInterfaces(),
176 ocRep.getResourceTypes(),
177 ResourceAttributesConverter::fromOCRepresentation(ocRep));
180 OC::OCRepresentation RCSRepresentation::toOCRepresentation(const RCSRepresentation& rcsRep)
182 return toOCRepresentation(RCSRepresentation{ rcsRep });
185 OC::OCRepresentation RCSRepresentation::toOCRepresentation(RCSRepresentation&& rcsRep)
188 ResourceAttributesConverter::toOCRepresentation(std::move(rcsRep.m_attributes));
190 ocRep.setUri(std::move(rcsRep.m_uri));
191 ocRep.setResourceInterfaces(std::move(rcsRep.m_interfaces));
192 ocRep.setResourceTypes(std::move(rcsRep.m_resourceTypes));
194 for (auto& child : rcsRep.m_children)
196 ocRep.addChild(toOCRepresentation(std::move(child)));