SOFA API  ca70b0f0
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")
;
RegisterObject & addLicense(std::string val)
Specify a license (LGPL, GPL, ...)
Definition: ObjectFactory.cpp:594

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...
 
RegisterObjectaddDocumentationURL (std::string url)
 Specify a documentation URL. 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

◆ entry

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

Class entry being constructed.

Constructor details

◆ RegisterObject()

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

Start the registration by giving the description of this class.

Function details

◆ add()

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.

◆ addAlias()

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

Add an alias name for this class.

◆ addAuthor()

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

Specify a list of authors (separated with spaces)

◆ addCreator()

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.

◆ addDescription()

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

Add more descriptive text about this class.

◆ addDocumentationURL()

RegisterObject & sofa::core::RegisterObject::addDocumentationURL ( std::string  url)

Specify a documentation URL.

◆ addLicense()

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

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

◆ operator int()

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

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