votca 2024.2-dev
|
template class for object factory More...
#include <objectfactory.h>
Public Types | |
using | creator_t = std::unique_ptr<T> (*)(args_t &&...) |
Public Member Functions | |
ObjectFactory ()=default | |
virtual | ~ObjectFactory ()=default |
void | Register (const key_t &key, creator_t creator) |
register an object | |
template<typename obj_t > | |
void | Register (const key_t &key) |
virtual std::unique_ptr< T > | Create (const key_t &key, args_t &&...arguments) |
bool | IsRegistered (const key_t &id_) const |
std::vector< key_t > | getKeys () const |
Private Attributes | |
std::map< key_t, creator_t > | objects_ |
template class for object factory
This class is a template for an object factory. The factory creates an instance of an derived class, be giving a key (e.g. a string) for the object which identifies it uniquely. This allows the implementation of new features (e.g. new file formats, new mapping algorithms) without touching or recompiling existing bits of code.
Definition at line 44 of file objectfactory.h.
using votca::tools::ObjectFactory< key_t, T, args_t >::creator_t = std::unique_ptr<T> (*)(args_t &&...) |
Definition at line 46 of file objectfactory.h.
|
default |
|
virtualdefault |
|
inlinevirtual |
Create an instance of the object identified by key.
Definition at line 102 of file objectfactory.h.
|
inline |
Definition at line 70 of file objectfactory.h.
|
inline |
Definition at line 114 of file objectfactory.h.
|
inline |
Definition at line 97 of file objectfactory.h.
|
inline |
register an object
key | identifier |
creator | create policy |
This function is called to register an object in the factory. After an object is registered, an instance of it can be created by calling Create specifying the corresponding key.
Definition at line 89 of file objectfactory.h.
|
private |
Definition at line 80 of file objectfactory.h.