17 #ifndef _SDF_ELEMENT_HH_
18 #define _SDF_ELEMENT_HH_
22 #include <boost/shared_ptr.hpp>
23 #include <boost/enable_shared_from_this.hpp>
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
35 #pragma GCC diagnostic pop
42 #pragma warning(disable: 4251)
66 public boost::enable_shared_from_this<Element>
76 public: boost::shared_ptr<Element> Clone()
const;
89 public:
void SetParent(
const ElementPtr _parent);
93 public:
void SetName(
const std::string &_name);
97 public:
const std::string &GetName()
const;
105 public:
void SetRequired(
const std::string &_req);
110 public:
const std::string &GetRequired()
const;
115 public:
void SetCopyChildren(
bool _value);
120 public:
bool GetCopyChildren()
const;
124 public:
void PrintDescription(
const std::string &_prefix);
128 public:
void PrintValues(std::string _prefix);
130 public:
void PrintWiki(std::string _prefix);
138 public:
void PrintDocLeftPane(std::string &_html,
139 int _spacing,
int &_index);
146 public:
void PrintDocRightPane(std::string &_html,
147 int _spacing,
int &_index);
152 public: std::string ToString(
const std::string &_prefix)
const;
160 public:
void AddAttribute(
const std::string &_key,
161 const std::string &_type,
162 const std::string &_defaultvalue,
164 const std::string &_description=
"");
171 public:
void AddValue(
const std::string &_type,
172 const std::string &_defaultValue,
bool _required,
173 const std::string &_description=
"");
178 public:
ParamPtr GetAttribute(
const std::string &_key);
181 public:
size_t GetAttributeCount()
const;
184 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
187 public:
size_t GetElementDescriptionCount()
const;
190 public:
ElementPtr GetElementDescription(
unsigned int _index)
const;
193 public:
ElementPtr GetElementDescription(
const std::string &_key)
const;
196 public:
bool HasElementDescription(
const std::string &_name);
198 public:
bool HasAttribute(
const std::string &_key);
201 public:
bool GetAttributeSet(
const std::string &_key);
210 public: boost::any GetAny(
const std::string &_key =
"");
212 public:
template<
typename T>
213 T Get(
const std::string &_key =
"");
215 public:
template<
typename T>
216 bool Set(
const T &_value);
218 public:
bool HasElement(
const std::string &_name)
const;
220 public:
ElementPtr GetElement(
const std::string &_name)
const;
223 public:
ElementPtr GetNextElement(
const std::string &_name =
"")
const;
225 public:
ElementPtr GetElement(
const std::string &_name);
226 public:
ElementPtr AddElement(
const std::string &_name);
230 public:
void RemoveFromParent();
237 public:
void ClearElements();
239 public:
void Update();
240 public:
void Reset();
242 public:
void SetInclude(
const std::string &_filename);
243 public: std::string GetInclude()
const;
246 public: std::string GetDescription()
const;
249 public:
void SetDescription(
const std::string &_desc);
252 public:
void AddElementDescription(
ElementPtr _elem);
254 public:
ElementPtr GetElementImpl(
const std::string &_name)
const;
256 private:
void ToString(
const std::string &_prefix,
257 std::ostringstream &_out)
const;
260 private: boost::shared_ptr<Param> CreateParam(
const std::string &_key,
261 const std::string &_type,
const std::string &_defaultValue,
262 bool _required,
const std::string &_description=
"");
310 if (_key.empty() && this->dataPtr->
value)
311 this->dataPtr->
value->
Get<T>(result);
312 else if (!_key.empty())
322 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
331 if (this->dataPtr->
value)
ElementPtr_V elementDescriptions
Definition: Element.hh:298
Element * ElementPtr
Definition: Element.hh:54
bool Set(const T &_value)
Definition: Element.hh:329
Definition: Element.hh:271
A parameter class.
Definition: Param.hh:67
bool Set(const T &_value)
Set the parameter's value.
Definition: Param.hh:258
ElementPtr GetElementImpl(const std::string &_name) const
class SDFORMAT_VISIBLE Element
Definition: Element.hh:50
bool HasElementDescription(const std::string &_name)
Return true if an element description exists.
std::string name
Element name.
Definition: Element.hh:274
T Get(const std::string &_key="")
Definition: Element.hh:306
ElementPtr GetElementDescription(unsigned int _index) const
Get an element description using an index.
SDF Element class.
Definition: Element.hh:65
ElementPtr parent
Element's parent.
Definition: Element.hh:286
std::string required
True if element is required.
Definition: Element.hh:277
bool Get(T &_value) const
Get the value of the parameter.
Definition: Param.hh:278
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
#define sdferr
Output an error message.
Definition: Console.hh:47
std::string includeFilename
name of the include file that was used to create this element
Definition: Element.hh:301
std::string description
Element description.
Definition: Element.hh:280
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:58
std::vector< ParamPtr > Param_V
Definition: Param.hh:60
bool HasElement(const std::string &_name) const
bool copyChildren
True if element's children should be copied.
Definition: Element.hh:283
Param_V attributes
Definition: Element.hh:289
ParamPtr GetAttribute(const std::string &_key)
Get the param of an attribute.
ElementPtr_V elements
Definition: Element.hh:295
ParamPtr value
Definition: Element.hh:292