#include <ObjectFactory.h>
Classes | |
| class | ClassEntry |
| Record storing information about a class. More... | |
| class | Creator |
| Abstract interface of objects used to create instances of a given type. More... | |
Protected Attributes | |
| ClassEntryMap | registry |
| Main class registry. More... | |
| OnCreateCallback | m_callbackOnCreate |
| RegisteredPluginSet | m_registeredPluginSet |
Public Member Functions | |
| ~ObjectFactory () | |
| ClassEntry & | getEntry (std::string classname) |
| Get an entry given a class name (or alias) More... | |
| bool | hasCreator (std::string classname) |
| Test if a creator exists for a given classname. More... | |
| std::string | shortName (std::string classname) |
| void | getAllEntries (std::vector< ClassEntry::SPtr > &result, bool filterUnloadedPlugins=true) |
| Fill the given vector with all the registered classes. More... | |
| void | getEntriesFromTarget (std::vector< ClassEntry::SPtr > &result, std::string target) |
| Fill the given vector with the registered classes from a given target. More... | |
| std::string | listClassesFromTarget (std::string target, std::string separator=", ") |
| Return the list of classes from a given target. More... | |
| template<class BaseClass > | |
| void | getEntriesDerivedFrom (std::vector< ClassEntry::SPtr > &result) const |
| Fill the given vector with all the registered classes derived from BaseClass. More... | |
| template<class BaseClass > | |
| std::string | listClassesDerivedFrom (const std::string &separator=", ") const |
| Return the list of classes derived from BaseClass as a string. More... | |
| bool | addAlias (std::string name, std::string target, bool force=false, ClassEntry::SPtr *previous=nullptr) |
| void | resetAlias (std::string name, ClassEntry::SPtr previous) |
| objectmodel::BaseObject::SPtr | createObject (objectmodel::BaseContext *context, objectmodel::BaseObjectDescription *arg) |
| Create an object given a context and a description. More... | |
| void | dump (std::ostream &out=std::cout) |
| Dump the content of the factory to a text stream. More... | |
| void | dumpXML (std::ostream &out=std::cout) |
| Dump the content of the factory to a XML stream. More... | |
| void | dumpHTML (std::ostream &out=std::cout) |
| Dump the content of the factory to a HTML stream. More... | |
| void | setCallback (OnCreateCallback cb) |
| bool | registerObjectsFromPlugin (const std::string &pluginName) |
| bool | registerObjects (ObjectRegistrationData &ro) |
Static Public Member Functions | |
| static ObjectFactory * | getInstance () |
| Get the ObjectFactory singleton instance. More... | |
| static objectmodel::BaseObject::SPtr | CreateObject (objectmodel::BaseContext *context, objectmodel::BaseObjectDescription *arg) |
| Create an object given a context and a description. More... | |
| static bool | AddAlias (std::string name, std::string result, bool force=false, ClassEntry::SPtr *previous=nullptr) |
| static void | ResetAlias (std::string name, ClassEntry::SPtr previous) |
| static bool | HasCreator (std::string classname) |
| Test if a creator exists for a given classname. More... | |
| static std::string | ShortName (std::string classname) |
|
protected |
|
protected |
|
protected |
Main class registry.
| sofa::core::ObjectFactory::~ObjectFactory | ( | ) |
|
inlinestatic |
Add an alias name for an already registered class
| name | name of the new alias |
| target | 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 |
| bool sofa::core::ObjectFactory::addAlias | ( | std::string | name, |
| std::string | target, | ||
| bool | force = false, |
||
| ClassEntry::SPtr * | previous = nullptr |
||
| ) |
Add an alias name for an already registered class
| name | name of the new alias |
| target | 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 |
| objectmodel::BaseObject::SPtr sofa::core::ObjectFactory::createObject | ( | objectmodel::BaseContext * | context, |
| objectmodel::BaseObjectDescription * | arg | ||
| ) |
Create an object given a context and a description.
|
inlinestatic |
Create an object given a context and a description.
| void sofa::core::ObjectFactory::dump | ( | std::ostream & | out = std::cout | ) |
Dump the content of the factory to a text stream.
| void sofa::core::ObjectFactory::dumpHTML | ( | std::ostream & | out = std::cout | ) |
Dump the content of the factory to a HTML stream.
| void sofa::core::ObjectFactory::dumpXML | ( | std::ostream & | out = std::cout | ) |
Dump the content of the factory to a XML stream.
| void sofa::core::ObjectFactory::getAllEntries | ( | std::vector< ClassEntry::SPtr > & | result, |
| bool | filterUnloadedPlugins = true |
||
| ) |
Fill the given vector with all the registered classes.
| void sofa::core::ObjectFactory::getEntriesDerivedFrom | ( | std::vector< ClassEntry::SPtr > & | result | ) | const |
Fill the given vector with all the registered classes derived from BaseClass.
| void sofa::core::ObjectFactory::getEntriesFromTarget | ( | std::vector< ClassEntry::SPtr > & | result, |
| std::string | target | ||
| ) |
Fill the given vector with the registered classes from a given target.
| ObjectFactory::ClassEntry & sofa::core::ObjectFactory::getEntry | ( | std::string | classname | ) |
Get an entry given a class name (or alias)
|
static |
Get the ObjectFactory singleton instance.
| bool sofa::core::ObjectFactory::hasCreator | ( | std::string | classname | ) |
Test if a creator exists for a given classname.
|
inlinestatic |
Test if a creator exists for a given classname.
| std::string sofa::core::ObjectFactory::listClassesDerivedFrom | ( | const std::string & | separator = ", " | ) | const |
Return the list of classes derived from BaseClass as a string.
| std::string sofa::core::ObjectFactory::listClassesFromTarget | ( | std::string | target, |
| std::string | separator = ", " |
||
| ) |
Return the list of classes from a given target.
| bool sofa::core::ObjectFactory::registerObjects | ( | ObjectRegistrationData & | ro | ) |
| bool sofa::core::ObjectFactory::registerObjectsFromPlugin | ( | const std::string & | pluginName | ) |
| void sofa::core::ObjectFactory::resetAlias | ( | std::string | name, |
| ClassEntry::SPtr | 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 |
|
inlinestatic |
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 |
|
inline |
| std::string sofa::core::ObjectFactory::shortName | ( | std::string | classname | ) |
Return the shortname for this classname. Empty string if no creator exists for this classname.
|
inlinestatic |