SOFA API  cba138a4
Open source framework for multi-physics simuation
sofa::core::objectmodel::BaseObjectDescription Class Reference

#include <BaseObjectDescription.h>

Base Interface for classes containing the description of an object, used to construct it. More...

Inheritance diagram for sofa::core::objectmodel::BaseObjectDescription:

Detailed Description

Base Interface for classes containing the description of an object, used to construct it.

This class defines what informations are used as input (read from a file for instance) to create an object. This default implementation simply stores an attributes map and does not support any hierarchy.

Classes

class  Attribute
 

Protected Attributes

AttributeMap attributes
 
std::vector< std::string > errors
 

Public Member Functions

 BaseObjectDescription (const char *name=nullptr, const char *type=nullptr)
 
virtual ~BaseObjectDescription ()
 
virtual BasegetObject ()
 Get the associated object (or nullptr if it is not created yet) More...
 
virtual std::string getName ()
 Get the object instance name. More...
 
virtual void setName (const std::string &name)
 Set the object instance name. More...
 
virtual BaseObjectDescriptiongetParent () const
 Get the parent node. More...
 
virtual std::string getBaseFile ()
 Get the file where this description was read from. Useful to resolve relative file paths. More...
 
virtual const AttributeMapgetAttributeMap () const
 
template<class T >
void getAttributeList (T &container) const
 
virtual BaseObjectDescriptionfind (const char *nodeName, bool absolute=false)
 Find an object description given its name (relative to this object) More...
 
virtual BasefindObject (const char *nodeName)
 Find an object given its name (relative to this object) More...
 
virtual const char * getAttribute (const std::string &attr, const char *defaultVal=nullptr)
 Get an attribute given its name (return defaultVal if not present) More...
 
virtual float getAttributeAsFloat (const std::string &attr, const float defaultVal=0.0)
 Docs is in .h. More...
 
virtual int getAttributeAsInt (const std::string &attr, const int defaultVal=0.0)
 Docs is in .h. More...
 
virtual void setAttribute (const std::string &attr, const std::string &val)
 Set an attribute. Override any existing value. More...
 
virtual bool removeAttribute (const std::string &attr)
 Remove an attribute given its name. More...
 
virtual std::string getFullName ()
 Get the full name of this object (i.e. concatenation if all the names of its ancestors and itself) More...
 
virtual void logError (const std::string &s)
 
virtual void logErrors (const std::vector< std::string > &e)
 
std::vector< std::string > const & getErrors () const
 
virtual void clearErrors ()
 

Attribute details

AttributeMap sofa::core::objectmodel::BaseObjectDescription::attributes
protected
std::vector< std::string > sofa::core::objectmodel::BaseObjectDescription::errors
protected

Constructor details

sofa::core::objectmodel::BaseObjectDescription::BaseObjectDescription ( const char *  name = nullptr,
const char *  type = nullptr 
)
sofa::core::objectmodel::BaseObjectDescription::~BaseObjectDescription ( )
virtual

Function details

virtual void sofa::core::objectmodel::BaseObjectDescription::clearErrors ( )
inlinevirtual
BaseObjectDescription * sofa::core::objectmodel::BaseObjectDescription::find ( const char *  nodeName,
bool  absolute = false 
)
virtual

Find an object description given its name (relative to this object)

Reimplemented in sofa::simulation::xml::BaseElement.

Base * sofa::core::objectmodel::BaseObjectDescription::findObject ( const char *  nodeName)
virtual

Find an object given its name (relative to this object)

Find an object given its name.

const char * sofa::core::objectmodel::BaseObjectDescription::getAttribute ( const std::string &  attr,
const char *  defaultVal = nullptr 
)
virtual

Get an attribute given its name (return defaultVal if not present)

float sofa::core::objectmodel::BaseObjectDescription::getAttributeAsFloat ( const std::string &  attr,
const float  defaultVal = 0.0 
)
virtual

Docs is in .h.

Get an attribute converted to a float given its name. returns defaultVal if not present or in case the attribute cannot be parsed totally adds a message in the logError if the attribute cannot be totally parsed.

int sofa::core::objectmodel::BaseObjectDescription::getAttributeAsInt ( const std::string &  attr,
const int  defaultVal = 0.0 
)
virtual

Docs is in .h.

Get an attribute converted to a int given its name. returns defaultVal if not present or in case the attribute cannot be parsed totally adds a message in the logError if the attribute cannot be totally parsed.

template<class T >
void sofa::core::objectmodel::BaseObjectDescription::getAttributeList ( T &  container) const
inline
const BaseObjectDescription::AttributeMap & sofa::core::objectmodel::BaseObjectDescription::getAttributeMap ( ) const
virtual
std::string sofa::core::objectmodel::BaseObjectDescription::getBaseFile ( )
virtual

Get the file where this description was read from. Useful to resolve relative file paths.

Reimplemented in sofa::simulation::xml::BaseElement.

std::vector< std::string > const& sofa::core::objectmodel::BaseObjectDescription::getErrors ( ) const
inline
std::string sofa::core::objectmodel::BaseObjectDescription::getFullName ( )
virtual

Get the full name of this object (i.e. concatenation if all the names of its ancestors and itself)

std::string sofa::core::objectmodel::BaseObjectDescription::getName ( )
virtual

Get the object instance name.

Reimplemented in sofa::simulation::xml::BaseElement.

Base * sofa::core::objectmodel::BaseObjectDescription::getObject ( )
virtual
BaseObjectDescription * sofa::core::objectmodel::BaseObjectDescription::getParent ( ) const
virtual

Get the parent node.

Reimplemented in sofa::simulation::xml::BaseElement.

virtual void sofa::core::objectmodel::BaseObjectDescription::logError ( const std::string &  s)
inlinevirtual
virtual void sofa::core::objectmodel::BaseObjectDescription::logErrors ( const std::vector< std::string > &  e)
inlinevirtual
bool sofa::core::objectmodel::BaseObjectDescription::removeAttribute ( const std::string &  attr)
virtual

Remove an attribute given its name.

Remove an attribute given its name, returns false if the attribute was not there.

Reimplemented in sofa::simulation::xml::BaseElement.

void sofa::core::objectmodel::BaseObjectDescription::setAttribute ( const std::string &  attr,
const std::string &  val 
)
virtual

Set an attribute. Override any existing value.

void sofa::core::objectmodel::BaseObjectDescription::setName ( const std::string &  name)
virtual

Set the object instance name.

Reimplemented in sofa::simulation::xml::BaseElement.