Description
A class factory.
It can create C++ objects from their string name. Just use the ChClassFactory::create() function, given a string. NOTE: desired classes must be previously registered via the CH_FACTORY_REGISTER macro, or using ClassRegister, otherwise the ChClassFactory::create() throws an exception. NOTE: You do not need to explicitly create it: a static ChClassFactory class factory is automatically instanced once, at the first time that someone registers a class. It is consistent also across different DLLs.
#include <ChClassFactory.h>
Static Public Member Functions | |
static void | ClassRegister (const std::string &keyName, ChClassRegistrationBase *mregistration) |
Register a class into the global class factory. More... | |
static void | ClassUnregister (const std::string &keyName) |
Unregister a class from the global class factory. More... | |
static bool | IsClassRegistered (const std::string &keyName) |
Tell if a class is registered, from class name. Name is the mnemonic tag given at registration. | |
static ChClassRegistrationBase * | GetClass (const std::string &keyName) |
Get class registration info from class name. More... | |
static std::string & | GetClassTagName (const std::type_info &mtype) |
Tell the class name, from type_info. More... | |
template<class T > | |
static void | create (const std::string &keyName, T **ptr) |
Create from class name, for registered classes. More... | |
template<class T > | |
static void | create (const std::string &keyName, ChArchiveIn &marchive, T **ptr) |
Create from class name, for registered classes. More... | |
Member Function Documentation
◆ ClassRegister()
|
inlinestatic |
Register a class into the global class factory.
Provide an unique name and a ChClassRegistration object. If multiple registrations with the same name are attempted, only one is done.
◆ ClassUnregister()
|
inlinestatic |
Unregister a class from the global class factory.
Provide an unique name.
◆ create() [1/2]
|
inlinestatic |
Create from class name, for registered classes.
Name is the mnemonic tag given at registration. If a static T* ArchiveINconstructor(ChArchiveIn&) function is available, call it instead. The created object is returned in "ptr"
◆ create() [2/2]
|
inlinestatic |
Create from class name, for registered classes.
Name is the mnemonic tag given at registration. The created object is returned in "ptr"
◆ GetClass()
|
inlinestatic |
Get class registration info from class name.
Name is the mnemonic tag given at registration. Return nullptr if not registered.
◆ GetClassTagName()
|
inlinestatic |
Tell the class name, from type_info.
This is a mnemonic tag name, given at registration, not the typeid.name().
The documentation for this class was generated from the following files:
- /builds/uwsbel/chrono/src/chrono/core/ChClassFactory.h
- /builds/uwsbel/chrono/src/chrono/core/ChClassFactory.cpp