Minsky
minsky::OperationFactory< Base, T, N > Class Template Reference

factory class template, for creating objects of type T<O>. N is the maximum value of O More...

#include <operationType.h>

Collaboration diagram for minsky::OperationFactory< Base, T, N >:
Collaboration graph

Classes

struct  Creator
 
struct  CreatorBase
 
struct  is_equal
 

Public Member Functions

template<int I>
classdesc::enable_if< classdesc::Not< is_equal< I, N > >, void >::T registerNext ()
 
template<int I>
classdesc::enable_if< is_equal< I, N >, void >::T registerNext ()
 
Base * create (OperationType::Type o) const
 create an object of type T<o> on the heap More...
 
 OperationFactory ()
 

Private Attributes

std::vector< std::unique_ptr< CreatorBase > > creators
 

Detailed Description

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
class minsky::OperationFactory< Base, T, N >

factory class template, for creating objects of type T<O>. N is the maximum value of O

Definition at line 76 of file operationType.h.

Constructor & Destructor Documentation

◆ OperationFactory()

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
minsky::OperationFactory< Base, T, N >::OperationFactory ( )
inline

Definition at line 116 of file operationType.h.

116 {registerNext<OperationType::Type(0)>();}

Member Function Documentation

◆ create()

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
Base* minsky::OperationFactory< Base, T, N >::create ( OperationType::Type  o) const
inline

create an object of type T<o> on the heap

Definition at line 111 of file operationType.h.

References minsky::OperationFactory< Base, T, N >::creators.

111  {
112  assert(o<creators.size());
113  return creators[o]->create();
114  }
std::vector< std::unique_ptr< CreatorBase > > creators
Definition: operationType.h:84

◆ registerNext() [1/2]

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
template<int I>
classdesc::enable_if<classdesc::Not<is_equal<I,N> >,void>::T minsky::OperationFactory< Base, T, N >::registerNext ( )
inline

Definition at line 100 of file operationType.h.

References minsky::OperationFactory< Base, T, N >::creators.

101  {
102  creators.emplace_back(new Creator<T<OperationType::Type(I)>>);
103  registerNext<I+1>();
104  }
std::vector< std::unique_ptr< CreatorBase > > creators
Definition: operationType.h:84

◆ registerNext() [2/2]

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
template<int I>
classdesc::enable_if<is_equal<I,N>,void>::T minsky::OperationFactory< Base, T, N >::registerNext ( )
inline

Definition at line 107 of file operationType.h.

References minsky::OperationFactory< Base, T, N >::creators.

108  {creators.emplace_back(new Creator<T<OperationType::Type(I)>>);}
std::vector< std::unique_ptr< CreatorBase > > creators
Definition: operationType.h:84

Member Data Documentation

◆ creators

template<class Base, template< minsky::OperationType::Type > class T, int N = OperationType::numOps>
std::vector<std::unique_ptr<CreatorBase> > minsky::OperationFactory< Base, T, N >::creators
private

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