#include <Base.h>
Base class for everything. More...
Base class for everything.
This class contains all functionality shared by every objects in SOFA. Most importantly it defines how to retrieve information about an object (name, type, data fields). All classes deriving from Base should use the SOFA_CLASS macro within their declaration (see BaseClass.h).
Public Attributes | |
std::vector< lifecycle::DeprecatedData * > | m_oldAttributes |
Data< int > | d_messageLogCount |
Data< std::string > | name |
Name of the object. More... | |
Data< bool > | f_printLog |
if true, emits extra messages at runtime. More... | |
Data< sofa::core::objectmodel::TagSet > | f_tags |
list of the subsets the object belongs to More... | |
Data< sofa::type::BoundingBox > | f_bbox |
this object bounding box More... | |
Data< sofa::core::objectmodel::ComponentState > | d_componentState |
The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). More... | |
std::string | m_definitionSourceFileName {""} |
int | m_definitionSourceFilePos {-1} |
std::string | m_instanciationSourceFileName {""} |
int | m_instanciationSourceFilePos {-1} |
Protected Attributes | |
std::map< std::string, sofa::core::DataTrackerCallback > | m_internalEngine |
VecData | m_vecData |
List of fields (Data instances) More... | |
MapData | m_aliasData |
name -> Data multi-map (includes names and aliases) More... | |
VecLink | m_vecLink |
List of links. More... | |
MapLink | m_aliasLink |
name -> Link multi-map (includes names and aliases) More... | |
Public Member Functions | |
virtual const BaseClass * | getClass () const |
void | addDeprecatedAttribute (lifecycle::DeprecatedData *attribute) |
void | addUpdateCallback (const std::string &name, std::initializer_list< BaseData * > inputs, std::function< sofa::core::objectmodel::ComponentState(const DataTracker &)> function, std::initializer_list< BaseData * > outputs) |
void | addOutputsToCallback (const std::string &name, std::initializer_list< BaseData * > outputs) |
virtual std::string | getPathName () const |
const std::string & | getName () const |
Accessor to the object name. More... | |
void | setName (const std::string &n) |
Set the name of this object. More... | |
void | setName (const std::string &n, int counter) |
Set the name of this object, adding an integer counter. More... | |
std::string | getTypeName () const |
Get the type name of this object (i.e. class and template types) More... | |
virtual std::string | getClassName () const |
Get the class name of this object. More... | |
virtual std::string | getTemplateName () const final |
Get the template type names (if any) used to instantiate this object. More... | |
std::string | getNameSpaceName () const |
Get the template type names (if any) used to instantiate this object. More... | |
void | setDefinitionSourceFileName (const std::string &sourceFileName) |
Set the source filename (where the component is implemented) More... | |
const std::string & | getDefinitionSourceFileName () const |
Get the source filename (where the component is implemented) More... | |
void | setDefinitionSourceFilePos (const int) |
Set the source location (where the component is implemented) More... | |
int | getDefinitionSourceFilePos () const |
Get the source location (where the component is implemented) More... | |
void | setInstanciationSourceFileName (const std::string &sourceFileName) |
const std::string & | getInstanciationSourceFileName () const |
void | setInstanciationSourceFilePos (const int) |
int | getInstanciationSourceFilePos () const |
void | addMessage (const sofa::helper::logging::Message &m) const |
size_t | countLoggedMessages (sofa::helper::logging::Message::TypeSet t=sofa::helper::logging::Message::AnyTypes) const |
const std::deque< sofa::helper::logging::Message > & | getLoggedMessages () const |
const std::string | getLoggedMessagesAsString (sofa::helper::logging::Message::TypeSet t=sofa::helper::logging::Message::AnyTypes) const |
void | clearLoggedMessages () const |
bool | notMuted () const |
tags | |
Methods related to tagged subsets | |
const sofa::core::objectmodel::TagSet & | getTags () const |
Represents the subsets the object belongs to. More... | |
bool | hasTag (Tag t) const |
Return true if the object belong to the given subset. More... | |
void | addTag (Tag t) |
Add a subset qualification to the object. More... | |
void | removeTag (Tag t) |
Remove a subset qualification to the object. More... | |
componentstate | |
Methods related to component state | |
ComponentState | getComponentState () const |
bool | isComponentStateValid () const |
Static Public Member Functions | |
static const BaseClass * | GetClass () |
template<class T > | |
static std::string | shortName (const T *ptr=nullptr, BaseObjectDescription *=nullptr) |
Protected Member Functions | |
Base () | |
virtual | ~Base () |
void | initData0 (BaseData *field, BaseData::BaseInitData &res, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false) |
Helper method used by initData() More... | |
void | initData0 (BaseData *field, BaseData::BaseInitData &res, const char *name, const char *help, BaseData::DataFlags dataFlags) |
Helper method used by initData() More... | |
template<class T > | |
void | initData0 (Data< T > *field, typename Data< T >::InitData &res, const T &value, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false) |
Helper method used by initData() More... | |
Friends | |
void | intrusive_ptr_add_ref (Base *p) |
void | intrusive_ptr_release (Base *p) |
fields | |
Data fields management | |
typedef type::vector< BaseData * > | VecData |
typedef std::multimap< std::string, BaseData * > | MapData |
typedef type::vector< BaseLink * > | VecLink |
typedef std::multimap< std::string, BaseLink * > | MapLink |
virtual bool | parseField (const std::string &attribute, const std::string &value) |
Assign one field value (Data or Link) More... | |
virtual bool | hasField (const std::string &attribute) const |
Check if a given Data field or Link exists. More... | |
virtual void | parse (BaseObjectDescription *arg) |
Parse the given description to assign values to this object's fields and potentially other parameters. More... | |
void | parseFields (const std::list< std::string > &str) |
Assign the field values stored in the given list of name + value pairs of strings. More... | |
virtual void | parseFields (const std::map< std::string, std::string * > &str) |
Assign the field values stored in the given map of name -> value pairs. More... | |
void | writeDatas (std::map< std::string, std::string * > &str) |
Write the current field values to the given map of name -> value pairs. More... | |
void | writeDatas (std::ostream &out, const std::string &separator=" ") |
BaseData * | findData (const std::string &name) const |
std::vector< BaseData * > | findGlobalField (const std::string &name) const |
Find data fields given a name: several can be found as we look into the alias map. More... | |
BaseLink * | findLink (const std::string &name) const |
std::vector< BaseLink * > | findLinks (const std::string &name) const |
Find link fields given a name: several can be found as we look into the alias map. More... | |
virtual void | updateLinks (bool logErrors=true) |
Update pointers in case the pointed-to objects have appeared. More... | |
template<class T > | |
BaseData::BaseInitData | initData (::sofa::core::objectmodel::Data< T > *field, const char *name, const char *help, ::sofa::core::objectmodel::BaseData::DataFlags dataflags) |
Helper method used to initialize a data field containing a value of type T. More... | |
template<class T > | |
BaseData::BaseInitData | initData (Data< T > *field, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false) |
Helper method used to initialize a data field containing a value of type T. More... | |
template<class T > | |
Data< T >::InitData | initData (Data< T > *field, const T &value, const char *name, const char *help, bool isDisplayed=true, bool isReadOnly=false) |
Helper method used to initialize a data field containing a value of type T. More... | |
void | addData (BaseData *f, const std::string &name) |
void | addData (BaseData *f) |
void | removeData (BaseData *f) |
Remove a data field. More... | |
void | addAlias (BaseData *field, const char *alias) |
Add an alias to a Data. More... | |
void | addLink (BaseLink *l) |
Add a link. More... | |
void | addAlias (BaseLink *link, const char *alias) |
Add an alias to a Link. More... | |
const VecData & | getDataFields () const |
Accessor to the vector containing all the fields of this object. More... | |
const MapData & | getDataAliases () const |
Accessor to the map containing all the aliases of this object. More... | |
const VecLink & | getLinks () const |
Accessor to the vector containing all the fields of this object. More... | |
const MapLink & | getLinkAliases () const |
Accessor to the map containing all the aliases of this object. More... | |
virtual bool | findDataLinkDest (BaseData *&ptr, const std::string &path, const BaseLink *link) |
virtual Base * | findLinkDestClass (const BaseClass *destType, const std::string &path, const BaseLink *link) |
template<class T > | |
bool | findLinkDest (T *&ptr, const std::string &path, const BaseLink *link) |
Data< sofa::core::objectmodel::ComponentState > sofa::core::objectmodel::Base::d_componentState |
The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).
|
mutable |
Data< sofa::type::BoundingBox > sofa::core::objectmodel::Base::f_bbox |
this object bounding box
Data< sofa::core::objectmodel::TagSet > sofa::core::objectmodel::Base::f_tags |
list of the subsets the object belongs to
|
protected |
name -> Data multi-map (includes names and aliases)
|
protected |
name -> Link multi-map (includes names and aliases)
std::string sofa::core::objectmodel::Base::m_definitionSourceFileName {""} |
int sofa::core::objectmodel::Base::m_definitionSourceFilePos {-1} |
std::string sofa::core::objectmodel::Base::m_instanciationSourceFileName {""} |
int sofa::core::objectmodel::Base::m_instanciationSourceFilePos {-1} |
|
protected |
std::vector<lifecycle::DeprecatedData*> sofa::core::objectmodel::Base::m_oldAttributes |
|
protected |
List of links.
Data<std::string> sofa::core::objectmodel::Base::name |
Name of the object.
|
protected |
Constructor cannot be called directly Use the New() method instead
|
protectedvirtual |
Direct calls to destructor are forbidden. Smart pointers must be used to manage creation/destruction of objects
Add an alias to a Data.
Add an alias to a Link.
void sofa::core::objectmodel::Base::addData | ( | BaseData * | f | ) |
Add a data field. Note that this method should only be called if the Data was not initialized with the initData method
Add a data field. Note that this method should only be called if the field was not initialized with the initData method
void sofa::core::objectmodel::Base::addData | ( | BaseData * | f, |
const std::string & | name | ||
) |
Add a data field. Note that this method should only be called if the Data was not initialized with the initData method
Add a data field. Note that this method should only be called if the field was not initialized with the initData method
void sofa::core::objectmodel::Base::addDeprecatedAttribute | ( | lifecycle::DeprecatedData * | attribute | ) |
void sofa::core::objectmodel::Base::addLink | ( | BaseLink * | l | ) |
Add a link.
Add a link. Note that this method should only be called if the link was not initialized with the initLink method
void sofa::core::objectmodel::Base::addMessage | ( | const sofa::helper::logging::Message & | m | ) | const |
void sofa::core::objectmodel::Base::addOutputsToCallback | ( | const std::string & | name, |
std::initializer_list< BaseData * > | outputs | ||
) |
void sofa::core::objectmodel::Base::addTag | ( | Tag | t | ) |
Add a subset qualification to the object.
void sofa::core::objectmodel::Base::addUpdateCallback | ( | const std::string & | name, |
std::initializer_list< BaseData * > | inputs, | ||
std::function< sofa::core::objectmodel::ComponentState(const DataTracker &)> | function, | ||
std::initializer_list< BaseData * > | outputs | ||
) |
void sofa::core::objectmodel::Base::clearLoggedMessages | ( | ) | const |
size_t sofa::core::objectmodel::Base::countLoggedMessages | ( | sofa::helper::logging::Message::TypeSet | t = sofa::helper::logging::Message::AnyTypes | ) | const |
BaseData * sofa::core::objectmodel::Base::findData | ( | const std::string & | name | ) | const |
Find a data field given its name. Return nullptr if not found. If more than one field is found (due to aliases), only the first is returned.
|
virtual |
std::vector< BaseData * > sofa::core::objectmodel::Base::findGlobalField | ( | const std::string & | name | ) | const |
Find data fields given a name: several can be found as we look into the alias map.
Find fields given a name: several can be found as we look into the alias map.
BaseLink * sofa::core::objectmodel::Base::findLink | ( | const std::string & | name | ) | const |
Find a link given its name. Return nullptr if not found. If more than one link is found (due to aliases), only the first is returned.
|
inline |
|
virtual |
Reimplemented in sofa::simulation::Node, sofa::core::objectmodel::BaseNode, and sofa::core::objectmodel::BaseObject.
std::vector< BaseLink * > sofa::core::objectmodel::Base::findLinks | ( | const std::string & | name | ) | const |
Find link fields given a name: several can be found as we look into the alias map.
Find links given a name: several can be found as we look into the alias map.
|
inlinestatic |
|
inlinevirtual |
|
virtual |
Get the class name of this object.
Get the class name of this object To specify custom static class name you need to implement a single static std::string GetCustomClassName(){} method. Override only if the class name cannot be known at compile-time (e.g. Python).
|
inline |
|
inline |
Accessor to the map containing all the aliases of this object.
|
inline |
Accessor to the vector containing all the fields of this object.
const std::string & sofa::core::objectmodel::Base::getDefinitionSourceFileName | ( | ) | const |
Get the source filename (where the component is implemented)
int sofa::core::objectmodel::Base::getDefinitionSourceFilePos | ( | ) | const |
Get the source location (where the component is implemented)
const std::string & sofa::core::objectmodel::Base::getInstanciationSourceFileName | ( | ) | const |
Get the file where the instance has been created This is useful to store where the component was emitted from
int sofa::core::objectmodel::Base::getInstanciationSourceFilePos | ( | ) | const |
Get the file location (line number) where the instance has been created This is useful to store where the component was emitted from
|
inline |
Accessor to the map containing all the aliases of this object.
|
inline |
Accessor to the vector containing all the fields of this object.
const std::deque< sofa::helper::logging::Message > & sofa::core::objectmodel::Base::getLoggedMessages | ( | ) | const |
const std::string sofa::core::objectmodel::Base::getLoggedMessagesAsString | ( | sofa::helper::logging::Message::TypeSet | t = sofa::helper::logging::Message::AnyTypes | ) | const |
|
inline |
Accessor to the object name.
std::string sofa::core::objectmodel::Base::getNameSpaceName | ( | ) | const |
Get the template type names (if any) used to instantiate this object.
|
inlinevirtual |
Reimplemented in sofa::core::objectmodel::BaseObject, and sofa::core::objectmodel::BaseNode.
|
inline |
Represents the subsets the object belongs to.
|
finalvirtual |
Get the template type names (if any) used to instantiate this object.
Get the template type names (if any) used to instantiate this object To specify custom static template name you need to implement a single static std::string GetCustomTemplateName(){} method.
std::string sofa::core::objectmodel::Base::getTypeName | ( | ) | const |
Get the type name of this object (i.e. class and template types)
|
virtual |
Check if a given Data field or Link exists.
Return true if the object belong to the given subset.
|
inline |
Helper method used to initialize a data field containing a value of type T.
|
inline |
Helper method used to initialize a data field containing a value of type T.
|
inline |
Helper method used to initialize a data field containing a value of type T.
|
protected |
Helper method used by initData()
|
protected |
Helper method used by initData()
|
inlineprotected |
Helper method used by initData()
|
inline |
|
inline |
|
virtual |
Parse the given description to assign values to this object's fields and potentially other parameters.
Reimplemented in sofa::gl::component::rendering3d::MergeVisualModels, sofa::simulation::RequiredPlugin, sofa::simulation::Node, sofa::core::loader::SceneLoader, sofa::core::loader::MeshLoader, sofa::component::solidmechanics::fem::elastic::TriangularFEMForceFieldOptim< DataTypes >, sofa::component::sceneutility::BaseAddResourceRepository, sofa::component::mass::UniformMass< DataTypes >, sofa::component::mass::MeshMatrixMass< DataTypes, GeometricalTypes >, sofa::component::mass::DiagonalMass< DataTypes, GeometricalTypes >, sofa::component::mass::DiagonalMass< DataTypes, GeometricalTypes >, sofa::component::engine::transform::ROIValueMapper, sofa::component::engine::transform::MathOp< VecT >, sofa::component::engine::select::SelectConnectedLabelsROI< _T >, sofa::component::engine::select::MeshSplittingEngine< DataTypes >, sofa::component::engine::select::ComplementaryROI< DataTypes >, sofa::component::engine::generate::MergeVectors< VecT >, sofa::component::engine::generate::MergeMeshes< DataTypes >, sofa::component::collision::response::contact::RuleBasedContactManager, sofa::core::loader::BaseLoader, sofa::gl::component::shader::OglShader, sofa::gl::component::rendering3d::OglModel, sofa::gl::component::rendering2d::OglLabel, sofa::component::visual::VisualModelImpl, sofa::component::topology::container::grid::RegularGridTopology, sofa::component::topology::container::grid::GridTopology, sofa::component::topology::container::constant::CubeTopology, sofa::component::statecontainer::MechanicalObject< DataTypes >, sofa::component::statecontainer::MechanicalObject< T >, sofa::component::solidmechanics::spring::RestShapeSpringsForceField< DataTypes >, sofa::component::sceneutility::FileMessageHandlerComponent, sofa::component::sceneutility::MessageHandlerComponent, sofa::component::sceneutility::makedataaliascomponent::MakeDataAliasComponent, sofa::component::sceneutility::makealiascomponent::MakeAliasComponent, sofa::component::odesolver::backward::VariationalSymplecticSolver, sofa::component::mapping::nonlinear::RigidMapping< TIn, TOut >, sofa::component::engine::select::MergeROIs, and sofa::core::objectmodel::BaseObject.
|
virtual |
Assign one field value (Data or Link)
void sofa::core::objectmodel::Base::parseFields | ( | const std::list< std::string > & | str | ) |
Assign the field values stored in the given list of name + value pairs of strings.
|
virtual |
Assign the field values stored in the given map of name -> value pairs.
Reimplemented in sofa::gl::component::rendering3d::MergeVisualModels, sofa::component::engine::transform::ROIValueMapper, sofa::component::engine::transform::MathOp< VecT >, sofa::component::engine::select::SelectConnectedLabelsROI< _T >, sofa::component::engine::select::MeshSplittingEngine< DataTypes >, sofa::component::engine::select::MergeROIs, sofa::component::engine::select::ComplementaryROI< DataTypes >, sofa::component::engine::generate::MergeVectors< VecT >, and sofa::component::engine::generate::MergeMeshes< DataTypes >.
void sofa::core::objectmodel::Base::removeData | ( | BaseData * | f | ) |
Remove a data field.
void sofa::core::objectmodel::Base::removeTag | ( | Tag | t | ) |
Remove a subset qualification to the object.
void sofa::core::objectmodel::Base::setDefinitionSourceFileName | ( | const std::string & | sourceFileName | ) |
Set the source filename (where the component is implemented)
void sofa::core::objectmodel::Base::setDefinitionSourceFilePos | ( | const int | linenum | ) |
Set the source location (where the component is implemented)
void sofa::core::objectmodel::Base::setInstanciationSourceFileName | ( | const std::string & | filename | ) |
Set the file where the instance has been created This is useful to store where the component was emitted from
void sofa::core::objectmodel::Base::setInstanciationSourceFilePos | ( | const int | lineco | ) |
Set the file location (line number) where the instance has been created This is useful to store where the component was emitted from
void sofa::core::objectmodel::Base::setName | ( | const std::string & | n | ) |
Set the name of this object.
void sofa::core::objectmodel::Base::setName | ( | const std::string & | n, |
int | counter | ||
) |
Set the name of this object, adding an integer counter.
|
inlinestatic |
Helper method to get the shortname of a type derived from this class. The default implementation return the class name.
This method should be used as follow :
This way derived classes can redefine the shortName method
|
virtual |
Update pointers in case the pointed-to objects have appeared.
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.
void sofa::core::objectmodel::Base::writeDatas | ( | std::ostream & | out, |
const std::string & | separator = " " |
||
) |
Write the current field values to the given output stream separated with the given separator (" " used by default for XML)
|
friend |
|
friend |