RcsPySim
A robot control and simulation library
Rcs::PropertySourceXml Class Reference

#include <PropertySourceXml.h>

Inheritance diagram for Rcs::PropertySourceXml:
Collaboration diagram for Rcs::PropertySourceXml:

Public Member Functions

 PropertySourceXml (xmlNodePtr node, xmlDocPtr doc=NULL)
 
 PropertySourceXml (const char *configFile)
 
virtual ~PropertySourceXml ()
 
virtual bool exists ()
 
virtual bool getProperty (std::string &out, const char *property)
 
bool getProperty (std::vector< std::string > &out, const char *property) override
 
virtual bool getProperty (double &out, const char *property)
 
virtual bool getProperty (int &out, const char *property)
 
virtual bool getProperty (MatNd *&out, const char *property)
 
virtual bool getPropertyBool (const char *property, bool def=false)
 
virtual PropertySourcegetChild (const char *prefix)
 
virtual const std::vector< PropertySource * > & getChildList (const char *prefix)
 
virtual PropertySourceclone () const
 
virtual void saveXML (const char *fileName, const char *rootNodeName)
 
- Public Member Functions inherited from Rcs::PropertySource
 PropertySource ()
 
virtual ~PropertySource ()
 

Private Attributes

xmlNodePtr node
 
xmlDocPtr doc
 
std::map< std::string, PropertySource * > children
 
std::map< std::string, std::vector< PropertySource * > > listChildren
 

Additional Inherited Members

- Static Public Member Functions inherited from Rcs::PropertySource
static PropertySourceempty ()
 

Detailed Description

Property source backed by the attributes of an xml node.

Definition at line 46 of file PropertySourceXml.h.

Constructor & Destructor Documentation

◆ PropertySourceXml() [1/2]

Rcs::PropertySourceXml::PropertySourceXml ( xmlNodePtr  node,
xmlDocPtr  doc = NULL 
)

Constructor

Parameters
[in]nodenode whose attributes will be read
[in]docdocument to destroy on close. Use to make the node owned by this class. If null, node will not be destroyed.

Definition at line 62 of file PropertySourceXml.cpp.

◆ PropertySourceXml() [2/2]

Rcs::PropertySourceXml::PropertySourceXml ( const char *  configFile)
explicit

Constructor, loading XML from filename. Expects a root tag named 'Experiment'.

Parameters
configFilexml file name

Definition at line 45 of file PropertySourceXml.cpp.

◆ ~PropertySourceXml()

Rcs::PropertySourceXml::~PropertySourceXml ( )
virtual

Definition at line 68 of file PropertySourceXml.cpp.

Member Function Documentation

◆ clone()

PropertySource * Rcs::PropertySourceXml::clone ( ) const
virtual

Create an independent copy of this property source.

Returns
a copy of this property source. Must take ownership.

Implements Rcs::PropertySource.

Definition at line 241 of file PropertySourceXml.cpp.

◆ exists()

bool Rcs::PropertySourceXml::exists ( )
virtual

Check if this property source exists in the underlying storage.

Implements Rcs::PropertySource.

Definition at line 87 of file PropertySourceXml.cpp.

◆ getChild()

PropertySource * Rcs::PropertySourceXml::getChild ( const char *  prefix)
virtual

Obtain a child property source.

The exact meaning of this depends on the implementation. For an Xml document, it could be a child element. For a python dict, it could be a dict-typed entry.

The returned object is owned by the parent.

Implements Rcs::PropertySource.

Definition at line 196 of file PropertySourceXml.cpp.

◆ getChildList()

const std::vector< PropertySource * > & Rcs::PropertySourceXml::getChildList ( const char *  prefix)
virtual

Obtain a list of child property sources. The exact meaning of this depends on the implementation. For an Xml document, it could be child elements with the same tag name. For a python dict, it could be a list of dicts.

The returned objects are owned by the parent.

Implements Rcs::PropertySource.

Definition at line 218 of file PropertySourceXml.cpp.

◆ getProperty() [1/5]

bool Rcs::PropertySourceXml::getProperty ( std::string &  out,
const char *  property 
)
virtual

Read a string value.

Parameters
[out]outstorage for read value
[in]propertyname of property to read
Returns
true if the property was read successfully
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 93 of file PropertySourceXml.cpp.

◆ getProperty() [2/5]

bool Rcs::PropertySourceXml::getProperty ( std::vector< std::string > &  out,
const char *  property 
)
overridevirtual

Read a string list value.

Parameters
[out]outstorage for read value
[in]propertyname of property to read
Returns
true if the property was read successfully
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 105 of file PropertySourceXml.cpp.

◆ getProperty() [3/5]

bool Rcs::PropertySourceXml::getProperty ( double &  out,
const char *  property 
)
virtual

Read a double value.

Parameters
[out]outstorage for read value
[in]propertyname of property to read
Returns
true if the property was read successfully, false if it doesn't exist
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 114 of file PropertySourceXml.cpp.

◆ getProperty() [4/5]

bool Rcs::PropertySourceXml::getProperty ( int &  out,
const char *  property 
)
virtual

Read an int value.

Parameters
[out]outstorage for read value
[in]propertyname of property to read
Returns
true if the property was read successfully, false if it doesn't exist
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 132 of file PropertySourceXml.cpp.

◆ getProperty() [5/5]

bool Rcs::PropertySourceXml::getProperty ( MatNd *&  out,
const char *  property 
)
virtual

Read a vector/matrix value. The variable out should be a pointer and will be set to a newly created MatNd* on success.

Parameters
[out]outstorage for read value
[in]propertyname of property to read
Returns
true if the property was read successfully, false if it doesn't exist
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 150 of file PropertySourceXml.cpp.

◆ getPropertyBool()

bool Rcs::PropertySourceXml::getPropertyBool ( const char *  property,
bool  def = false 
)
virtual

Read a boolean value, returning a default value if not found. This interface differs from the others to ease usability

Parameters
[in]propertyname of property to read
[in]defvalue to return if property doesn't exist
Returns
true if the property was read successfully
Exceptions
std::exceptionif the property exists, but couldn't be converted

Implements Rcs::PropertySource.

Definition at line 184 of file PropertySourceXml.cpp.

◆ saveXML()

void Rcs::PropertySourceXml::saveXML ( const char *  fileName,
const char *  rootNodeName 
)
virtual

Save this property source as xml file.

Parameters
[in]fileNamename of the file to write
[in]rootNodeNamename of the xml root node

Implements Rcs::PropertySource.

Definition at line 251 of file PropertySourceXml.cpp.

Member Data Documentation

◆ children

std::map<std::string, PropertySource*> Rcs::PropertySourceXml::children
private

Definition at line 52 of file PropertySourceXml.h.

◆ doc

xmlDocPtr Rcs::PropertySourceXml::doc
private

Definition at line 50 of file PropertySourceXml.h.

◆ listChildren

std::map<std::string, std::vector<PropertySource*> > Rcs::PropertySourceXml::listChildren
private

Definition at line 53 of file PropertySourceXml.h.

◆ node

xmlNodePtr Rcs::PropertySourceXml::node
private

Definition at line 49 of file PropertySourceXml.h.


The documentation for this class was generated from the following files: