sofa::core::objectmodel::Base Class Reference

#include <Base.h>

Inheritance diagram for sofa::core::objectmodel::Base:

Inheritance graph
[legend]
Collaboration diagram for sofa::core::objectmodel::Base:

Collaboration graph
[legend]

Detailed Description

Base class for everything This class contains all functionnality shared by every objects in SOFA. Most importantly it defines how to retrieve information about an object (name, type, fields).

Definition at line 53 of file Base.h.


Public Member Functions

 Base ()
virtual ~Base ()
std::string getName () const
 Accessor to the object name.
void setName (const std::string &n)
 Set the name of this object.
virtual std::string getTypeName () const
 Get the type name of this object (i.e. class and template types).
virtual std::string getClassName () const
 Get the class name of this object.
virtual std::string getTemplateName () const
 Get the template type names (if any) used to instantiate this object.
void parseFields (std::list< std::string > str)
 Assign the field values stored in the given list of name + value pairs of strings.
virtual void parseFields (const std::map< std::string, std::string * > &str)
 Assign the field values stored in the given map of name -> value pairs.
void writeDatas (std::map< std::string, std::string * > &str)
 Write the current field values to the given map of name -> value pairs.
void writeDatas (std::ostream &out)
 Write the current field values to the given text output stream.
void xmlWriteNodeDatas (std::ostream &out, unsigned level)
 Write the current Node values to the given XML output stream.
void xmlWriteDatas (std::ostream &out, unsigned level)
 Write the current field values to the given XML output stream.
unsigned int findField (const char *name) const
 Find a field give its name, if not found, the index is the size of the vector.
unsigned int findField (const std::string &name) const
template<class T>
Data< T > initData (Data< T > *field, const char *name, const char *help)
 Helper method used to initialize a field containing a value of type T.
template<class T>
Data< T > initData (Data< T > *field, const T &value, const char *name, const char *help)
 Helper method used to initialize a field containing a value of type T.
template<class T>
DataPtr< T > initDataPtr (DataPtr< T > *field, T *ptr, const char *name, const char *help)
 Helper method used to initialize a field pointing to a value of type T.
virtual void parse (BaseObjectDescription *arg)
 Parse the given description to assign values to this object's fields and potentially other parameters.
std::vector
< std::pair
< std::string,
BaseData * > > 
getFields ()
 Accessor to the map containing all the fields of this object.

Static Public Member Functions

static std::string decodeTypeName (const std::type_info &t)
 Helper method to decode the type name to a more readable form if possible.
static std::string decodeClassName (const std::type_info &t)
 Helper method to extract the class name (removing namespaces and templates).
static std::string decodeNamespaceName (const std::type_info &t)
 Helper method to extract the namespace (removing class name and templates).
static std::string decodeTemplateName (const std::type_info &t)
 Helper method to extract the template name (removing namespaces and class name).
template<class T>
static std::string typeName (const T *=NULL)
 Helper method to get the type name of a type derived from this class.
template<class T>
static std::string className (const T *=NULL)
 Helper method to get the class name of a type derived from this class.
template<class T>
static std::string namespaceName (const T *=NULL)
 Helper method to get the namespace name of a type derived from this class.
template<class T>
static std::string templateName (const T *=NULL)
 Helper method to get the template name of a type derived from this class.

Data Fields

Data< std::string > name
 Name of the object.

Protected Member Functions

void addField (BaseData *f, const char *name)
 Add a field. Note that this method should only be called if the field was not initialized with the initData<T> of field<T> methods.

Protected Attributes

std::vector
< std::pair
< std::string,
BaseData * > > 
m_fieldVec
 name -> Field object

Constructor & Destructor Documentation

sofa::core::objectmodel::Base::Base (  ) 

Definition at line 55 of file Base.cpp.

References initData(), and name.

sofa::core::objectmodel::Base::~Base (  )  [virtual]

Definition at line 60 of file Base.cpp.


Member Function Documentation

std::string sofa::core::objectmodel::Base::getName (  )  const

Accessor to the object name.

Definition at line 63 of file Base.cpp.

References sofa::core::objectmodel::Data< T >::getValue(), and name.

Referenced by sofa::gui::qt::GraphListenerQListView::addChild(), sofa::component::collision::BruteForceDetection::addCollisionPair(), sofa::gui::qt::GraphListenerQListView::addObject(), sofa::component::collision::DefaultContactManager::createContacts(), sofa::component::collision::DefaultPipeline::doCollisionDetection(), sofa::component::collision::DefaultPipeline::doCollisionResponse(), sofa::simulation::tree::Simulation::getInstruments(), sofa::simulation::tree::ExportDotVisitor::getName(), OgreVisualModel::getOgreName(), sofa::simulation::tree::GNode::getPathName(), sofa::gui::qt::RealGUI::graphCreateStats(), sofa::gui::qt::RealGUI::graphModify(), sofa::core::objectmodel::BaseObject::handleEvent(), sofa::component::forcefield::TriangleFEMForceField< DataTypes >::init(), sofa::component::forcefield::HexahedronFEMForceField< DataTypes >::init(), sofa::component::collision::TriangularFEMFractureManager::init(), sofa::simulation::tree::PrintVisitor::processNodeTopDown(), sofa::simulation::tree::ExportDotVisitor::processNodeTopDown(), sofa::simulation::tree::ExportDotVisitor::processObject(), sofa::simulation::tree::AnimateVisitor::processOdeSolver(), sofa::simulation::tree::ExportOBJVisitor::processVisualModel(), SofaFlowVR::FlowVRRenderMesh::renderUpdate(), sofa::gui::qt::ModifyObject::setNode(), sofa::simulation::tree::GNode::updateContext(), sofa::simulation::tree::GNode::updateSimulationContext(), sofa::simulation::tree::GNode::updateVisualContext(), and sofa::component::ArticulatedBody::vOp().

void sofa::core::objectmodel::Base::setName ( const std::string &  n  ) 

Set the name of this object.

Definition at line 70 of file Base.cpp.

References name, and sofa::core::objectmodel::Data< T >::setValue().

Referenced by sofa::filemanager::pml::LMLReader::BuildStructure(), sofa::component::collision::DefaultContactManager::createContacts(), sofa::simulation::tree::GNode::GNode(), sofa::gui::fltk::FLTKviewer::handle(), sofa::simulation::tree::xml::ObjectElement::initNode(), sofa::filemanager::pml::LMLConstraint< DataTypes >::LMLConstraint(), sofa::filemanager::pml::LMLForce< DataTypes >::LMLForce(), main(), sofa::gui::qt::viewer::SofaViewer::mouseEvent(), sofa::gui::glut::SimpleGUI::mouseEvent(), and sofa::filemanager::pml::LMLReader::updateStructure().

virtual std::string sofa::core::objectmodel::Base::getTypeName (  )  const [inline, virtual]

Get the type name of this object (i.e. class and template types).

Definition at line 69 of file Base.h.

References decodeTypeName().

Referenced by sofa::core::objectmodel::BaseObject::handleEvent(), sofa::component::forcefield::HexahedronFEMForceField< DataTypes >::init(), and sofa::gui::qt::ModifyObject::setNode().

virtual std::string sofa::core::objectmodel::Base::getClassName (  )  const [inline, virtual]

Get the class name of this object.

Definition at line 75 of file Base.h.

References decodeClassName().

Referenced by sofa::component::collision::DefaultContactManager::createContacts(), sofa::gpu::cuda::CudaCollisionDetection::createTest(), SofaFlowVR::FlowVRInputMesh::flowvrBeginIteration(), sofa::gpu::cuda::CudaCollisionDetection::PointRigidTest::PointRigidTest(), sofa::gpu::cuda::CudaCollisionDetection::RigidRigidTest::RigidRigidTest(), and sofa::gpu::cuda::CudaCollisionDetection::SphereRigidTest::SphereRigidTest().

virtual std::string sofa::core::objectmodel::Base::getTemplateName (  )  const [inline, virtual]

Get the template type names (if any) used to instantiate this object.

Reimplemented in sofa::core::componentmodel::behavior::Constraint< DataTypes >, sofa::core::componentmodel::behavior::ForceField< TDataTypes >, sofa::core::componentmodel::behavior::MechanicalState< TDataTypes >, sofa::core::componentmodel::behavior::MixedInteractionForceField< TDataTypes1, TDataTypes2 >, sofa::core::componentmodel::behavior::PairInteractionForceField< TDataTypes >, sofa::component::ArticulatedBody, sofa::component::collision::ContactCorrection< TDataTypes >, sofa::component::forcefield::HexahedronFEMForceFieldAndMass< DataTypes >, sofa::component::misc::ReadState< DataTypes >, sofa::component::misc::WriteState< DataTypes >, sofa::component::topology::PointSetTopology< DataTypes >, sofa::core::componentmodel::behavior::Constraint< sofa::component::ArticulatedBody >, sofa::core::componentmodel::behavior::ForceField< sofa::defaulttype::StdVectorTypes >, sofa::core::componentmodel::behavior::ForceField< sofa::defaulttype::SolidTypes< float > >, sofa::core::componentmodel::behavior::ForceField< sofa::defaulttype::SolidTypes< R > >, sofa::core::componentmodel::behavior::ForceField< DataTypes >, sofa::core::componentmodel::behavior::MechanicalState< sofa::component::ArticulatedBody >, sofa::core::componentmodel::behavior::MechanicalState< Rigid3dTypes >, sofa::core::componentmodel::behavior::MechanicalState< sofa::gpu::cuda::CudaVectorTypes >, sofa::core::componentmodel::behavior::MechanicalState< In >, sofa::core::componentmodel::behavior::MechanicalState< sofa::defaulttype::SolidTypes >, sofa::core::componentmodel::behavior::MechanicalState< sofa::defaulttype::StdVectorTypes >, sofa::core::componentmodel::behavior::MechanicalState< LMTypes >, sofa::core::componentmodel::behavior::MechanicalState< DataTypes2 >, sofa::core::componentmodel::behavior::MechanicalState< Rigid3Types >, sofa::core::componentmodel::behavior::MechanicalState< sofa::defaulttype::StdVectorTypes< TCoord, TDeriv, TReal > >, sofa::core::componentmodel::behavior::MechanicalState< DataTypes1 >, sofa::core::componentmodel::behavior::MechanicalState< DataTypes >, sofa::core::componentmodel::behavior::MixedInteractionForceField< DataTypes1, DataTypes2 >, sofa::core::componentmodel::behavior::PairInteractionForceField< CudaVec3fTypes >, sofa::core::componentmodel::behavior::PairInteractionForceField< sofa::defaulttype::StdVectorTypes< TCoord, TDeriv, TReal > >, sofa::core::componentmodel::behavior::PairInteractionForceField< DataTypes >, and sofa::component::topology::PointSetTopology< In >.

Definition at line 81 of file Base.h.

References decodeTemplateName().

std::string sofa::core::objectmodel::Base::decodeTypeName ( const std::type_info &  t  )  [static]

Helper method to decode the type name to a more readable form if possible.

Decode the type's name to a more readable form if possible.

Definition at line 77 of file Base.cpp.

References name.

Referenced by sofa::gpu::cuda::CudaMatrix< T >::copyToDevice(), sofa::gpu::cuda::CudaVector< CubeData >::copyToDevice(), sofa::gpu::cuda::CudaMatrix< T >::copyToHost(), sofa::gpu::cuda::CudaVector< CubeData >::copyToHost(), sofa::core::objectmodel::FieldBase::decodeTypeName(), sofa::core::objectmodel::BaseData::decodeTypeName(), getTypeName(), and typeName().

std::string sofa::core::objectmodel::Base::decodeClassName ( const std::type_info &  t  )  [static]

Helper method to extract the class name (removing namespaces and templates).

Extract the class name (removing namespaces and templates).

Definition at line 155 of file Base.cpp.

References name.

Referenced by className(), and getClassName().

std::string sofa::core::objectmodel::Base::decodeNamespaceName ( const std::type_info &  t  )  [static]

Helper method to extract the namespace (removing class name and templates).

Extract the namespace (removing class name and templates).

Definition at line 223 of file Base.cpp.

References name.

Referenced by projects::generateFactoryPHPDoc(), and namespaceName().

std::string sofa::core::objectmodel::Base::decodeTemplateName ( const std::type_info &  t  )  [static]

Helper method to extract the template name (removing namespaces and class name).

Decode the template name (removing namespaces and class name).

Definition at line 262 of file Base.cpp.

References name.

Referenced by getTemplateName(), and templateName().

template<class T>
static std::string sofa::core::objectmodel::Base::typeName ( const T *  = NULL  )  [inline, static]

Helper method to get the type name of a type derived from this class.

This method should be used as follow :

 T* ptr = NULL; std::string type = T::typeName(ptr); 
This way derived classes can redefine the typeName method

Definition at line 104 of file Base.h.

References decodeTypeName().

template<class T>
static std::string sofa::core::objectmodel::Base::className ( const T *  = NULL  )  [inline, static]

Helper method to get the class name of a type derived from this class.

This method should be used as follow :

 T* ptr = NULL; std::string type = T::className(ptr); 
This way derived classes can redefine the className method

Definition at line 115 of file Base.h.

References decodeClassName().

Referenced by sofa::component::topology::Tetra2TriangleTopologicalMapping< TIn, TOut >::canCreate(), and sofa::core::Mapping< In, Out >::canCreate().

template<class T>
static std::string sofa::core::objectmodel::Base::namespaceName ( const T *  = NULL  )  [inline, static]

Helper method to get the namespace name of a type derived from this class.

This method should be used as follow :

 T* ptr = NULL; std::string type = T::namespaceName(ptr); 
This way derived classes can redefine the namespaceName method

Definition at line 126 of file Base.h.

References decodeNamespaceName().

template<class T>
static std::string sofa::core::objectmodel::Base::templateName ( const T *  = NULL  )  [inline, static]

Helper method to get the template name of a type derived from this class.

This method should be used as follow :

 T* ptr = NULL; std::string type = T::templateName(ptr); 
This way derived classes can redefine the templateName method

Definition at line 137 of file Base.h.

References decodeTemplateName().

void sofa::core::objectmodel::Base::parseFields ( std::list< std::string >  str  ) 

Assign the field values stored in the given list of name + value pairs of strings.

Definition at line 337 of file Base.cpp.

References findField(), m_fieldVec, and name.

void sofa::core::objectmodel::Base::parseFields ( const std::map< std::string, std::string * > &  str  )  [virtual]

Assign the field values stored in the given map of name -> value pairs.

Definition at line 357 of file Base.cpp.

References findField(), key, and m_fieldVec.

void sofa::core::objectmodel::Base::writeDatas ( std::map< std::string, std::string * > &  str  ) 

Write the current field values to the given map of name -> value pairs.

Definition at line 394 of file Base.cpp.

References sofa::core::objectmodel::BaseData::getValueString(), and m_fieldVec.

void sofa::core::objectmodel::Base::writeDatas ( std::ostream &  out  ) 

Write the current field values to the given text output stream.

Definition at line 409 of file Base.cpp.

References sofa::core::objectmodel::BaseData::getValueString(), sofa::core::objectmodel::BaseData::isSet(), and m_fieldVec.

void sofa::core::objectmodel::Base::xmlWriteNodeDatas ( std::ostream &  out,
unsigned  level 
)

Write the current Node values to the given XML output stream.

Definition at line 420 of file Base.cpp.

References sofa::core::objectmodel::BaseData::getValueString(), sofa::core::objectmodel::BaseData::isSet(), and m_fieldVec.

Referenced by sofa::simulation::tree::XMLPrintVisitor::processNodeTopDown().

void sofa::core::objectmodel::Base::xmlWriteDatas ( std::ostream &  out,
unsigned  level 
)

Write the current field values to the given XML output stream.

Definition at line 432 of file Base.cpp.

References sofa::core::objectmodel::BaseData::getValueString(), sofa::core::objectmodel::BaseData::isSet(), and m_fieldVec.

unsigned int sofa::core::objectmodel::Base::findField ( const char *  name  )  const [inline]

Find a field give its name, if not found, the index is the size of the vector.

Definition at line 161 of file Base.h.

References m_fieldVec.

Referenced by addField(), initData(), initDataPtr(), and parseFields().

unsigned int sofa::core::objectmodel::Base::findField ( const std::string &  name  )  const [inline]

Definition at line 171 of file Base.h.

References m_fieldVec.

template<class T>
Data<T> sofa::core::objectmodel::Base::initData ( Data< T > *  field,
const char *  name,
const char *  help 
) [inline]

Helper method used to initialize a field containing a value of type T.

Definition at line 182 of file Base.h.

References findField(), and m_fieldVec.

Referenced by Base(), sofa::core::componentmodel::behavior::Mass< DataTypes >::Mass(), and sofa::component::mass::MatrixMass< DataTypes, MassType >::MatrixMass().

template<class T>
Data<T> sofa::core::objectmodel::Base::initData ( Data< T > *  field,
const T &  value,
const char *  name,
const char *  help 
) [inline]

Helper method used to initialize a field containing a value of type T.

Definition at line 197 of file Base.h.

References findField(), and m_fieldVec.

template<class T>
DataPtr<T> sofa::core::objectmodel::Base::initDataPtr ( DataPtr< T > *  field,
T *  ptr,
const char *  name,
const char *  help 
) [inline]

Helper method used to initialize a field pointing to a value of type T.

Definition at line 212 of file Base.h.

References findField(), and m_fieldVec.

void sofa::core::objectmodel::Base::parse ( BaseObjectDescription arg  )  [virtual]

Parse the given description to assign values to this object's fields and potentially other parameters.

Reimplemented in sofa::component::collision::DistanceOctreeCollisionModel, sofa::component::container::ArticulatedHierarchyContainer, sofa::component::contextobject::CoordinateSystem, sofa::component::forcefield::HexahedronFEMForceField< DataTypes >, sofa::component::forcefield::MeshSpringForceField< DataTypes >, sofa::component::forcefield::RegularGridSpringForceField< DataTypes >, sofa::component::forcefield::SparseGridSpringForceField< DataTypes >, sofa::component::forcefield::SpringForceField< DataTypes >, sofa::component::forcefield::TetrahedralCorotationalFEMForceField< DataTypes >, sofa::component::forcefield::TetrahedronFEMForceField< DataTypes >, sofa::component::mapping::ImplicitSurfaceMapping< In, Out >, sofa::component::mapping::RigidMapping< BasicMapping >, sofa::component::mapping::RigidRigidMapping< BasicMapping >, sofa::component::mapping::SkinningMapping< BasicMapping >, sofa::component::mass::DiagonalMass< DataTypes, MassType >, sofa::component::mass::UniformMass< DataTypes, MassType >, sofa::component::MechanicalObject< DataTypes >, sofa::component::odesolver::BiCGStabImplicitSolver, sofa::component::topology::CubeTopology, sofa::component::topology::GridTopology, sofa::component::topology::MeshTopology, sofa::component::topology::PointSetTopology< DataTypes >, sofa::component::topology::RegularGridTopology, sofa::component::visualmodel::VisualModelImpl, SofaFlowVR::FlowVRRenderMesh, sofa::component::forcefield::MeshSpringForceField< sofa::defaulttype::StdVectorTypes >, sofa::component::forcefield::SpringForceField< sofa::defaulttype::StdVectorTypes< TCoord, TDeriv, TReal > >, sofa::component::MechanicalObject< In >, sofa::component::MechanicalObject< sofa::gpu::cuda::CudaVec3Types >, sofa::component::MechanicalObject< sofa::defaulttype::StdVectorTypes >, sofa::component::MechanicalObject< LMTypes >, sofa::component::MechanicalObject< Rigid3Types >, sofa::component::MechanicalObject< TDataTypes >, sofa::component::topology::PointSetTopology< In >, sofa::component::mass::UniformMass< DataTypes, MassType >, sofa::component::mass::UniformMass< DataTypes, MassType >, sofa::component::mass::UniformMass< DataTypes, MassType >, and sofa::component::mass::UniformMass< DataTypes, MassType >.

Definition at line 379 of file Base.cpp.

References sofa::core::objectmodel::BaseObjectDescription::getAttribute(), and m_fieldVec.

Referenced by sofa::simulation::tree::create().

std::vector< std::pair<std::string, BaseData*> > sofa::core::objectmodel::Base::getFields (  )  [inline]

Accessor to the map containing all the fields of this object.

Definition at line 230 of file Base.h.

References m_fieldVec.

Referenced by sofa::gui::qt::ModifyObject::setNode(), and sofa::gui::qt::ModifyObject::updateValues().

void sofa::core::objectmodel::Base::addField ( BaseData f,
const char *  name 
) [inline, protected]

Add a field. Note that this method should only be called if the field was not initialized with the initData<T> of field<T> methods.

Definition at line 237 of file Base.h.

References findField(), and m_fieldVec.

Referenced by sofa::component::mapping::BarycentricMapping< BasicMapping >::BarycentricMapping(), sofa::component::topology::EdgeSetTopology< DataTypes >::EdgeSetTopology(), sofa::component::MechanicalObject< DataTypes >::MechanicalObject(), sofa::component::topology::PointSetTopology< DataTypes >::PointSetTopology(), sofa::component::topology::TetrahedronSetTopology< DataTypes >::TetrahedronSetTopology(), and sofa::component::topology::TriangleSetTopology< DataTypes >::TriangleSetTopology().


Field Documentation

Data<std::string> sofa::core::objectmodel::Base::name

Name of the object.

Definition at line 60 of file Base.h.

Referenced by sofa::component::collision::BruteForceDetection::addCollisionPair(), Base(), decodeClassName(), decodeNamespaceName(), decodeTemplateName(), decodeTypeName(), sofa::simulation::tree::Simulation::getInstruments(), getName(), sofa::simulation::tree::GNode::getObject(), sofa::component::Light::init(), SofaFlowVR::FlowVRRenderMesh::parse(), parseFields(), setName(), and sofa::component::Light::~Light().

std::vector< std::pair<std::string, BaseData*> > sofa::core::objectmodel::Base::m_fieldVec [protected]

name -> Field object

Definition at line 234 of file Base.h.

Referenced by addField(), findField(), getFields(), initData(), initDataPtr(), parse(), parseFields(), writeDatas(), xmlWriteDatas(), and xmlWriteNodeDatas().


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