public

Inheritance Graph

graph BT
	LambdaFactory
	click LambdaFactory "classUtil_1_1LambdaFactory"

Description

Generic factory for objects allowing lambdas with variable number of arguments as creator functions.

The factory template can be instaniated to generate different kinds of factories. The generated factory generates objects of typeObjectType.

Parameters

ObjectType
Base type for all objects that are generated by the factory
IdentifierType
Type of the identifier that specifies which object creator to call
FallbackPolicy
Template with a functiononUnknownType()that handles the case that the requested object type was not found

Author: Sascha Brandt

Date: 2015-05-22

See also: http://meh.schizofreni.co/programming/magic/2013/01/23/function-pointer-from-lambda.html

Classes

   
struct Util::LambdaFactory::Creator

Public Types

   
   
typedef FallbackPolicy< ObjectType, IdentifierType > fallbackPolicy_t

Public Attributes

   
   
fallbackPolicy_t fallbackPolicy

Public Functions

   
   
  LambdaFactory()
   
  LambdaFactory( fallbackPolicy_t policy)
   
  ~LambdaFactory()
template< typename ObjectCreator >  
void registerType(const IdentifierType & id, ObjectCreator creator)
   
void unregisterType(const IdentifierType & id)
template< typename… Args >  
ObjectType create(const IdentifierType & id, Args… args)

Documentation

typedef
Util::LambdaFactory::fallbackPolicy_t

public
 
 
typedef FallbackPolicy< ObjectType, IdentifierType > fallbackPolicy_t

Defined in Util/Factory/LambdaFactory.h:75


variable
Util::LambdaFactory::fallbackPolicy

public
 
 
fallbackPolicy_t fallbackPolicy

Defined in Util/Factory/LambdaFactory.h:76


function
Util::LambdaFactory::LambdaFactory

public inline
   
   
LambdaFactory( )

Defined in Util/Factory/LambdaFactory.h:77


function
Util::LambdaFactory::LambdaFactory

public inline
     
     
LambdaFactory( fallbackPolicy_t policy )

Defined in Util/Factory/LambdaFactory.h:79


function
Util::LambdaFactory::~LambdaFactory

public inline
   
   
~LambdaFactory( )

Defined in Util/Factory/LambdaFactory.h:81


function
Util::LambdaFactory::registerType

public inline
     
template< typename ObjectCreator >    
void registerType( const IdentifierType & id,
  ObjectCreator creator
)    

Defined in Util/Factory/LambdaFactory.h:87


function
Util::LambdaFactory::unregisterType

public inline
     
     
void unregisterType( const IdentifierType & id )

Defined in Util/Factory/LambdaFactory.h:97


function
Util::LambdaFactory::create

public inline
     
template< typename… Args >    
ObjectType create( const IdentifierType & id,
  Args… args
)    

Defined in Util/Factory/LambdaFactory.h:105