Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
ObjectFactory< PRODUCT > Class Template Reference

#include <object_factory.h>

Public Member Functions

PRODUCT * create (const std::string &name) const
bool add (const std::string &name, PRODUCT *(*maker)())
size_t size () const

Private Attributes

std::map< std::string, PRODUCT *(*)() > manufacturers

Detailed Description

template<typename PRODUCT>
class ObjectFactory< PRODUCT >

A generic storage class for storing items, such as variable values or function pointers. The storage class can store any type of item that does not require a constructor call, i.e., it does not create a new copy of an item when one is requested.

Definition at line 36 of file object_factory.h.

Member Function Documentation

◆ add()

template<typename PRODUCT>
bool ObjectFactory< PRODUCT >::add ( const std::string & name,
PRODUCT *(* maker )() )
inline

Register a maker to the factory. This function will fail to succeed if the factory already contains a maker with the given name.

Parameters
nameA unique name for the maker.
funcThe maker function.
Returns
If true, the maker was added to the factory.

Definition at line 72 of file object_factory.h.

◆ create()

template<typename PRODUCT>
PRODUCT * ObjectFactory< PRODUCT >::create ( const std::string & name) const
inline

Get an item (product) with the given name.

Parameters
nameThe name of the item.
funcThe requested item is stored here, if it was found.
Returns
If true, variable func contains a valid item.

Definition at line 58 of file object_factory.h.

◆ size()

template<typename PRODUCT>
size_t ObjectFactory< PRODUCT >::size ( ) const
inline

Definition at line 80 of file object_factory.h.

Member Data Documentation

◆ manufacturers

template<typename PRODUCT>
std::map<std::string,PRODUCT* (*)() > ObjectFactory< PRODUCT >::manufacturers
private

Container for all stored maker functions.

Definition at line 50 of file object_factory.h.


The documentation for this class was generated from the following file: