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)
const;
131 public:
void PrintValues(std::string _prefix)
const;
139 public:
void PrintDocLeftPane(std::string &_html,
140 int _spacing,
int &_index)
const;
147 public:
void PrintDocRightPane(std::string &_html,
148 int _spacing,
int &_index)
const;
153 public: std::string ToString(
const std::string &_prefix)
const;
162 public:
void AddAttribute(
const std::string &_key,
163 const std::string &_type,
164 const std::string &_defaultvalue,
166 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)
const;
185 public:
size_t GetAttributeCount()
const;
190 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
194 public:
size_t GetElementDescriptionCount()
const;
199 public:
ElementPtr GetElementDescription(
unsigned int _index)
const;
204 public:
ElementPtr GetElementDescription(
const std::string &_key)
const;
209 public:
bool HasElementDescription(
const std::string &_name)
const;
214 public:
bool HasAttribute(
const std::string &_key)
const;
219 public:
bool GetAttributeSet(
const std::string &_key)
const;
229 public: boost::any GetAny(
const std::string &_key =
"")
const;
237 public:
template<
typename T>
238 T Get(
const std::string &_key =
"")
const;
246 public:
template<
typename T>
247 std::pair<T, bool> Get(
const std::string &_key,
248 const T &_defaultValue)
const;
256 public:
template<
typename T>
257 bool Get(
const std::string &_key,
259 const T &_defaultValue)
const;
264 public:
template<
typename T>
265 bool Set(
const T &_value);
270 public:
bool HasElement(
const std::string &_name)
const;
288 public:
ElementPtr GetNextElement(
const std::string &_name =
"")
const;
299 public:
ElementPtr GetElement(
const std::string &_name);
304 public:
ElementPtr AddElement(
const std::string &_name);
311 public:
void RemoveFromParent();
318 public:
void ClearElements();
322 public:
void Update();
327 public:
void Reset();
331 public:
void SetInclude(
const std::string &_filename);
335 public: std::string GetInclude()
const;
339 public: std::string GetDescription()
const;
343 public:
void SetDescription(
const std::string &_desc);
347 public:
void AddElementDescription(
ElementPtr _elem);
352 public:
ElementPtr GetElementImpl(
const std::string &_name)
const;
357 private:
void ToString(
const std::string &_prefix,
358 std::ostringstream &_out)
const;
363 private:
void PrintValuesImpl(
const std::string &_prefix,
364 std::ostringstream &_out)
const;
374 private:
ParamPtr CreateParam(
const std::string &_key,
375 const std::string &_type,
376 const std::string &_defaultValue,
378 const std::string &_description=
"");
382 private: std::unique_ptr<ElementPrivate> dataPtr;
429 std::pair<T, bool> ret = this->Get<T>(_key, result);
438 const T &_defaultValue)
const
440 std::pair<T, bool> ret = this->Get<T>(_key, _defaultValue);
448 const T &_defaultValue)
const
450 std::pair<T, bool> result(_defaultValue,
true);
452 if (_key.empty() && this->dataPtr->value)
454 this->dataPtr->value->Get<T>(result.first);
456 else if (!_key.empty())
461 param->Get(result.first);
473 result.second =
false;
478 result.second =
false;
488 if (this->dataPtr->value)
490 this->dataPtr->value->Set(_value);
ParamPtr GetAttribute(const std::string &_key) const
Get the param of an attribute.
ElementPtr_V elementDescriptions
Definition: Element.hh:414
bool Set(const T &_value)
Set the value of this element.
Definition: Element.hh:486
Definition: Element.hh:387
std::weak_ptr< Element > ElementWeakPtr
Definition: Element.hh:49
std::string referenceSDF
Name of reference sdf.
Definition: Element.hh:420
ElementPtr GetElementImpl(const std::string &_name) const
Get a pointer to the named element.
class SDFORMAT_VISIBLE Element
Definition: Element.hh:41
std::string name
Element name.
Definition: Element.hh:390
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:53
ElementPtr GetElementDescription(unsigned int _index) const
Get an element description using an index.
SDF Element class.
Definition: Element.hh:60
T Get(const std::string &_key="") const
Get the value of a key.
Definition: Element.hh:425
std::string required
True if element is required.
Definition: Element.hh:393
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
std::string includeFilename
name of the include file that was used to create this element
Definition: Element.hh:417
std::string description
Element description.
Definition: Element.hh:396
std::shared_ptr< Param > ParamPtr
Definition: Param.hh:55
std::vector< ParamPtr > Param_V
Definition: Param.hh:59
ElementWeakPtr parent
Element's parent.
Definition: Element.hh:402
bool HasElement(const std::string &_name) const
Return true if the named element exists.
bool HasElementDescription(const std::string &_name) const
Return true if an element description exists.
bool copyChildren
True if element's children should be copied.
Definition: Element.hh:399
Param_V attributes
Definition: Element.hh:405
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:45
ElementPtr_V elements
Definition: Element.hh:411
ParamPtr value
Definition: Element.hh:408