sofa::simulation::tree::xml::BaseElement Class Reference

#include <BaseElement.h>

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

Inheritance graph
[legend]
Collaboration diagram for sofa::simulation::tree::xml::BaseElement:

Collaboration graph
[legend]

Data Structures

class  child_iterator

Public Types

typedef helper::Factory
< std::string, BaseElement,
std::pair< std::string,
std::string > > 
NodeFactory

Public Member Functions

 BaseElement (const std::string &name, const std::string &type, BaseElement *newParent=NULL)
virtual ~BaseElement ()
virtual const char * getClass () const =0
 Get the node class (Scene, Mapping, ...).
std::string getName ()
 Get the associated object.
virtual void setName (const std::string &newName)
std::string getType ()
 Get the node instance type (MassObject, IdentityMapping, ...).
virtual void setType (const std::string &newType)
sofa::core::objectmodel::BaseObjectDescription * getParent () const
 Get the parent node.
BaseElement * getParentElement () const
 Get the parent node.
std::string getBaseFile ()
 Get the file where this description was read from. Useful to resolve relative file paths.
virtual void setBaseFile (const std::string &newBaseFile)
bool isFileRoot ()
 Return true if this element was the root of the file.
bool isGroupType ()
 Return true if this element was a special group node from an included file.
void setGroupType (bool b)
 Specify that the current element if a special group node from an included file.
virtual void setAttribute (const std::string &attr, const char *val)
 Set an attribute. Override any existing value.
virtual bool presenceAttribute (const std::string &s)
 Verify the presence of an attribute.
virtual bool removeAttribute (const std::string &attr)
 Remove an attribute. Fails if this attribute is "name" or "type".
virtual BaseElement * findNode (const char *nodeName, bool absolute=false)
 Find a node given its name.
virtual BaseObjectDescription * find (const char *nodeName, bool absolute=false)
 Find a node given its name.
template<class Sequence >
void pushObjects (Sequence &result)
 Get all objects of a given type.
template<class Map >
void pushNamedObjects (Map &result)
 Get all objects of a given type.
virtual bool addChild (BaseElement *child)
virtual bool removeChild (BaseElement *child)
virtual bool initNode ()=0
virtual bool init ()
template<class Node >
child_iterator< Node > begin ()
child_iterator< BaseElement > begin ()
template<class Node >
child_iterator< Node > end ()
child_iterator< BaseElement > end ()

Static Public Member Functions

static BaseElement * Create (const std::string &nodeClass, const std::string &name, const std::string &type)
template<class Node >
static void create (Node *&obj, 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.

Private Types

typedef std::list< BaseElement * > ChildList

Private Attributes

std::string basefile
BaseElement * parent
ChildList children
bool groupType

Detailed Description

Definition at line 49 of file BaseElement.h.


Member Typedef Documentation

Definition at line 57 of file BaseElement.h.

typedef helper::Factory< std::string, BaseElement, std::pair<std::string, std::string> > sofa::simulation::tree::xml::BaseElement::NodeFactory

Definition at line 227 of file BaseElement.h.


Constructor & Destructor Documentation

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

Definition at line 41 of file BaseElement.cpp.

References addChild().

sofa::simulation::tree::xml::BaseElement::~BaseElement (  )  [virtual]

Definition at line 49 of file BaseElement.cpp.

References children.


Member Function Documentation

bool sofa::simulation::tree::xml::BaseElement::addChild ( BaseElement *  child  )  [virtual]

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

Definition at line 211 of file BaseElement.h.

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

template<class Node >
static void sofa::simulation::tree::xml::BaseElement::create ( Node *&  obj,
std::pair< std::string, std::string >  arg 
) [inline, static]

Definition at line 232 of file BaseElement.h.

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

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

Definition at line 222 of file BaseElement.h.

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

virtual BaseObjectDescription* sofa::simulation::tree::xml::BaseElement::find ( const char *  nodeName,
bool  absolute = false 
) [inline, virtual]

Find a node given its name.

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

Definition at line 129 of file BaseElement.h.

References findNode().

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

Find a node given its name.

Definition at line 161 of file BaseElement.cpp.

References begin(), end(), findNode(), and getParentElement().

Referenced by find(), and findNode().

std::string sofa::simulation::tree::xml::BaseElement::getBaseFile (  )  [virtual]

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

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

Definition at line 62 of file BaseElement.cpp.

References basefile, getBaseFile(), getParentElement(), and isFileRoot().

Referenced by getBaseFile().

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

std::string sofa::simulation::tree::xml::BaseElement::getName (  )  [inline, virtual]

sofa::core::objectmodel::BaseObjectDescription* sofa::simulation::tree::xml::BaseElement::getParent (  )  const [inline, virtual]

Get the parent node.

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

Definition at line 86 of file BaseElement.h.

References parent.

Referenced by addChild(), sofa::simulation::tree::xml::ObjectElement::initNode(), and removeChild().

BaseElement* sofa::simulation::tree::xml::BaseElement::getParentElement (  )  const [inline]

std::string sofa::simulation::tree::xml::BaseElement::getType (  )  [inline]

bool sofa::simulation::tree::xml::BaseElement::init ( void   )  [virtual]

virtual bool sofa::simulation::tree::xml::BaseElement::initNode (  )  [pure virtual]

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

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

Definition at line 75 of file BaseElement.cpp.

References basefile.

Referenced by getBaseFile().

bool sofa::simulation::tree::xml::BaseElement::isGroupType (  )  [inline]

Return true if this element was a special group node from an included file.

Definition at line 102 of file BaseElement.h.

References groupType.

Referenced by sofa::simulation::tree::xml::createNode(), and sofa::simulation::tree::xml::includeNode().

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

Verify the presence of an attribute.

Definition at line 96 of file BaseElement.cpp.

References sofa::core::objectmodel::BaseObjectDescription::attributes.

Referenced by sofa::gui::qt::GraphModeler::updatePresetNode().

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

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

Get all objects of a given type.

Definition at line 136 of file BaseElement.h.

References begin(), end(), and sofa::core::objectmodel::BaseObjectDescription::getObject().

bool sofa::simulation::tree::xml::BaseElement::removeAttribute ( const std::string &  attr  )  [virtual]

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

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

Definition at line 101 of file BaseElement.cpp.

References sofa::core::objectmodel::BaseObjectDescription::attributes.

bool sofa::simulation::tree::xml::BaseElement::removeChild ( BaseElement *  child  )  [virtual]

Definition at line 128 of file BaseElement.cpp.

References children, getParent(), and setParent().

Referenced by addChild(), and sofa::simulation::tree::xml::createNode().

void sofa::simulation::tree::xml::BaseElement::setAttribute ( const std::string &  attr,
const char *  val 
) [virtual]

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

Definition at line 69 of file BaseElement.cpp.

References basefile.

Referenced by sofa::simulation::tree::xml::createNode().

void sofa::simulation::tree::xml::BaseElement::setGroupType ( bool  b  )  [inline]

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

Definition at line 105 of file BaseElement.h.

References groupType.

Referenced by sofa::simulation::tree::xml::includeNode().

virtual void sofa::simulation::tree::xml::BaseElement::setName ( const std::string &  newName  )  [inline, virtual]

virtual bool sofa::simulation::tree::xml::BaseElement::setParent ( BaseElement *  newParent  )  [inline, protected, virtual]

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::tree::xml::NodeElement.

Definition at line 160 of file BaseElement.h.

References parent.

Referenced by addChild(), and removeChild().

virtual void sofa::simulation::tree::xml::BaseElement::setType ( const std::string &  newType  )  [inline, virtual]


Field Documentation

Definition at line 55 of file BaseElement.h.

Referenced by getBaseFile(), init(), isFileRoot(), and setBaseFile().

Definition at line 59 of file BaseElement.h.

Referenced by isGroupType(), and setGroupType().

Definition at line 56 of file BaseElement.h.

Referenced by getParent(), getParentElement(), and setParent().


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

Generated on Sun Nov 23 04:24:40 2008 for Sofa by  doxygen 1.5.7.1