17 #ifndef _SDF_ELEMENT_HH_
18 #define _SDF_ELEMENT_HH_
33 #pragma warning(disable: 4251)
61 public std::enable_shared_from_this<Element>
84 public:
void SetParent(
const ElementPtr _parent);
88 public:
void SetName(
const std::string &_name);
92 public:
const std::string &GetName()
const;
100 public:
void SetRequired(
const std::string &_req);
105 public:
const std::string &GetRequired()
const;
110 public:
void SetCopyChildren(
bool _value);
115 public:
bool GetCopyChildren()
const;
119 public:
void SetReferenceSDF(
const std::string &_value);
123 public: std::string ReferenceSDF()
const;
127 public:
void PrintDescription(
const std::string &_prefix);
131 public:
void PrintValues(std::string _prefix);
133 public:
void PrintWiki(std::string _prefix);
141 public:
void PrintDocLeftPane(std::string &_html,
142 int _spacing,
int &_index);
149 public:
void PrintDocRightPane(std::string &_html,
150 int _spacing,
int &_index);
155 public: std::string ToString(
const std::string &_prefix)
const;
163 public:
void AddAttribute(
const std::string &_key,
164 const std::string &_type,
165 const std::string &_defaultvalue,
167 const std::string &_description=
"");
174 public:
void AddValue(
const std::string &_type,
175 const std::string &_defaultValue,
bool _required,
176 const std::string &_description=
"");
181 public:
ParamPtr GetAttribute(
const std::string &_key);
184 public:
size_t GetAttributeCount()
const;
187 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
190 public:
size_t GetElementDescriptionCount()
const;
193 public:
ElementPtr GetElementDescription(
unsigned int _index)
const;
196 public:
ElementPtr GetElementDescription(
const std::string &_key)
const;
199 public:
bool HasElementDescription(
const std::string &_name);
201 public:
bool HasAttribute(
const std::string &_key);
204 public:
bool GetAttributeSet(
const std::string &_key);
213 public: boost::any GetAny(
const std::string &_key =
"");
221 public:
template<
typename T>
222 T Get(
const std::string &_key =
"");
230 public:
template<
typename T>
231 std::pair<T, bool> Get(
const std::string &_key,
232 const T &_defaultValue);
234 public:
template<
typename T>
235 bool Set(
const T &_value);
237 public:
bool HasElement(
const std::string &_name)
const;
239 public:
ElementPtr GetElement(
const std::string &_name)
const;
256 public:
ElementPtr GetNextElement(
const std::string &_name =
"")
const;
267 public:
ElementPtr GetElement(
const std::string &_name);
269 public:
ElementPtr AddElement(
const std::string &_name);
273 public:
void RemoveFromParent();
280 public:
void ClearElements();
282 public:
void Update();
283 public:
void Reset();
285 public:
void SetInclude(
const std::string &_filename);
286 public: std::string GetInclude()
const;
289 public: std::string GetDescription()
const;
292 public:
void SetDescription(
const std::string &_desc);
295 public:
void AddElementDescription(
ElementPtr _elem);
297 public:
ElementPtr GetElementImpl(
const std::string &_name)
const;
299 private:
void ToString(
const std::string &_prefix,
300 std::ostringstream &_out)
const;
303 private:
ParamPtr CreateParam(
const std::string &_key,
304 const std::string &_type,
const std::string &_defaultValue,
305 bool _required,
const std::string &_description=
"");
356 if (_key.empty() && this->dataPtr->
value)
357 this->dataPtr->
value->Get<T>(result);
358 else if (!_key.empty())
368 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
376 const T &_defaultValue)
378 std::pair<T, bool> result(_defaultValue,
true);
380 if (_key.empty() && this->dataPtr->
value)
381 this->dataPtr->
value->Get<T>(result.first);
382 else if (!_key.empty())
386 param->Get(result.first);
390 result.first = this->GetElementDescription(_key)->Get<T>();
392 result.second =
false;
396 result.second =
false;
406 if (this->dataPtr->
value)
408 this->dataPtr->
value->Set(_value);
ElementPtr_V elementDescriptions
Definition: Element.hh:341
bool Set(const T &_value)
Definition: Element.hh:404
Definition: Element.hh:314
std::weak_ptr< Element > ElementWeakPtr
Definition: Element.hh:49
std::string referenceSDF
Name of reference sdf.
Definition: Element.hh:347
ElementPtr GetElementImpl(const std::string &_name) const
class SDFORMAT_VISIBLE Element
Definition: Element.hh:41
bool HasElementDescription(const std::string &_name)
Return true if an element description exists.
std::string name
Element name.
Definition: Element.hh:317
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:53
T Get(const std::string &_key="")
Get the value of a key.
Definition: Element.hh:352
ElementPtr GetElementDescription(unsigned int _index) const
Get an element description using an index.
SDF Element class.
Definition: Element.hh:60
std::string required
True if element is required.
Definition: Element.hh:320
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
#define sdferr
Output an error message.
Definition: Console.hh:54
std::string includeFilename
name of the include file that was used to create this element
Definition: Element.hh:344
std::string description
Element description.
Definition: Element.hh:323
std::shared_ptr< Param > ParamPtr
Definition: Param.hh:47
std::vector< ParamPtr > Param_V
Definition: Param.hh:51
ElementWeakPtr parent
Element's parent.
Definition: Element.hh:329
bool HasElement(const std::string &_name) const
bool copyChildren
True if element's children should be copied.
Definition: Element.hh:326
Param_V attributes
Definition: Element.hh:332
ParamPtr GetAttribute(const std::string &_key)
Get the param of an attribute.
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:45
ElementPtr_V elements
Definition: Element.hh:338
ParamPtr value
Definition: Element.hh:335