aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::MultiDimAdressable Class Referenceabstract

Abstract base class for all multi dimensionnal addressable. More...

#include <agrum/base/multidim/multiDimAdressable.h>

Inheritance diagram for gum::MultiDimAdressable:
Collaboration diagram for gum::MultiDimAdressable:

Public Member Functions

Constructors / Destructors
 MultiDimAdressable ()
 Default constructor.
 MultiDimAdressable (const MultiDimAdressable &from)
 Copy constructor.
MultiDimAdressableoperator= (const MultiDimAdressable &from)
 Default constructor.
 MultiDimAdressable (MultiDimAdressable &&) noexcept
 Class move constructor.
MultiDimAdressableoperator= (MultiDimAdressable &&from) noexcept
 Default constructor.
 ~MultiDimAdressable () override
 Destructor.
Slave management and extension due to slave management
virtual MultiDimAdressablegetMasterRef ()=0
 In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
virtual const MultiDimAdressablegetMasterRef () const =0
 In order to insure the dereference for decorators, we need to virtualize the access to master pointer.
virtual bool registerSlave (Instantiation &i)=0
 Register i as a slave of this MultiDimAdressable.
virtual bool unregisterSlave (Instantiation &i)=0
 Unregister i as a slave of this MultiDimAdressable.
virtual void changeNotification (const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval)=0
 Listen to changes in a given Instantiation.
virtual void setFirstNotification (const Instantiation &i)=0
 Listen to setFirst in a given Instantiation.
virtual void setLastNotification (const Instantiation &i)=0
 Listen to setLast in a given Instantiation.
virtual void setIncNotification (const Instantiation &i)=0
 Listen to increment in a given Instantiation.
virtual void setDecNotification (const Instantiation &i)=0
 Listen to increment in each recorded Instantiation.
virtual void setChangeNotification (const Instantiation &i)=0
 Listen to an assignment of a value in a Instantiation.
virtual std::string toString (const Instantiation *i) const =0
 Return a string representation of internal data about i in this.
Accessors / Modifiers
virtual Idx nbrDim () const =0
 Returns the number of vars in the multidimensional container.
virtual Size domainSize () const =0
 Returns the product of the variables domain size.
virtual void add (const DiscreteVariable &v)=0
 Adds a new var to the variables of the multidimensional matrix.
virtual void erase (const DiscreteVariable &v)=0
 Removes a var from the variables of the multidimensional matrix.
virtual const Sequence< const DiscreteVariable * > & variablesSequence () const =0
 Returns a const ref to the sequence of DiscreteVariable*.
virtual const DiscreteVariablevariable (Idx i) const =0
 Returns a const ref to the ith var.
virtual const DiscreteVariablevariable (const std::string &name) const =0
 Returns the variable with the name.
virtual Idx pos (const DiscreteVariable &v) const =0
 Returns the index of a variable.
virtual bool contains (const DiscreteVariable &v) const =0
 Returns true if var is in *this.
virtual bool empty () const =0
 Returns true if no var is in *this.
void replace (const DiscreteVariable &x, const DiscreteVariable &y)
 Replace variables in this multidim.

Protected Member Functions

virtual void replace_ (const DiscreteVariable *x, const DiscreteVariable *y)=0
 This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.

Detailed Description

Abstract base class for all multi dimensionnal addressable.

MultiDimAdressable is the abstract base class for all multi dimensionnal adressable. Its purpose is to deal with slave Instantiation and notification.

Definition at line 78 of file multiDimAdressable.h.

Constructor & Destructor Documentation

◆ MultiDimAdressable() [1/3]

INLINE gum::MultiDimAdressable::MultiDimAdressable ( )

Default constructor.

Definition at line 65 of file multiDimAdressable_inl.h.

65{ GUM_CONSTRUCTOR(MultiDimAdressable); }
MultiDimAdressable()
Default constructor.

References MultiDimAdressable().

Referenced by MultiDimAdressable(), MultiDimAdressable(), MultiDimAdressable(), gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), gum::MultiDimContainer< GUM_SCALAR >::MultiDimContainer(), ~MultiDimAdressable(), gum::MultiDimContainer< GUM_SCALAR >::content(), getMasterRef(), getMasterRef(), gum::MultiDimContainer< GUM_SCALAR >::getMasterRef(), gum::MultiDimContainer< GUM_SCALAR >::getMasterRef(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MultiDimAdressable() [2/3]

INLINE gum::MultiDimAdressable::MultiDimAdressable ( const MultiDimAdressable & from)

Copy constructor.

Definition at line 67 of file multiDimAdressable_inl.h.

67 {
68 GUM_CONS_CPY(MultiDimAdressable);
69 }

References MultiDimAdressable().

Here is the call graph for this function:

◆ MultiDimAdressable() [3/3]

INLINE gum::MultiDimAdressable::MultiDimAdressable ( MultiDimAdressable && from)
noexcept

Class move constructor.

Definition at line 60 of file multiDimAdressable_inl.h.

60 :
61 MultiDimInterface(std::forward< MultiDimInterface >(from)) {
62 GUM_CONS_MOV(MultiDimAdressable);
63 }

References MultiDimAdressable().

Here is the call graph for this function:

◆ ~MultiDimAdressable()

INLINE gum::MultiDimAdressable::~MultiDimAdressable ( )
override

Destructor.

Definition at line 71 of file multiDimAdressable_inl.h.

71{ GUM_DESTRUCTOR(MultiDimAdressable); }

References MultiDimAdressable().

Here is the call graph for this function:

Member Function Documentation

◆ add()

virtual void gum::MultiDimInterface::add ( const DiscreteVariable & v)
pure virtualinherited

Adds a new var to the variables of the multidimensional matrix.

See also
operator<<(MultiDimInterface& c, const DiscreteVariable& v)
Warning
Note that the variable passed in argument is not duplicated, that is, only a pointer toward the variable is kept by the MultiDimInterface.
Parameters
vThe new var.
Exceptions
DuplicateElementRaised if the variable already belongs to the sequence of variables.
OperationNotAllowedRaised if this object is non mutable.

Implemented in gum::Instantiation, gum::MultiDimArray< GUM_SCALAR >, gum::MultiDimBijArray< GUM_SCALAR >, gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimDecorator< GUM_SCALAR >, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< bool >, gum::MultiDimImplementation< double >, gum::MultiDimImplementation< gum::ActionSet >, gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const HashTable< const DiscreteVariable *, Idx > &), gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *), gum::MultiDimImplementation< Size >, gum::MultiDimImplementation< std::string >, gum::MultiDimSparse< GUM_SCALAR >, gum::MultiDimWithOffset< GUM_SCALAR >, and gum::VariableSet &)< GUM_SCALAR >.

Referenced by gum::operator<<().

Here is the caller graph for this function:

◆ changeNotification()

◆ contains()

◆ domainSize()

◆ empty()

◆ erase()

virtual void gum::MultiDimInterface::erase ( const DiscreteVariable & v)
pure virtualinherited

Removes a var from the variables of the multidimensional matrix.

See also
operator>>(MultiDimInterface& c, const DiscreteVariable& v)
Exceptions
OperationNotAllowedRaised if this object is non mutable.
NotFoundRaised if v does not belong to this.

Implemented in gum::Instantiation, gum::MultiDimArray< GUM_SCALAR >, gum::MultiDimBijArray< GUM_SCALAR >, gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimDecorator< GUM_SCALAR >, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< bool >, gum::MultiDimImplementation< double >, gum::MultiDimImplementation< gum::ActionSet >, gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const HashTable< const DiscreteVariable *, Idx > &), gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *), gum::MultiDimImplementation< Size >, gum::MultiDimImplementation< std::string >, gum::MultiDimSparse< GUM_SCALAR >, gum::MultiDimWithOffset< GUM_SCALAR >, and gum::VariableSet &)< GUM_SCALAR >.

Referenced by gum::MultiDimContainer< GUM_SCALAR >::copy(), and gum::operator>>().

Here is the caller graph for this function:

◆ getMasterRef() [1/2]

virtual const MultiDimAdressable & gum::MultiDimAdressable::getMasterRef ( ) const
pure virtual

In order to insure the dereference for decorators, we need to virtualize the access to master pointer.

Returns
Returns the master of this MultiDimAdressable.

Implemented in gum::MultiDimBucket< GUM_SCALAR >, and gum::MultiDimContainer< GUM_SCALAR >.

References MultiDimAdressable().

Here is the call graph for this function:

◆ getMasterRef() [2/2]

virtual MultiDimAdressable & gum::MultiDimAdressable::getMasterRef ( )
pure virtual

In order to insure the dereference for decorators, we need to virtualize the access to master pointer.

Returns
Returns the master of this MultiDimAdressable.

Implemented in gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimContainer< GUM_SCALAR >, gum::MultiDimContainer< bool >, gum::MultiDimContainer< double >, gum::MultiDimContainer< gum::ActionSet >, gum::MultiDimContainer< Size >, and gum::MultiDimContainer< std::string >.

References MultiDimAdressable().

Referenced by gum::Instantiation::_init_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nbrDim()

◆ operator=() [1/2]

INLINE MultiDimAdressable & gum::MultiDimAdressable::operator= ( const MultiDimAdressable & from)

Default constructor.

Definition at line 73 of file multiDimAdressable_inl.h.

73 {
74 GUM_OP_CPY(MultiDimAdressable);
75 MultiDimInterface::operator=(from);
76 return *this;
77 }

References MultiDimAdressable().

Referenced by gum::MultiDimContainer< GUM_SCALAR >::operator=(), and gum::MultiDimContainer< GUM_SCALAR >::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

INLINE MultiDimAdressable & gum::MultiDimAdressable::operator= ( MultiDimAdressable && from)
noexcept

Default constructor.

Definition at line 79 of file multiDimAdressable_inl.h.

79 {
80 GUM_OP_MOV(MultiDimAdressable);
81 MultiDimInterface::operator=(std::forward< MultiDimInterface >(from));
82 return *this;
83 }

References MultiDimAdressable().

Here is the call graph for this function:

◆ pos()

◆ registerSlave()

◆ replace()

INLINE void gum::MultiDimInterface::replace ( const DiscreteVariable & x,
const DiscreteVariable & y )
inherited

Replace variables in this multidim.

If x is in this MultiDim and y has the same domain size, then x will be replace by y in this MultiDim.

Parameters
xThe variable in this which will be replaced.
yThe variable replacing y.
Exceptions
NotFoundRaised if x does not belong to this MultiDim.
OperationNotAllowedIf y and x are not interchangeable.
DuplicateElementIf y is already in this MultiDim.

Definition at line 56 of file multiDimInterface_inl.h.

56 {
57 if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable") }
58
59 if (contains(y)) { GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim") }
60
61 if (x.domainSize() != y.domainSize()) {
62 GUM_ERROR(OperationNotAllowed, "incompatible variables")
63 }
64
65 replace_(&x, &y);
66 }
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y)=0
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References contains(), gum::DiscreteVariable::domainSize(), GUM_ERROR, and replace_().

Here is the call graph for this function:

◆ replace_()

virtual void gum::MultiDimInterface::replace_ ( const DiscreteVariable * x,
const DiscreteVariable * y )
protectedpure virtualinherited

This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.

This is called only when everything have been checked.

Parameters
xThe variable to replace in
yThe second variable to swap.

Implemented in gum::Instantiation, gum::MultiDimArray< GUM_SCALAR >, gum::MultiDimBijArray< GUM_SCALAR >, gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimDecorator< GUM_SCALAR >, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >, gum::MultiDimICIModel< GUM_SCALAR >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< bool >, gum::MultiDimImplementation< double >, gum::MultiDimImplementation< gum::ActionSet >, gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const HashTable< const DiscreteVariable *, Idx > &), gum::MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *), gum::MultiDimImplementation< Size >, gum::MultiDimImplementation< std::string >, gum::MultiDimSparse< GUM_SCALAR >, and gum::VariableSet &)< GUM_SCALAR >.

Referenced by replace().

Here is the caller graph for this function:

◆ setChangeNotification()

◆ setDecNotification()

◆ setFirstNotification()

◆ setIncNotification()

◆ setLastNotification()

◆ toString()

◆ unregisterSlave()

◆ variable() [1/2]

virtual const DiscreteVariable & gum::MultiDimInterface::variable ( const std::string & name) const
pure virtualinherited

◆ variable() [2/2]

virtual const DiscreteVariable & gum::MultiDimInterface::variable ( Idx i) const
pure virtualinherited

◆ variablesSequence()


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