17 #ifndef SDF_ELEMENT_HH_    18 #define SDF_ELEMENT_HH_    29 #include "sdf/sdf_config.h"    37 #pragma warning(disable: 4251)    45   inline namespace SDF_VERSION_NAMESPACE {
    69     public std::enable_shared_from_this<Element>
    79     public: ElementPtr Clone() 
const;
    83     public: 
void Copy(
const ElementPtr _elem);
    88     public: ElementPtr GetParent() 
const;
    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) 
const;
   139     public: 
void PrintValues(std::string _prefix) 
const;
   147     public: 
void PrintDocLeftPane(std::string &_html,
   148                                   int _spacing, 
int &_index) 
const;
   155     public: 
void PrintDocRightPane(std::string &_html,
   156                                   int _spacing, 
int &_index) 
const;
   161     public: std::string ToString(
const std::string &_prefix) 
const;
   170     public: 
void AddAttribute(
const std::string &_key,
   171                               const std::string &_type,
   172                               const std::string &_defaultvalue,
   174                               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) 
const;
   193     public: 
size_t GetAttributeCount() 
const;
   198     public: 
ParamPtr GetAttribute(
unsigned int _index) 
const;
   202     public: 
size_t GetElementDescriptionCount() 
const;
   207     public: ElementPtr GetElementDescription(
unsigned int _index) 
const;
   212     public: ElementPtr GetElementDescription(
const std::string &_key) 
const;
   217     public: 
bool HasElementDescription(
const std::string &_name) 
const;
   222     public: 
bool HasAttribute(
const std::string &_key) 
const;
   227     public: 
bool GetAttributeSet(
const std::string &_key) 
const;
   237     public: std::any GetAny(
const std::string &_key = 
"") 
const;
   245     public: 
template<
typename T>
   246             T Get(
const std::string &_key = 
"") 
const;
   254     public: 
template<
typename T>
   255             std::pair<T, bool> Get(
const std::string &_key,
   256                                    const T &_defaultValue) 
const;
   264     public: 
template<
typename T>
   265             bool Get(
const std::string &_key,
   267                      const T &_defaultValue) 
const;
   272     public: 
template<
typename T>
   273             bool Set(
const T &_value);
   278     public: 
bool HasElement(
const std::string &_name) 
const;
   283     public: ElementPtr GetFirstElement() 
const;
   296     public: ElementPtr GetNextElement(
const std::string &_name = 
"") 
const;
   300     public: std::set<std::string> GetElementTypeNames() 
const;
   309     public: 
bool HasUniqueChildNames(
const std::string &_type = 
"") 
const;
   318     public: std::map<std::string, std::size_t>
   319             CountNamedElements(
const std::string &_type = 
"") 
const;
   330     public: ElementPtr GetElement(
const std::string &_name);
   335     public: ElementPtr AddElement(
const std::string &_name);
   339     public: 
void InsertElement(ElementPtr _elem);
   342     public: 
void RemoveFromParent();
   346     public: 
void RemoveChild(ElementPtr _child);
   349     public: 
void ClearElements();
   353     public: 
void Clear();
   357     public: 
void Update();
   362     public: 
void Reset();
   366     public: 
void SetInclude(
const std::string &_filename);
   370     public: std::string GetInclude() 
const;
   374     public: 
void SetFilePath(
const std::string &_path);
   378     public: 
const std::string &FilePath() 
const;
   382     public: 
void SetOriginalVersion(
const std::string &_version);
   386     public: 
const std::string &OriginalVersion() 
const;
   390     public: std::string GetDescription() 
const;
   394     public: 
void SetDescription(
const std::string &_desc);
   398     public: 
void AddElementDescription(ElementPtr _elem);
   403     public: ElementPtr GetElementImpl(
const std::string &_name) 
const;
   408     private: 
void ToString(
const std::string &_prefix,
   409                            std::ostringstream &_out) 
const;
   414     private: 
void PrintValuesImpl(
const std::string &_prefix,
   415                                   std::ostringstream &_out) 
const;
   425     private: 
ParamPtr CreateParam(
const std::string &_key,
   426                                   const std::string &_type,
   427                                   const std::string &_defaultValue,
   429                                   const std::string &_description=
"");
   433     private: std::unique_ptr<ElementPrivate> dataPtr;
   482   T Element::Get(
const std::string &_key)
 const   486     std::pair<T, bool> ret = this->Get<T>(_key, result);
   493   bool Element::Get(
const std::string &_key,
   495                     const T &_defaultValue)
 const   497     std::pair<T, bool> ret = this->Get<T>(_key, _defaultValue);
   504   std::pair<T, bool> Element::Get(
const std::string &_key,
   505                                   const T &_defaultValue)
 const   507     std::pair<T, bool> result(_defaultValue, 
true);
   509     if (_key.empty() && this->dataPtr->value)
   511       this->dataPtr->value->Get<T>(result.first);
   513     else if (!_key.empty())
   515       ParamPtr param = this->GetAttribute(_key);
   518         param->Get(result.first);
   520       else if (this->HasElement(_key))
   522         result.first = this->GetElementImpl(_key)->Get<T>();
   524       else if (this->HasElementDescription(_key))
   526         result.first = this->GetElementDescription(_key)->Get<T>();
   530         result.second = 
false;
   535       result.second = 
false;
   543   bool Element::Set(
const T &_value)
   545     if (this->dataPtr->value)
   547       this->dataPtr->value->Set(_value);
 Param_V attributes
Definition: Element.hh:456
 
ElementPtr_V elementDescriptions
Definition: Element.hh:465
 
std::string includeFilename
name of the include file that was used to create this element 
Definition: Element.hh:468
 
ElementPtr_V elements
Definition: Element.hh:462
 
bool copyChildren
True if element's children should be copied. 
Definition: Element.hh:450
 
Definition: Element.hh:438
 
std::weak_ptr< Element > ElementWeakPtr
Definition: Element.hh:57
 
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
 
SDF Element class. 
Definition: Element.hh:68
 
std::string referenceSDF
Name of reference sdf. 
Definition: Element.hh:471
 
ParamPtr value
Definition: Element.hh:459
 
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
 
std::string path
Path to file where this element came from. 
Definition: Element.hh:474
 
std::string description
Element description. 
Definition: Element.hh:447
 
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported. 
Definition: system_util.hh:48
 
std::string name
Element name. 
Definition: Element.hh:441
 
std::shared_ptr< Param > ParamPtr
Definition: Param.hh:57
 
std::vector< ElementPtr > ElementPtr_V
Definition: Element.hh:61
 
namespace for Simulation Description Format parser 
Definition: Actor.hh:32
 
std::vector< ParamPtr > Param_V
Definition: Param.hh:61
 
std::string originalVersion
Spec version that this was originally parsed from. 
Definition: Element.hh:477
 
ElementWeakPtr parent
Element's parent. 
Definition: Element.hh:453
 
std::string required
True if element is required. 
Definition: Element.hh:444