This class allow you to create a factory for anytype of the Base class (FactoryType) with anytype of identifier (ClassIdentifier) More...

#include <ifactory.h>

Collaboration diagram for dnai::interfaces::IFactory< FactoryType, ClassIdentifier >:
Collaboration graph

Public Member Functions

 IFactory ()=default
 
FactoryType * create (Key ci)
Return a new instance of type (FactoryType) with the identifier of type (ClassIdentifier) More...
 
template<typename TrueType , typename... Args>
void registerObject (Key ci, Args &&...args)
Register a new class of type (TrueType) witch derived of base type (FactoryType) and assign an identifier of type ClassIdentifier. More...
 

Private Types

using Callback = std::function< FactoryType *()>
 
using Key = typename std::conditional< std::is_enum< ClassIdentifier >::value, int, ClassIdentifier >::type
 

Private Attributes

std::map< Key, Callbackm_factoryObjects
 

Detailed Description

template<typename FactoryType, class ClassIdentifier>
class dnai::interfaces::IFactory< FactoryType, ClassIdentifier >

This class allow you to create a factory for anytype of the Base class (FactoryType) with anytype of identifier (ClassIdentifier)

Member Typedef Documentation

template<typename FactoryType , class ClassIdentifier >
using dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::Callback = std::function<FactoryType *()>
private
template<typename FactoryType , class ClassIdentifier >
using dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::Key = typename std::conditional<std::is_enum<ClassIdentifier>::value, int, ClassIdentifier>::type
private

Constructor & Destructor Documentation

template<typename FactoryType , class ClassIdentifier >
dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::IFactory ( )
default

Member Function Documentation

template<typename FactoryType , class ClassIdentifier >
FactoryType* dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::create ( Key  ci)
inline

Return a new instance of type (FactoryType) with the identifier of type (ClassIdentifier)

Parameters
ci
Returns
return the new instance of object or nullptr if an error occur
template<typename FactoryType , class ClassIdentifier >
template<typename TrueType , typename... Args>
void dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::registerObject ( Key  ci,
Args &&...  args 
)
inline

Register a new class of type (TrueType) witch derived of base type (FactoryType) and assign an identifier of type ClassIdentifier.

Template Parameters
TrueType
Args
Parameters
ci
args

Member Data Documentation

template<typename FactoryType , class ClassIdentifier >
std::map<Key, Callback> dnai::interfaces::IFactory< FactoryType, ClassIdentifier >::m_factoryObjects
private

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