1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
22 * @file RamlResource.h
\r
24 * @brief This file provides data Model for RAML RamlResource.
\r
33 #include "UriParameter.h"
\r
34 #include "ActionType.h"
\r
36 #include "RamlUtils.h"
\r
37 #include "IncludeResolver.h"
\r
42 * @class RamlResource
\r
43 * @brief This class provides data Model for RAML RamlResource.
\r
49 * This method is for getting DisplayName from RamlResource.
\r
51 * @return DisplayName as string.
\r
53 virtual std::string getDisplayName() const;
\r
56 * This method is for setting DisplayName to RamlResource.
\r
58 * @param displayName - DisplayName as string
\r
60 virtual void setDisplayName(const std::string &displayName);
\r
63 * This method is for getting Description from RamlResource.
\r
65 * @return Description as string.
\r
67 virtual std::string getDescription() const;
\r
70 * This method is for setting Description to RamlResource.
\r
72 * @param description - Description as string
\r
74 virtual void setDescription(const std::string &description);
\r
77 * This method is for getting ParentUri from RamlResource.
\r
79 * @return ParentUri as string.
\r
81 virtual std::string getParentUri() const;
\r
84 * This method is for setting ParentUri to RamlResource.
\r
86 * @param parentUri - ParentUri as string
\r
88 virtual void setParentUri(const std::string &parentUri);
\r
91 * This method is for getting RelativeUri from RamlResource.
\r
93 * @return RelativeUri as string.
\r
95 virtual std::string getRelativeUri() const;
\r
98 * This method is for setting RelativeUri to RamlResource.
\r
100 * @param relativeUri - RelativeUri as string
\r
102 virtual void setRelativeUri(const std::string &relativeUri);
\r
105 * This method is for getting UriParameter from RamlResource.
\r
107 * @return map of UriParameter name and Pointer to UriParameter.
\r
109 virtual std::map<std::string, UriParameterPtr> const &getUriParameters() const;
\r
112 * This method is for setting UriParameter to RamlResource.
\r
114 * @param paramName - name of UriParameter as string
\r
115 * @param uriParameter - pointer to UriParameter
\r
117 virtual void setUriParameter(const std::string ¶mName, const UriParameterPtr &uriParameter);
\r
120 * This method is for getting BaseUriParameter from RamlResource.
\r
122 * @return map of BaseUriParameter name and Pointer to UriParameter.
\r
124 virtual std::map<std::string, UriParameterPtr > const &getBaseUriParameters() const;
\r
127 * This method is for setting BaseUriParameter to RamlResource.
\r
129 * @param paramName - name of BaseUriParameter as string
\r
130 * @param baseUriParameter - pointer to UriParameter
\r
132 virtual void setBaseUriParameter(const std::string ¶mName,
\r
133 const UriParameterPtr &baseUriParameter);
\r
136 * This method is for getting Action from RamlResource.
\r
138 * @param actionType - type of action as ActionType
\r
140 * @return Pointer to Action.
\r
142 virtual ActionPtr getAction(ActionType actionType);
\r
145 * This method is for getting Action from RamlResource.
\r
147 * @return map of ActionType and Pointer to Action.
\r
149 virtual std::map<ActionType , ActionPtr> const &getActions() const;
\r
152 * This method is for setting Action to RamlResource.
\r
154 * @param actiontype - type of action
\r
155 * @param action - pointer to Action
\r
157 virtual void setAction(const ActionType &actiontype , const ActionPtr &action );
\r
160 * This method is for getting child Resource from RamlResource.
\r
162 * @return map of Resource name and Pointer to RamlResource.
\r
164 virtual std::map<std::string, std::shared_ptr<RamlResource> > const &getResources() const;
\r
167 * This method is for setting child Resource to RamlResource.
\r
169 * @param resourceName - name of Resource as string
\r
170 * @param resources - pointer to RamlResource
\r
172 virtual void setResource(const std::string &resourceName,
\r
173 const std::shared_ptr<RamlResource> &resources);
\r
176 * This method is for getting Traits from RamlResource.
\r
178 * @return list of Traits name.
\r
180 virtual std::list<std::string> const &getTraits() const;
\r
183 * This method is for setting Traits to RamlResource.
\r
185 * @param trait - name of Traits
\r
187 virtual void setTrait(const std::string &trait);
\r
190 * This method is for getting ResourceType from RamlResource.
\r
192 * @return ResourceType name.
\r
194 virtual std::string getResourceType() const;
\r
197 * This method is for setting ResourceType to RamlResource.
\r
199 * @param type - name of ResourceType
\r
201 virtual void setResourceType(const std::string &type);
\r
204 * This method is for getting ResourceUri from RamlResource.
\r
206 * @return ResourceUri as string.
\r
208 virtual std::string getResourceUri() const;
\r
211 * Constructor of RamlResource.
\r
213 RamlResource(): m_includeResolver(NULL) {}
\r
216 * Constructor of RamlResource.
\r
218 * @param resourceKey - name of the Resource
\r
219 * @param yamlNode - Reference to YamlNode for reading the RamlResource
\r
220 * @param includeResolver - Reference to IncludeResolver for reading external files
\r
221 * @param parentUri - Uri of the Parent to form the Absolute Uri
\r
224 RamlResource(const std::string resourceKey, const YAML::Node &yamlNode ,
\r
225 const IncludeResolverPtr &includeResolver,
\r
226 const std::string &parentUri) : m_includeResolver(includeResolver)
\r
228 readResource(resourceKey, yamlNode, parentUri);
\r
231 void readResource(const std::string resourceKey, const YAML::Node &yamlNode,
\r
232 const std::string &parentUri);
\r
234 std::string m_displayName;
\r
235 std::string m_description;
\r
236 std::string m_relativeUri;
\r
237 std::map<std::string, UriParameterPtr> m_uriParameters;
\r
238 std::map<std::string, UriParameterPtr > m_baseUriParameters;
\r
239 std::map<ActionType , ActionPtr> m_actions;
\r
240 std::list<std::string> m_traits;
\r
241 std::string m_resourceType;
\r
242 std::string m_parentUri;
\r
243 std::map<std::string, std::shared_ptr<RamlResource> > m_resources;
\r
244 IncludeResolverPtr m_includeResolver;
\r
247 /** RamlResourcePtr - shared Ptr to RamlResource.*/
\r
248 typedef std::shared_ptr<RamlResource> RamlResourcePtr;
\r