fuzzylite  6.0
A Fuzzy Logic Control Library in C++
fl::ConstructionFactory< T > Class Template Reference

The ConstructionFactory class is the base class for a factory whose objects are created from a registered ConstructionFactory::Constructor. More...

#include <ConstructionFactory.h>

Inheritance diagram for fl::ConstructionFactory< T >:
Collaboration diagram for fl::ConstructionFactory< T >:

Public Types

typedef T(* Constructor) ()
 The Constructor type definition refers to a zero-parameter method which returns an instance of T. More...
 

Public Member Functions

 ConstructionFactory (const std::string &name)
 
virtual ~ConstructionFactory ()
 
virtual std::string name () const
 Returns the name of the factory. More...
 
virtual void registerConstructor (const std::string &key, Constructor constructor)
 Registers the constructor in the factory. More...
 
virtual void deregisterConstructor (const std::string &key)
 Deregisters from the factory the constructor associated to the given key. More...
 
virtual bool hasConstructor (const std::string &key) const
 Checks whether the factory has a constructor registered by the given key. More...
 
virtual Constructor getConstructor (const std::string &key) const
 Gets the constructor registered by the given key. More...
 
virtual T constructObject (const std::string &key) const
 Creates an object by executing the constructor associated to the given key. More...
 
virtual std::vector< std::string > available () const
 Returns a vector of keys for the constructors available. More...
 
virtual std::map< std::string, Constructor > & constructors ()
 Gets the map of registered keys and constructors. More...
 
virtual const std::map< std::string, Constructor > & constructors () const
 Gets an immutable map of registered keys and constructors. More...
 

Detailed Description

template<typename T>
class fl::ConstructionFactory< T >

The ConstructionFactory class is the base class for a factory whose objects are created from a registered ConstructionFactory::Constructor.

Author
Juan Rada-Vilela, Ph.D.
See also
FactoryManager
Since
5.0

Definition at line 38 of file ConstructionFactory.h.

Member Typedef Documentation

◆ Constructor

template<typename T>
typedef T(* fl::ConstructionFactory< T >::Constructor) ()

The Constructor type definition refers to a zero-parameter method which returns an instance of T.

Definition at line 44 of file ConstructionFactory.h.

Constructor & Destructor Documentation

◆ ConstructionFactory()

template<typename T >
fl::ConstructionFactory< T >::ConstructionFactory ( const std::string &  name)
inlineexplicit

Definition at line 124 of file ConstructionFactory.h.

◆ ~ConstructionFactory()

template<typename T >
fl::ConstructionFactory< T >::~ConstructionFactory ( )
inlinevirtual

Definition at line 129 of file ConstructionFactory.h.

Member Function Documentation

◆ available()

template<typename T >
std::vector< std::string > fl::ConstructionFactory< T >::available ( ) const
inlinevirtual

Returns a vector of keys for the constructors available.

Returns
a vector of keys for the constructors available

Definition at line 180 of file ConstructionFactory.h.

◆ constructObject()

template<typename T >
T fl::ConstructionFactory< T >::constructObject ( const std::string &  key) const
inlinevirtual

Creates an object by executing the constructor associated to the given key.

Parameters
keyis the unique name by which constructors are registered
Returns
an object by executing the constructor associated to the given key

Definition at line 166 of file ConstructionFactory.h.

◆ constructors() [1/2]

template<typename T >
std::map< std::string, typename ConstructionFactory< T >::Constructor > & fl::ConstructionFactory< T >::constructors ( )
inlinevirtual

Gets the map of registered keys and constructors.

Returns
the map of registered keys and constructors

Definition at line 191 of file ConstructionFactory.h.

◆ constructors() [2/2]

template<typename T >
const std::map< std::string, typename ConstructionFactory< T >::Constructor > & fl::ConstructionFactory< T >::constructors ( ) const
inlinevirtual

Gets an immutable map of registered keys and constructors.

Returns
an immutable map of registered keys and constructors

Definition at line 196 of file ConstructionFactory.h.

◆ deregisterConstructor()

template<typename T >
void fl::ConstructionFactory< T >::deregisterConstructor ( const std::string &  key)
inlinevirtual

Deregisters from the factory the constructor associated to the given key.

Parameters
keyis the unique name by which constructors are registered

Definition at line 143 of file ConstructionFactory.h.

◆ getConstructor()

template<typename T >
ConstructionFactory< T >::Constructor fl::ConstructionFactory< T >::getConstructor ( const std::string &  key) const
inlinevirtual

Gets the constructor registered by the given key.

Parameters
keyis the unique name by which constructors are registered
Returns
the pointer to the given constructor

Definition at line 157 of file ConstructionFactory.h.

◆ hasConstructor()

template<typename T >
bool fl::ConstructionFactory< T >::hasConstructor ( const std::string &  key) const
inlinevirtual

Checks whether the factory has a constructor registered by the given key.

Parameters
keyis the unique name by which constructors are registered
Returns
whether the factory has the given constructor registered

Definition at line 151 of file ConstructionFactory.h.

◆ name()

template<typename T >
std::string fl::ConstructionFactory< T >::name ( ) const
inlinevirtual

Returns the name of the factory.

Returns
the name of the factory

Definition at line 133 of file ConstructionFactory.h.

◆ registerConstructor()

template<typename T >
void fl::ConstructionFactory< T >::registerConstructor ( const std::string &  key,
Constructor  constructor 
)
inlinevirtual

Registers the constructor in the factory.

Parameters
keyis the unique name by which constructors are registered
constructoris the pointer to the constructor of the object

Definition at line 138 of file ConstructionFactory.h.


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