SOFA API  ca665544
Open source framework for multi-physics simuation
sofa::simulation::xml::BaseElement Class Referenceabstract

#include <BaseElement.h>

Inheritance diagram for sofa::simulation::xml::BaseElement:

Classes

class  child_iterator
 

Protected Attributes

std::map< std::string, std::string > replaceAttribute
 
- Protected Attributes inherited from sofa::core::objectmodel::BaseObjectDescription
AttributeMap attributes
 
std::vector< std::string > errors
 

Public Member Functions

 BaseElement (const std::string &name, const std::string &type, BaseElement *newParent=nullptr)
 
 ~BaseElement () override
 
virtual const chargetClass () const =0
 Get the node class (Scene, Mapping, ...) More...
 
sofa::core::objectmodel::BasegetObject () override=0
 Get the associated object. More...
 
std::string getName () override
 Get the node instance name. More...
 
virtual void setName (const std::string &newName) override
 Set the object instance name. More...
 
std::string getType ()
 Get the node instance type (MassObject, IdentityMapping, ...) More...
 
virtual void setType (const std::string &newType)
 
sofa::core::objectmodel::BaseObjectDescriptiongetParent () const override
 Get the parent node. More...
 
BaseElementgetParentElement () const
 Get the parent node. More...
 
std::string getBaseFile () override
 Get the file where this description was read from. Useful to resolve relative file paths. More...
 
virtual void setBaseFile (const std::string &newBaseFile)
 
const std::string & getSrcFile () const
 
virtual void setSrcFile (const std::string &newSrcFile)
 
int getSrcLine () const
 
virtual void setSrcLine (const int l)
 
bool isFileRoot ()
 Return true if this element was the root of the file. More...
 
IncludeNodeType getIncludeNodeType () const
 Return if the current element ifsa special group node from an included file. More...
 
void setIncludeNodeType (IncludeNodeType t)
 Specify that the current element is a special group node from an included file. More...
 
virtual bool presenceAttribute (const std::string &s)
 Verify the presence of an attribute. More...
 
virtual bool removeAttribute (const std::string &attr) override
 Remove an attribute. Fails if this attribute is "name" or "type". More...
 
virtual void addReplaceAttribute (const std::string &attr, const char *val)
 List of parameters to be replaced. More...
 
virtual BaseElementfindNode (const char *nodeName, bool absolute=false)
 Find a node given its name. More...
 
BaseObjectDescriptionfind (const char *nodeName, bool absolute=false) override
 Find a node given its name. More...
 
template<class Sequence >
void pushObjects (Sequence &result)
 Get all objects of a given type. More...
 
template<class Map >
void pushNamedObjects (Map &result)
 Get all objects of a given type. More...
 
virtual bool addChild (BaseElement *child)
 
virtual bool removeChild (BaseElement *child)
 
virtual bool initNode ()=0
 
virtual bool init ()
 
template<class Node >
child_iterator< Nodebegin ()
 
child_iterator< BaseElementbegin ()
 
template<class Node >
child_iterator< Nodeend ()
 
child_iterator< BaseElementend ()
 
- Public Member Functions inherited from sofa::core::objectmodel::BaseObjectDescription
 BaseObjectDescription (const char *name=nullptr, const char *type=nullptr)
 
virtual ~BaseObjectDescription ()
 
virtual const AttributeMapgetAttributeMap () const
 
template<class T >
void getAttributeList (T &container) const
 
virtual BasefindObject (const char *nodeName)
 Find an object given its name (relative to this object) More...
 
virtual const chargetAttribute (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 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 ()
 

Static Public Member Functions

static BaseElementCreate (const std::string &nodeClass, const std::string &name, const std::string &type)
 
template<class Node >
static Nodecreate (Node *, std::pair< std::string, std::string > arg)
 

Protected Member Functions

virtual bool setParent (BaseElement *newParent)
 Change this node's parent. Note that this method is protected as it should be called by the parent's addChild/removeChild methods. More...
 

Attribute details

◆ replaceAttribute

std::map< std::string, std::string > sofa::simulation::xml::BaseElement::replaceAttribute
protected

Constructor details

◆ BaseElement()

sofa::simulation::xml::BaseElement::BaseElement ( const std::string &  name,
const std::string &  type,
BaseElement newParent = nullptr 
)

◆ ~BaseElement()

sofa::simulation::xml::BaseElement::~BaseElement ( )
override

Function details

◆ addChild()

bool sofa::simulation::xml::BaseElement::addChild ( BaseElement child)
virtual

◆ addReplaceAttribute()

void sofa::simulation::xml::BaseElement::addReplaceAttribute ( const std::string &  attr,
const char val 
)
virtual

List of parameters to be replaced.

◆ begin() [1/2]

template<class Node >
child_iterator<Node> sofa::simulation::xml::BaseElement::begin ( )
inline

◆ begin() [2/2]

child_iterator<BaseElement> sofa::simulation::xml::BaseElement::begin ( )
inline

◆ Create()

BaseElement * sofa::simulation::xml::BaseElement::Create ( const std::string &  nodeClass,
const std::string &  name,
const std::string &  type 
)
static

◆ create()

template<class Node >
static Node* sofa::simulation::xml::BaseElement::create ( Node ,
std::pair< std::string, std::string >  arg 
)
inlinestatic

◆ end() [1/2]

template<class Node >
child_iterator<Node> sofa::simulation::xml::BaseElement::end ( )
inline

◆ end() [2/2]

child_iterator<BaseElement> sofa::simulation::xml::BaseElement::end ( )
inline

◆ find()

BaseObjectDescription* sofa::simulation::xml::BaseElement::find ( const char nodeName,
bool  absolute = false 
)
inlineoverridevirtual

Find a node given its name.

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ findNode()

BaseElement * sofa::simulation::xml::BaseElement::findNode ( const char nodeName,
bool  absolute = false 
)
virtual

Find a node given its name.

◆ getBaseFile()

std::string sofa::simulation::xml::BaseElement::getBaseFile ( )
overridevirtual

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

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ getClass()

virtual const char* sofa::simulation::xml::BaseElement::getClass ( ) const
pure virtual

◆ getIncludeNodeType()

IncludeNodeType sofa::simulation::xml::BaseElement::getIncludeNodeType ( ) const
inline

Return if the current element ifsa special group node from an included file.

◆ getName()

std::string sofa::simulation::xml::BaseElement::getName ( )
inlineoverridevirtual

Get the node instance name.

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ getObject()

◆ getParent()

sofa::core::objectmodel::BaseObjectDescription* sofa::simulation::xml::BaseElement::getParent ( ) const
inlineoverridevirtual

Get the parent node.

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ getParentElement()

BaseElement* sofa::simulation::xml::BaseElement::getParentElement ( ) const
inline

Get the parent node.

◆ getSrcFile()

const std::string & sofa::simulation::xml::BaseElement::getSrcFile ( ) const

◆ getSrcLine()

int sofa::simulation::xml::BaseElement::getSrcLine ( ) const

◆ getType()

std::string sofa::simulation::xml::BaseElement::getType ( )
inline

Get the node instance type (MassObject, IdentityMapping, ...)

◆ init()

bool sofa::simulation::xml::BaseElement::init ( void  )
virtual

◆ initNode()

◆ isFileRoot()

bool sofa::simulation::xml::BaseElement::isFileRoot ( )

Return true if this element was the root of the file.

◆ presenceAttribute()

bool sofa::simulation::xml::BaseElement::presenceAttribute ( const std::string &  s)
virtual

Verify the presence of an attribute.

◆ pushNamedObjects()

template<class Map >
void sofa::simulation::xml::BaseElement::pushNamedObjects ( Map &  result)
inline

Get all objects of a given type.

◆ pushObjects()

template<class Sequence >
void sofa::simulation::xml::BaseElement::pushObjects ( Sequence &  result)
inline

Get all objects of a given type.

◆ removeAttribute()

bool sofa::simulation::xml::BaseElement::removeAttribute ( const std::string &  attr)
overridevirtual

Remove an attribute. Fails if this attribute is "name" or "type".

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ removeChild()

bool sofa::simulation::xml::BaseElement::removeChild ( BaseElement child)
virtual

◆ setBaseFile()

void sofa::simulation::xml::BaseElement::setBaseFile ( const std::string &  newBaseFile)
virtual

◆ setIncludeNodeType()

void sofa::simulation::xml::BaseElement::setIncludeNodeType ( IncludeNodeType  t)
inline

Specify that the current element is a special group node from an included file.

◆ setName()

virtual void sofa::simulation::xml::BaseElement::setName ( const std::string &  name)
inlineoverridevirtual

Set the object instance name.

Reimplemented from sofa::core::objectmodel::BaseObjectDescription.

◆ setParent()

virtual bool sofa::simulation::xml::BaseElement::setParent ( BaseElement newParent)
inlineprotectedvirtual

Change this node's parent. Note that this method is protected as it should be called by the parent's addChild/removeChild methods.

Reimplemented in sofa::simulation::xml::NodeElement.

◆ setSrcFile()

void sofa::simulation::xml::BaseElement::setSrcFile ( const std::string &  newSrcFile)
virtual

◆ setSrcLine()

void sofa::simulation::xml::BaseElement::setSrcLine ( const int  l)
virtual

◆ setType()

virtual void sofa::simulation::xml::BaseElement::setType ( const std::string &  newType)
inlinevirtual