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) 70 public boost::enable_shared_from_this<Element>
80 public: ElementPtr Clone()
const;
84 public:
void Copy(
const ElementPtr _elem);
89 public: ElementPtr GetParent()
const;
93 public:
void SetParent(
const ElementPtr _parent);
97 public:
void SetName(
const std::string &_name);
101 public:
const std::string &GetName()
const;
109 public:
void SetRequired(
const std::string &_req);
114 public:
const std::string &GetRequired()
const;
119 public:
void SetCopyChildren(
bool _value);
124 public:
bool GetCopyChildren()
const;
128 public:
void SetReferenceSDF(
const std::string &_value);
132 public: std::string ReferenceSDF()
const;
136 public:
void PrintDescription(
const std::string &_prefix);
140 public:
void PrintValues(std::string _prefix);
142 public:
void PrintWiki(std::string _prefix);
150 public:
void PrintDocLeftPane(std::string &_html,
151 int _spacing,
int &_index);
158 public:
void PrintDocRightPane(std::string &_html,
159 int _spacing,
int &_index);
164 public: std::string ToString(
const std::string &_prefix)
const;
172 public:
void AddAttribute(
const std::string &_key,
173 const std::string &_type,
174 const std::string &_defaultvalue,
176 const std::string &_description=
"");
183 public:
void AddValue(
const std::string &_type,
184 const std::string &_defaultValue,
bool _required,
185 const std::string &_description=
"");
190 public:
ParamPtr GetAttribute(
const std::string &_key);
193 public:
size_t GetAttributeCount()
const;
196 public:
ParamPtr GetAttribute(
unsigned int _index)
const;
199 public:
size_t GetElementDescriptionCount()
const;
202 public: ElementPtr GetElementDescription(
unsigned int _index)
const;
205 public: ElementPtr GetElementDescription(
const std::string &_key)
const;
208 public:
bool HasElementDescription(
const std::string &_name);
210 public:
bool HasAttribute(
const std::string &_key);
213 public:
bool GetAttributeSet(
const std::string &_key);
222 public: boost::any GetAny(
const std::string &_key =
"");
224 public:
template<
typename T>
225 T Get(
const std::string &_key =
"");
227 public:
template<
typename T>
228 bool Set(
const T &_value);
230 public:
bool HasElement(
const std::string &_name)
const;
232 public: ElementPtr GetElement(
const std::string &_name)
const;
233 public: ElementPtr GetFirstElement()
const;
235 public: ElementPtr GetNextElement(
const std::string &_name =
"")
const;
237 public: ElementPtr GetElement(
const std::string &_name);
238 public: ElementPtr AddElement(
const std::string &_name);
239 public:
void InsertElement(ElementPtr _elem);
242 public:
void RemoveFromParent();
246 public:
void RemoveChild(ElementPtr _child);
249 public:
void ClearElements();
251 public:
void Update();
252 public:
void Reset();
254 public:
void SetInclude(
const std::string &_filename);
255 public: std::string GetInclude()
const;
258 public: std::string GetDescription()
const;
261 public:
void SetDescription(
const std::string &_desc);
264 public:
void AddElementDescription(ElementPtr _elem);
266 public: ElementPtr GetElementImpl(
const std::string &_name)
const;
268 private:
void ToString(
const std::string &_prefix,
269 std::ostringstream &_out)
const;
272 private:
ParamPtr CreateParam(
const std::string &_key,
273 const std::string &_type,
const std::string &_defaultValue,
274 bool _required,
const std::string &_description=
"");
325 if (_key.empty() && this->dataPtr->value)
326 this->dataPtr->value->Get<T>(result);
327 else if (!_key.empty())
329 ParamPtr param = this->GetAttribute(_key);
332 else if (this->HasElement(_key))
333 result = this->GetElementImpl(_key)->Get<T>();
334 else if (this->HasElementDescription(_key))
335 result = this->GetElementDescription(_key)->Get<T>();
337 sdferr <<
"Unable to find value for key[" << _key <<
"]\n";
346 if (this->dataPtr->value)
348 this->dataPtr->value->Set(_value);
ElementPtr_V elementDescriptions
Definition: Element.hh:310
Element * ElementPtr
Definition: Element.hh:54
bool Set(const T &_value)
Definition: Element.hh:344
Definition: Element.hh:283
std::string referenceSDF
Name of reference sdf.
Definition: Element.hh:316
A parameter class.
Definition: Param.hh:67
class SDFORMAT_VISIBLE Element
Definition: Element.hh:50
std::string name
Element name.
Definition: Element.hh:286
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:62
T Get(const std::string &_key="")
Definition: Element.hh:321
SDF Element class.
Definition: Element.hh:69
std::string required
True if element is required.
Definition: Element.hh:289
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
boost::weak_ptr< Element > ElementWeakPtr
Definition: Element.hh:58
std::string includeFilename
name of the include file that was used to create this element
Definition: Element.hh:313
std::string description
Element description.
Definition: Element.hh:292
std::vector< ParamPtr > Param_V
Definition: Param.hh:60
ElementWeakPtr parent
Element's parent.
Definition: Element.hh:298
namespace for Simulation Description Format parser
Definition: Console.hh:29
bool copyChildren
True if element's children should be copied.
Definition: Element.hh:295
Param_V attributes
Definition: Element.hh:301
ElementPtr_V elements
Definition: Element.hh:307
ParamPtr value
Definition: Element.hh:304