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]

Detailed Description

Definition at line 57 of file BaseElement.h.


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::BaseObjectDescriptiongetParent () const
 Get the parent node.
BaseElementgetParentElement () 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.
virtual void setAttribute (const std::string &attr, const char *val)
 Set an attribute. Override any existing value.
virtual bool removeAttribute (const std::string &attr)
 Remove an attribute. Fails if this attribute is "name" or "type".
virtual BaseElementfindNode (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 BaseElementCreate (const std::string &nodeClass, const std::string &name, const std::string &type)

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
BaseElementparent
ChildList children

Data Structures

class  child_iterator

Member Typedef Documentation

typedef std::list<BaseElement*> sofa::simulation::tree::xml::BaseElement::ChildList [private]

Definition at line 65 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 225 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

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

Get the node class (Scene, Mapping, ...).

Implemented in sofa::simulation::tree::xml::AttributeElement, sofa::simulation::tree::xml::DataElement, sofa::simulation::tree::xml::NodeElement, and sofa::simulation::tree::xml::ObjectElement.

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

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

Get the associated object.

Get the node instance name

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

Definition at line 79 of file BaseElement.h.

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

Referenced by sofa::simulation::tree::xml::createNode(), sofa::simulation::tree::xml::dumpNode(), sofa::simulation::tree::xml::ObjectElement::initNode(), sofa::simulation::tree::xml::Element< Object >::initNode(), and sofa::simulation::tree::xml::recReplaceAttribute().

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

Definition at line 82 of file BaseElement.h.

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

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

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

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

Definition at line 86 of file BaseElement.h.

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

Referenced by sofa::component::topology::create(), sofa::simulation::tree::xml::createNode(), sofa::simulation::tree::xml::createWith2Objects(), sofa::simulation::tree::xml::createWith2ObjectsAndFilename(), sofa::simulation::tree::xml::createWithFilename(), sofa::simulation::tree::xml::createWithParentAndFilename(), and sofa::simulation::tree::xml::dumpNode().

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

Definition at line 89 of file BaseElement.h.

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

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 93 of file BaseElement.h.

References parent.

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

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

Get the parent node.

Definition at line 97 of file BaseElement.h.

References parent.

Referenced by addChild(), findNode(), getBaseFile(), sofa::simulation::tree::xml::NodeElement::initNode(), sofa::simulation::tree::xml::DataElement::initNode(), and sofa::simulation::tree::xml::AttributeElement::initNode().

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().

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().

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().

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

Set an attribute. Override any existing value.

Definition at line 91 of file BaseElement.cpp.

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

Referenced by sofa::simulation::tree::xml::createNode(), sofa::simulation::tree::xml::AttributeElement::initNode(), and sofa::simulation::tree::xml::recReplaceAttribute().

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 97 of file BaseElement.cpp.

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

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

Find a node given its name.

Definition at line 157 of file BaseElement.cpp.

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

Referenced by find(), and findNode().

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 127 of file BaseElement.h.

References findNode().

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

Get all objects of a given type.

Definition at line 134 of file BaseElement.h.

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

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

Get all objects of a given type.

Definition at line 145 of file BaseElement.h.

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

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 158 of file BaseElement.h.

References parent.

Referenced by addChild(), and removeChild().

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

Definition at line 111 of file BaseElement.cpp.

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

Referenced by BaseElement(), sofa::simulation::tree::xml::createNode(), and sofa::simulation::tree::xml::NodeElement::initNode().

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

Definition at line 124 of file BaseElement.cpp.

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

Referenced by addChild().

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

Implemented in sofa::simulation::tree::xml::AttributeElement, sofa::simulation::tree::xml::DataElement, sofa::simulation::tree::xml::Element< Object >, sofa::simulation::tree::xml::NodeElement, sofa::simulation::tree::xml::ObjectElement, sofa::simulation::tree::xml::Element< sofa::core::objectmodel::BaseNode >, and sofa::simulation::tree::xml::Element< sofa::core::objectmodel::BaseObject >.

Referenced by init().

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

Reimplemented in sofa::simulation::tree::xml::AttributeElement, sofa::simulation::tree::xml::NodeElement, and sofa::simulation::tree::xml::ObjectElement.

Definition at line 140 of file BaseElement.cpp.

References basefile, begin(), end(), and initNode().

Referenced by sofa::simulation::tree::Simulation::load(), and sofa::gui::qt::RealGUI::loadObject().

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

Definition at line 204 of file BaseElement.h.

References children.

Referenced by sofa::simulation::tree::xml::dumpNode(), findNode(), sofa::simulation::tree::xml::ObjectElement::init(), init(), sofa::simulation::tree::xml::AttributeElement::init(), pushNamedObjects(), pushObjects(), and sofa::simulation::tree::xml::recReplaceAttribute().

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

Definition at line 209 of file BaseElement.h.

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

Definition at line 215 of file BaseElement.h.

References children.

Referenced by sofa::simulation::tree::xml::dumpNode(), findNode(), sofa::simulation::tree::xml::ObjectElement::init(), init(), sofa::simulation::tree::xml::AttributeElement::init(), pushNamedObjects(), pushObjects(), and sofa::simulation::tree::xml::recReplaceAttribute().

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

Definition at line 220 of file BaseElement.h.

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

Definition at line 151 of file BaseElement.cpp.

References sofa::helper::Factory< TKey, TObject, TArgument >::CreateObject().

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


Field Documentation

std::string sofa::simulation::tree::xml::BaseElement::basefile [private]

Definition at line 63 of file BaseElement.h.

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

BaseElement* sofa::simulation::tree::xml::BaseElement::parent [private]

Definition at line 64 of file BaseElement.h.

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

ChildList sofa::simulation::tree::xml::BaseElement::children [private]

Definition at line 66 of file BaseElement.h.

Referenced by addChild(), begin(), sofa::simulation::tree::xml::BaseElement::child_iterator< Node >::checkIt(), end(), removeChild(), and ~BaseElement().


The documentation for this class was generated from the following files:
Generated on Mon May 5 23:42:11 2008 for Sofa by  doxygen 1.5.3