aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::OperatorRegister4MultiDim< GUM_SCALAR > Class Template Reference

A container for registering binary functions on multiDimImplementations. More...

#include <agrum/multdim/operators/operatorRegister4MultiDim.h>

+ Collaboration diagram for gum::OperatorRegister4MultiDim< GUM_SCALAR >:

Public Member Functions

Accessors / Modifiers
void insert (const std::string &operation_name, const std::string &type1, const std::string &type2, OperatorPtr newFunction)
 adds a new entry into the register More...
 
void erase (const std::string &operation_name, const std::string &type1, const std::string &type2)
 removes a given entry from the register More...
 
bool exists (const std::string &operation_name, const std::string &type1, const std::string &type2) const
 Indicates whether a given entry exists in the register. More...
 
OperatorPtr get (const std::string &operation_name, const std::string &type1, const std::string &type2) const
 returns the specialized operator assigned to a given pair of MultiDimImplementations More...
 

Static Public Member Functions

Named Constructors
static OperatorRegister4MultiDim< GUM_SCALAR > & Register ()
 A named constructor that constructs one and only one Register per data type. More...
 

Public Types

typedef MultiDimImplementation< GUM_SCALAR > *(* OperatorPtr) (const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *)
 The type of functions used by the register. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::OperatorRegister4MultiDim< GUM_SCALAR >

A container for registering binary functions on multiDimImplementations.

Definition at line 58 of file operatorRegister4MultiDim.h.

Member Typedef Documentation

◆ OperatorPtr

template<typename GUM_SCALAR >
typedef MultiDimImplementation< GUM_SCALAR >*(* gum::OperatorRegister4MultiDim< GUM_SCALAR >::OperatorPtr) (const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *)

The type of functions used by the register.

Definition at line 61 of file operatorRegister4MultiDim.h.

◆ OperatorSet

template<typename GUM_SCALAR >
typedef HashTable< std::pair< std::string, std::string >, OperatorPtr > gum::OperatorRegister4MultiDim< GUM_SCALAR >::OperatorSet
private

The set of associations for a given operation type.

Definition at line 200 of file operatorRegister4MultiDim.h.

Constructor & Destructor Documentation

◆ OperatorRegister4MultiDim() [1/2]

template<typename GUM_SCALAR >
gum::OperatorRegister4MultiDim< GUM_SCALAR >::OperatorRegister4MultiDim ( )
private

Default constructor: creates an empty register.

◆ OperatorRegister4MultiDim() [2/2]

template<typename GUM_SCALAR >
gum::OperatorRegister4MultiDim< GUM_SCALAR >::OperatorRegister4MultiDim ( const OperatorRegister4MultiDim< GUM_SCALAR > &  )
private

Copy operator: never to be used.

◆ ~OperatorRegister4MultiDim()

template<typename GUM_SCALAR >
gum::OperatorRegister4MultiDim< GUM_SCALAR >::~OperatorRegister4MultiDim ( )
private

Destructor.

Member Function Documentation

◆ erase()

template<typename GUM_SCALAR >
void gum::OperatorRegister4MultiDim< GUM_SCALAR >::erase ( const std::string &  operation_name,
const std::string &  type1,
const std::string &  type2 
)

removes a given entry from the register

removes the function, if any, that performs the operation described by operation_name, and that takes in argument a multiDim of type type1 and one multiDim of type type2

Parameters
operation_namedescribes the name of the operation performed by the function to remove. Usual operation names are "+", "*", "/", "-", "max", "min"
type1the real type of the first multiDim taken in argument by the function to remove
type2the real type of the second multiDim taken in argument by the function to remove.

◆ exists()

template<typename GUM_SCALAR >
bool gum::OperatorRegister4MultiDim< GUM_SCALAR >::exists ( const std::string &  operation_name,
const std::string &  type1,
const std::string &  type2 
) const

Indicates whether a given entry exists in the register.

Indicates if the register contains a function that performs the operation described by operation_name, and that takes in argument a multiDim of type type1 and one multiDim of type type2

Parameters
operation_namedescribes the name of the operation performed by the function we look for. Usual operation names are "+", "*", "/", "-", "max", "min"
type1the real type of the first multiDim taken in argument by the function we look for
type2the real type of the second multiDim taken in argument by the function we look for

◆ get()

template<typename GUM_SCALAR >
OperatorPtr gum::OperatorRegister4MultiDim< GUM_SCALAR >::get ( const std::string &  operation_name,
const std::string &  type1,
const std::string &  type2 
) const

returns the specialized operator assigned to a given pair of MultiDimImplementations

returns the function, if any, that performs the operation described by operation_name, and that takes in argument a multiDim of type type1 and one multiDim of type type2

Parameters
operation_namedescribes the name of the operation performed by the function we look for. Usual operation names are "+", "*", "/", "-", "max", "min"
type1the real type of the first multiDim taken in argument by the function we look for
type2the real type of the second multiDim taken in argument by the function we look for
Exceptions
NotFoundexception is thrown if the operator we look for does not exist within this register.

◆ insert()

template<typename GUM_SCALAR >
void gum::OperatorRegister4MultiDim< GUM_SCALAR >::insert ( const std::string &  operation_name,
const std::string &  type1,
const std::string &  type2,
OperatorPtr  newFunction 
)

adds a new entry into the register

This method inserts a new function (newFunction) taking two multiDim in arguments of types type1 and type2 respectively (which actually inherit from MultiDimImplementation). This new function's purpose is to achieve the operator described by operation_name. For instance, if operator_name is "+", "-", "/" or "*", the new function performs the usual algebraic operations.

Parameters
operation_namedescribes the name of the operation performed by newFunction. Usual operation names are "+", "*", "/", "-", "max", "min"
type1the real type of the first multiDim taken in argument by function newFunction
type2the real type of the second multiDim taken in argument by function newFunction
newFunctiona pointer to the new function to register. Note that although newFunction actually performs an operation on multiDims of types type1 and type2, it should be declared as taking in argument two MultiDimImplementations. This constraint is imposed by the C++ typing system.

◆ Register()

template<typename GUM_SCALAR >
static OperatorRegister4MultiDim< GUM_SCALAR >& gum::OperatorRegister4MultiDim< GUM_SCALAR >::Register ( )
static

A named constructor that constructs one and only one Register per data type.

Note that this constructor prevents the famous init order fiasco.

Member Data Documentation

◆ _set_

template<typename GUM_SCALAR >
HashTable< std::string, OperatorSet* > gum::OperatorRegister4MultiDim< GUM_SCALAR >::_set_
private

A mapping from pairs of types of MultiDimImplementations to operators.

In this type, the strings represent the very types of the MultiDimImplementations that will be combined. To a pair of strings, hence to a pair of types of MultiDimImplementations, is associated a function to combine them (the OperatorPtr).

Definition at line 211 of file operatorRegister4MultiDim.h.


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