libgsjj  1
Deterministic finite automata learning library
Public Types | Public Member Functions | Static Public Member Functions | List of all members
gsjj::passive::MethodFactory Class Reference

The Factory Builder design pattern adapted to our methods. More...

#include <MethodFactory.h>

Public Types

using MethodPtr = std::unique_ptr< Method >
 The type the function create will return. More...
 
using MethodConstructor = std::function< MethodPtr(const std::set< std::string > &Sp, const std::set< std::string > &Sm, const std::set< std::string > &S, const std::set< std::string > &prefixes, const std::set< char > &alphabet, unsigned int n)>
 The type of the constructor the registerMethod must receive. More...
 

Public Member Functions

 MethodFactory ()=delete
 

Static Public Member Functions

static bool registerMethod (const std::string &name, MethodConstructor const &constructor)
 Registers a method. More...
 
static MethodPtr create (const std::string &name, unsigned int n, const std::set< std::string > &Sp, const std::set< std::string > &Sm, const std::set< std::string > &S, const std::set< std::string > &prefixes, const std::set< char > &alphabet)
 Creates a unique_ptr to a method. More...
 

Detailed Description

The Factory Builder design pattern adapted to our methods.

The methods must register themselves to this factory.

Some implementation details are inspired from https://dzone.com/articles/factory-with-self-registering-types

Definition at line 19 of file MethodFactory.h.

Member Typedef Documentation

◆ MethodConstructor

using gsjj::passive::MethodFactory::MethodConstructor = std::function<MethodPtr( const std::set<std::string>& Sp, const std::set<std::string>& Sm, const std::set<std::string>& S, const std::set<std::string>& prefixes, const std::set<char>& alphabet, unsigned int n )>

The type of the constructor the registerMethod must receive.

Definition at line 35 of file MethodFactory.h.

◆ MethodPtr

The type the function create will return.

Definition at line 24 of file MethodFactory.h.

Constructor & Destructor Documentation

◆ MethodFactory()

gsjj::passive::MethodFactory::MethodFactory ( )
delete

Member Function Documentation

◆ create()

MethodFactory::MethodPtr gsjj::passive::MethodFactory::create ( const std::string &  name,
unsigned int  n,
const std::set< std::string > &  Sp,
const std::set< std::string > &  Sm,
const std::set< std::string > &  S,
const std::set< std::string > &  prefixes,
const std::set< char > &  alphabet 
)
static

Creates a unique_ptr to a method.

The method must have been registered before!

Please use constructMethod instead of this function

Parameters
nameThe name of the method to construct
nThe number of states
SpThe $S_+$ set
SmThe $S_-$ set
SThe $S = S_+ \cup S_-$
prefixesThe prefixes set
alphabetThe alphabet
See also
registerMethod, constructMethod

Definition at line 31 of file MethodFactory.cpp.

◆ registerMethod()

bool gsjj::passive::MethodFactory::registerMethod ( const std::string &  name,
MethodConstructor const &  constructor 
)
static

Registers a method.

Parameters
nameThe name of the method to register
constructorA pointer to the constructor of the method
Returns
True iff it was possible to register the method
See also
gsjj::passive::RegisterInFactory

Definition at line 19 of file MethodFactory.cpp.


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