#include <ObjectFactory.h>

Data Structures | |
| class | ClassEntry |
| Record storing information about a class. More... | |
| class | Creator |
| Abstract interface of objects used to create instances of a given type. More... | |
Public Member Functions | |
| ClassEntry * | getEntry (std::string classname) |
| Get an entry given a class name (or alias). | |
| void | getAllEntries (std::vector< ClassEntry * > &result) |
| Fill the given vector with all the registered classes. | |
| bool | addAlias (std::string name, std::string result, bool force=false, ClassEntry **previous=NULL) |
| Add an alias name for an already registered class. | |
| void | resetAlias (std::string name, ClassEntry *previous) |
| Reset an alias to a previous state. | |
| objectmodel::BaseObject * | createObject (objectmodel::BaseContext *context, objectmodel::BaseObjectDescription *arg) |
| Create an object given a context and a description. | |
| void | dump (std::ostream &out=std::cout) |
| Dump the content of the factory to a text stream. | |
| void | dumpXML (std::ostream &out=std::cout) |
| Dump the content of the factory to a XML stream. | |
| void | dumpHTML (std::ostream &out=std::cout) |
| Dump the content of the factory to a HTML stream. | |
Static Public Member Functions | |
| static ObjectFactory * | getInstance () |
| Get the ObjectFactory singleton instance. | |
| static objectmodel::BaseObject * | CreateObject (objectmodel::BaseContext *context, objectmodel::BaseObjectDescription *arg) |
| static bool | AddAlias (std::string name, std::string result, bool force=false, ClassEntry **previous=NULL) |
| static void | ResetAlias (std::string name, ClassEntry *previous) |
Protected Attributes | |
| std::map< std::string, ClassEntry * > | registry |
| Main class registry. | |
It uses the Factory design pattern, where each class is registered in a map, and dynamically retrieved given the type name.
It also stores metainformation on each classes, such as description, authors, license, and available template types.
Definition at line 74 of file ObjectFactory.h.
| static bool sofa::core::ObjectFactory::AddAlias | ( | std::string | name, | |
| std::string | result, | |||
| bool | force = false, |
|||
| ClassEntry ** | previous = NULL | |||
| ) | [inline, static] |
Add an alias name for an already registered class.
| name | name of the new alias | |
| result | class pointed to by the new alias | |
| force | set to true if this method should override any entry already registered for this name | |
| previous | (output) previous ClassEntry registered for this name |
Definition at line 153 of file ObjectFactory.h.
References addAlias(), force, and getInstance().
Referenced by sofa::gui::qt::viewer::qtogre::QtOgreViewer::EnableViewer(), sofa::gui::qt::viewer::qt::QtViewer::EnableViewer(), sofa::gui::qt::viewer::qgl::QtGLViewer::EnableViewer(), and main().
| bool sofa::core::ObjectFactory::addAlias | ( | std::string | name, | |
| std::string | result, | |||
| bool | force = false, |
|||
| ClassEntry ** | previous = NULL | |||
| ) |
Add an alias name for an already registered class.
| name | name of the new alias | |
| result | class pointed to by the new alias | |
| force | set to true if this method should override any entry already registered for this name | |
| previous | (output) previous ClassEntry registered for this name |
Definition at line 50 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::aliases, and registry.
Referenced by AddAlias(), and sofa::core::RegisterObject::operator int().
| static objectmodel::BaseObject* sofa::core::ObjectFactory::CreateObject | ( | objectmodel::BaseContext * | context, | |
| objectmodel::BaseObjectDescription * | arg | |||
| ) | [inline, static] |
Create an object given a context and a description.
Definition at line 147 of file ObjectFactory.h.
References createObject(), and getInstance().
Referenced by sofa::simulation::PipelineImpl::init(), and sofa::simulation::tree::xml::ObjectElement::initNode().
| objectmodel::BaseObject * sofa::core::ObjectFactory::createObject | ( | objectmodel::BaseContext * | context, | |
| objectmodel::BaseObjectDescription * | arg | |||
| ) |
Create an object given a context and a description.
Definition at line 85 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::Creator::canCreate(), sofa::core::ObjectFactory::ClassEntry::creatorList, sofa::core::ObjectFactory::ClassEntry::creatorMap, sofa::core::objectmodel::Base::decodeTemplateName(), sofa::core::ObjectFactory::ClassEntry::defaultTemplate, sofa::core::objectmodel::BaseObjectDescription::getAttribute(), and registry.
Referenced by CreateObject().
| void sofa::core::ObjectFactory::dump | ( | std::ostream & | out = std::cout |
) |
Dump the content of the factory to a text stream.
Definition at line 157 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::aliases, sofa::core::ObjectFactory::ClassEntry::authors, sofa::core::ObjectFactory::ClassEntry::baseClasses, sofa::core::ObjectFactory::ClassEntry::className, sofa::core::ObjectFactory::ClassEntry::creatorList, sofa::core::ObjectFactory::ClassEntry::description, sofa::core::ObjectFactory::ClassEntry::license, and registry.
| void sofa::core::ObjectFactory::dumpHTML | ( | std::ostream & | out = std::cout |
) |
Dump the content of the factory to a HTML stream.
Definition at line 236 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::aliases, sofa::core::ObjectFactory::ClassEntry::authors, sofa::core::ObjectFactory::ClassEntry::baseClasses, sofa::core::ObjectFactory::ClassEntry::className, sofa::core::ObjectFactory::ClassEntry::creatorList, sofa::core::ObjectFactory::ClassEntry::defaultTemplate, sofa::core::ObjectFactory::ClassEntry::description, sofa::core::ObjectFactory::ClassEntry::license, registry, and sofa::core::xmlencode().
| void sofa::core::ObjectFactory::dumpXML | ( | std::ostream & | out = std::cout |
) |
Dump the content of the factory to a XML stream.
Definition at line 209 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::aliases, sofa::core::ObjectFactory::ClassEntry::authors, sofa::core::ObjectFactory::ClassEntry::baseClasses, sofa::core::ObjectFactory::ClassEntry::className, sofa::core::ObjectFactory::ClassEntry::creatorList, sofa::core::ObjectFactory::ClassEntry::description, sofa::core::ObjectFactory::ClassEntry::license, registry, and sofa::core::xmlencode().
| void sofa::core::ObjectFactory::getAllEntries | ( | std::vector< ClassEntry * > & | result | ) |
Fill the given vector with all the registered classes.
Definition at line 146 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::className, and registry.
Referenced by sofa::gui::qt::SofaModeler::SofaModeler().
| ObjectFactory::ClassEntry * sofa::core::ObjectFactory::getEntry | ( | std::string | classname | ) |
Get an entry given a class name (or alias).
Definition at line 39 of file ObjectFactory.cpp.
References sofa::core::ObjectFactory::ClassEntry::className, and registry.
Referenced by sofa::core::RegisterObject::operator int(), and sofa::gui::qt::ModifyObject::setNode().
| ObjectFactory * sofa::core::ObjectFactory::getInstance | ( | ) | [static] |
Get the ObjectFactory singleton instance.
Definition at line 140 of file ObjectFactory.cpp.
Referenced by AddAlias(), CreateObject(), projects::generateFactoryHTMLDoc(), projects::generateFactoryPHPDoc(), sofa::core::RegisterObject::operator int(), ResetAlias(), sofa::gui::qt::ModifyObject::setNode(), and sofa::gui::qt::SofaModeler::SofaModeler().
| static void sofa::core::ObjectFactory::ResetAlias | ( | std::string | name, | |
| ClassEntry * | previous | |||
| ) | [inline, static] |
Reset an alias to a previous state.
| name | name of the new alias | |
| previous | previous ClassEntry that need to be registered back for this name |
Definition at line 159 of file ObjectFactory.h.
References getInstance(), and resetAlias().
Referenced by sofa::gui::qt::viewer::qtogre::QtOgreViewer::DisableViewer(), sofa::gui::qt::viewer::qt::QtViewer::DisableViewer(), and sofa::gui::qt::viewer::qgl::QtGLViewer::DisableViewer().
| void sofa::core::ObjectFactory::resetAlias | ( | std::string | name, | |
| ClassEntry * | previous | |||
| ) |
Reset an alias to a previous state.
| name | name of the new alias | |
| previous | previous ClassEntry that need to be registered back for this name |
Definition at line 79 of file ObjectFactory.cpp.
References registry.
Referenced by ResetAlias().
std::map<std::string,ClassEntry*> sofa::core::ObjectFactory::registry [protected] |
Main class registry.
Definition at line 116 of file ObjectFactory.h.
Referenced by addAlias(), createObject(), dump(), dumpHTML(), dumpXML(), getAllEntries(), getEntry(), and resetAlias().
1.5.7.1