SOFA API  3944ba52
Open source framework for multi-physics simuation
sofa::core::RegisterObject Class Reference

#include <ObjectFactory.h>

Helper class used to register a class in the ObjectFactory. More...

Detailed Description

Helper class used to register a class in the ObjectFactory.

This class accumulate information about a given class, as well as creators for each supported template instanciation, to register a new entry in the ObjectFactory.

It should be used as a temporary object, finalized when used to initialize an int static variable. For example :

int Fluid3DClass = core::RegisterObject("Eulerian 3D fluid")
.add\< Fluid3D \>()
.addLicense("LGPL")
;

Protected Attributes

ObjectFactory::ClassEntry entry
 Class entry being constructed. More...
 

Public Member Functions

 RegisterObject (const std::string &description)
 Start the registration by giving the description of this class. More...
 
RegisterObjectaddAlias (std::string val)
 Add an alias name for this class. More...
 
RegisterObjectaddDescription (std::string val)
 Add more descriptive text about this class. More...
 
RegisterObjectaddAuthor (std::string val)
 Specify a list of authors (separated with spaces) More...
 
RegisterObjectaddLicense (std::string val)
 Specify a license (LGPL, GPL, ...) More...
 
RegisterObjectaddCreator (std::string classname, std::string templatename, ObjectFactory::Creator::SPtr creator)
 
template<class RealObject >
RegisterObjectadd (bool defaultTemplate=false)
 
 operator int ()
 This is the final operation that will actually commit the additions to the ObjectFactory. More...
 

Attribute details

ObjectFactory::ClassEntry sofa::core::RegisterObject::entry
protected

Class entry being constructed.

Constructor details

sofa::core::RegisterObject::RegisterObject ( const std::string &  description)

Start the registration by giving the description of this class.

Function details

template<class RealObject >
RegisterObject& sofa::core::RegisterObject::add ( bool  defaultTemplate = false)
inline

Add a template instanciation of this class.

Parameters
defaultTemplateset to true if this should be the default instance when no template name is given.
RegisterObject & sofa::core::RegisterObject::addAlias ( std::string  val)

Add an alias name for this class.

RegisterObject & sofa::core::RegisterObject::addAuthor ( std::string  val)

Specify a list of authors (separated with spaces)

RegisterObject & sofa::core::RegisterObject::addCreator ( std::string  classname,
std::string  templatename,
ObjectFactory::Creator::SPtr  creator 
)

Add a creator able to instance this class with the given templatename.

See the add<RealObject>() method for an easy way to add a Creator.

RegisterObject & sofa::core::RegisterObject::addDescription ( std::string  val)

Add more descriptive text about this class.

RegisterObject & sofa::core::RegisterObject::addLicense ( std::string  val)

Specify a license (LGPL, GPL, ...)

sofa::core::RegisterObject::operator int ( )

This is the final operation that will actually commit the additions to the ObjectFactory.