RINGMesh  Version 5.0.0
A programming library for geological model meshes
RINGMesh::Factory< Key, BaseClass, Args > Class Template Reference

#include <factory.h>

Public Types

using Creator = typename std::add_pointer< std::unique_ptr< BaseClass >(const Args &...) >::type
 
using FactoryStore = std::map< Key, Creator >
 

Static Public Member Functions

template<typename DerivedClass >
static void register_creator (const Key &key)
 
static std::unique_ptr< BaseClass > create (const Key &key, const Args &... args)
 
static std::vector< Key > list_creators ()
 
static bool has_creator (const Key &key)
 

Static Private Member Functions

template<typename DerivedClass >
static std::unique_ptr< BaseClass > create_function_impl (Args &&... args)
 

Static Private Attributes

static FactoryStore store_
 

Detailed Description

template<typename Key, typename BaseClass, typename... Args>
class RINGMesh::Factory< Key, BaseClass, Args >

Generic factory Example of use with A the base class and B, C derived classes // Instantiation using MyFactory = Factory< std::string, A, int, double >; // Registration MyFactory::register_creator< B >( "B" ); // B constructor takes an int and a double MyFactory::register_creator< C >( "C" ); // C constructor takes an int and a double // Creation std::unique_ptr< A > c = MyFactory::create( "C", 2, 8.6 );

Definition at line 61 of file factory.h.

Member Typedef Documentation

◆ Creator

template<typename Key , typename BaseClass , typename... Args>
using RINGMesh::Factory< Key, BaseClass, Args >::Creator = typename std::add_pointer< std::unique_ptr< BaseClass >( const Args&... ) >::type

Definition at line 114 of file factory.h.

◆ FactoryStore

template<typename Key , typename BaseClass , typename... Args>
using RINGMesh::Factory< Key, BaseClass, Args >::FactoryStore = std::map< Key, Creator >

Definition at line 115 of file factory.h.

Member Function Documentation

◆ create()

template<typename Key , typename BaseClass , typename... Args>
static std::unique_ptr< BaseClass > RINGMesh::Factory< Key, BaseClass, Args >::create ( const Key &  key,
const Args &...  args 
)
inlinestatic

Definition at line 85 of file factory.h.

◆ create_function_impl()

template<typename Key , typename BaseClass , typename... Args>
template<typename DerivedClass >
static std::unique_ptr< BaseClass > RINGMesh::Factory< Key, BaseClass, Args >::create_function_impl ( Args &&...  args)
inlinestaticprivate

Definition at line 119 of file factory.h.

◆ has_creator()

template<typename Key , typename BaseClass , typename... Args>
static bool RINGMesh::Factory< Key, BaseClass, Args >::has_creator ( const Key &  key)
inlinestatic

Definition at line 108 of file factory.h.

◆ list_creators()

template<typename Key , typename BaseClass , typename... Args>
static std::vector< Key > RINGMesh::Factory< Key, BaseClass, Args >::list_creators ( )
inlinestatic

Definition at line 97 of file factory.h.

◆ register_creator()

template<typename Key , typename BaseClass , typename... Args>
template<typename DerivedClass >
static void RINGMesh::Factory< Key, BaseClass, Args >::register_creator ( const Key &  key)
inlinestatic

Definition at line 68 of file factory.h.

Member Data Documentation

◆ store_

template<typename Key , typename BaseClass , typename... Args>
Factory< Key, BaseClass, Args... >::FactoryStore RINGMesh::Factory< Key, BaseClass, Args >::store_
staticprivate

Definition at line 126 of file factory.h.


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