17 #ifndef _SDF_ELEMENT_HH_
18 #define _SDF_ELEMENT_HH_
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
34 #pragma GCC diagnostic pop
41 #pragma warning(disable: 4251)
69 public std::enable_shared_from_this<Element>
92 public:
void SetParent(
const ElementPtr _parent);
96 public:
void SetName(
const std::string &_name);
100 public:
const std::string &GetName()
const;
108 public:
void SetRequired(
const std::string &_req);
113 public:
const std::string &GetRequired()
const;
118 public:
void SetCopyChildren(
bool _value);
123 public:
bool GetCopyChildren()
const;
127 public:
void SetReferenceSDF(
const std::string &_value);
131 public: std::string ReferenceSDF()
const;
135 public:
void PrintDescription(
const std::string &_prefix);
139 public:
void PrintValues(std::string _prefix);
141 public:
void PrintWiki(std::string _prefix);
149 public:
void PrintDocLeftPane(std::string &_html,
150 int _spacing,
int &_index);
157 public:
void PrintDocRightPane(std::string &_html,
158 int _spacing,
int &_index);
163 public: std::string ToString(
const std::string &_prefix)
const;
171 public:
void AddAttribute(
const std::string &_key,
172 const std::string &_type,
173 const std::string &_defaultvalue,
175 const std::string &_description=
"");
182 public:
void AddValue(
const std::string &_type,
183 const std::string &_defaultValue,
bool _required,
184 const std::string &_description=
"");
189 public:
ParamPtr GetAttribute(
const std::string &_key);
192 public:
size_t GetAttributeCount()
const;
195 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
198 public:
size_t GetElementDescriptionCount()
const;
201 public:
ElementPtr GetElementDescription(
unsigned int _index)
const;
204 public:
ElementPtr GetElementDescription(
const std::string &_key)
const;
207 public:
bool HasElementDescription(
const std::string &_name);
209 public:
bool HasAttribute(
const std::string &_key);
212 public:
bool GetAttributeSet(
const std::string &_key);
221 public: boost::any GetAny(
const std::string &_key =
"");
223 public:
template<
typename T>
224 T Get(
const std::string &_key =
"");
226 public:
template<
typename T>
227 bool Set(
const T &_value);
229 public:
bool HasElement(
const std::string &_name)
const;
231 public:
ElementPtr GetElement(
const std::string &_name)
const;
234 public:
ElementPtr GetNextElement(
const std::string &_name =
"")
const;
236 public:
ElementPtr GetElement(
const std::string &_name);
237 public:
ElementPtr AddElement(
const std::string &_name);
241 public:
void RemoveFromParent();
248 public:
void ClearElements();
250 public:
void Update();
251 public:
void Reset();
253 public:
void SetInclude(
const std::string &_filename);
254 public: std::string GetInclude()
const;
257 public: std::string GetDescription()
const;
260 public:
void SetDescription(
const std::string &_desc);
263 public:
void AddElementDescription(
ElementPtr _elem);
265 public:
ElementPtr GetElementImpl(
const std::string &_name)
const;
267 private:
void ToString(
const std::string &_prefix,
268 std::ostringstream &_out)
const;
271 private:
ParamPtr CreateParam(
const std::string &_key,
272 const std::string &_type,
const std::string &_defaultValue,
273 bool _required,
const std::string &_description=
"");
324 if (_key.empty() && this->dataPtr->
value)
325 this->dataPtr->
value->Get<T>(result);
326 else if (!_key.empty())
336 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
345 if (this->dataPtr->
value)
347 this->dataPtr->
value->Set(_value);
ElementPtr_V elementDescriptions
Definition: Element.hh:309
bool Set(const T &_value)
Definition: Element.hh:343
Definition: Element.hh:282
std::weak_ptr< Element > ElementWeakPtr
Definition: Element.hh:57
std::string referenceSDF
Name of reference sdf.
Definition: Element.hh:315
ElementPtr GetElementImpl(const std::string &_name) const
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
bool HasElementDescription(const std::string &_name)
Return true if an element description exists.
std::string name
Element name.
Definition: Element.hh:285
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:61
T Get(const std::string &_key="")
Definition: Element.hh:320
ElementPtr GetElementDescription(unsigned int _index) const
Get an element description using an index.
SDF Element class.
Definition: Element.hh:68
std::string required
True if element is required.
Definition: Element.hh:288
#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:312
std::string description
Element description.
Definition: Element.hh:291
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:297
bool HasElement(const std::string &_name) const
bool copyChildren
True if element's children should be copied.
Definition: Element.hh:294
Param_V attributes
Definition: Element.hh:300
ParamPtr GetAttribute(const std::string &_key)
Get the param of an attribute.
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
ElementPtr_V elements
Definition: Element.hh:306
ParamPtr value
Definition: Element.hh:303