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

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

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

Collaboration diagram for gum::OperatorRegister4MultiDim< GUM_ELEMENT >:

Public Types

using OperatorPtr
 The type of functions used by the register.

Public Member Functions

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

Static Public Member Functions

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

Private Types

using OperatorSet = HashTable< std::pair< std::string, std::string >, OperatorPtr >
 The set of associations for a given operation type.

Private Member Functions

Constructors / Destructors
 OperatorRegister4MultiDim ()
 Default constructor: creates an empty register.
 OperatorRegister4MultiDim (const OperatorRegister4MultiDim< GUM_ELEMENT > &)
 Copy operator: never to be used.
 ~OperatorRegister4MultiDim ()
 Destructor.

Private Attributes

HashTable< std::string, OperatorSet * > _set_
 A mapping from pairs of types of MultiDimImplementations to operators.

Detailed Description

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

A container for registering binary functions on multiDimImplementations.

Definition at line 83 of file operatorRegister4MultiDim.h.

Member Typedef Documentation

◆ OperatorPtr

template<typename GUM_ELEMENT>
using gum::OperatorRegister4MultiDim< GUM_ELEMENT >::OperatorPtr
Initial value:

The type of functions used by the register.

Definition at line 86 of file operatorRegister4MultiDim.h.

◆ OperatorSet

template<typename GUM_ELEMENT>
using gum::OperatorRegister4MultiDim< GUM_ELEMENT >::OperatorSet = HashTable< std::pair< std::string, std::string >, OperatorPtr >
private

The set of associations for a given operation type.

Definition at line 222 of file operatorRegister4MultiDim.h.

Constructor & Destructor Documentation

◆ OperatorRegister4MultiDim() [1/2]

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

Default constructor: creates an empty register.

Referenced by OperatorRegister4MultiDim(), and Register().

Here is the caller graph for this function:

◆ OperatorRegister4MultiDim() [2/2]

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

Copy operator: never to be used.

References OperatorRegister4MultiDim().

Here is the call graph for this function:

◆ ~OperatorRegister4MultiDim()

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

Destructor.

Member Function Documentation

◆ erase()

template<typename GUM_ELEMENT>
void gum::OperatorRegister4MultiDim< GUM_ELEMENT >::erase ( std::string_view operation_name,
std::string_view type1,
std::string_view 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_ELEMENT>
bool gum::OperatorRegister4MultiDim< GUM_ELEMENT >::exists ( std::string_view operation_name,
std::string_view type1,
std::string_view 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_ELEMENT>
OperatorPtr gum::OperatorRegister4MultiDim< GUM_ELEMENT >::get ( std::string_view operation_name,
std::string_view type1,
std::string_view 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_ELEMENT>
void gum::OperatorRegister4MultiDim< GUM_ELEMENT >::insert ( std::string_view operation_name,
std::string_view type1,
std::string_view 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_ELEMENT>
OperatorRegister4MultiDim< GUM_ELEMENT > & gum::OperatorRegister4MultiDim< GUM_ELEMENT >::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.

References OperatorRegister4MultiDim().

Here is the call graph for this function:

Member Data Documentation

◆ _set_

template<typename GUM_ELEMENT>
HashTable< std::string, OperatorSet* > gum::OperatorRegister4MultiDim< GUM_ELEMENT >::_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 233 of file operatorRegister4MultiDim.h.


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