aGrUM  0.13.3
gum::MultiDimAdressable Class Referenceabstract

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

#include <agrum/multidim/multiDimAdressable.h>

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

Public Member Functions

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

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. More...
 

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 56 of file multiDimAdressable.h.

Constructor & Destructor Documentation

◆ MultiDimAdressable() [1/3]

INLINE gum::MultiDimAdressable::MultiDimAdressable ( )

Default constructor.

Definition at line 42 of file multiDimAdressable_inl.h.

42  {
43  GUM_CONSTRUCTOR(MultiDimAdressable);
44  }
MultiDimAdressable()
Default constructor.

◆ MultiDimAdressable() [2/3]

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

Copy constructor.

Definition at line 47 of file multiDimAdressable_inl.h.

47  {
48  GUM_CONS_CPY(MultiDimAdressable);
49  }
MultiDimAdressable()
Default constructor.

◆ MultiDimAdressable() [3/3]

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

Class move constructor.

Definition at line 37 of file multiDimAdressable_inl.h.

37  :
38  MultiDimInterface(std::forward< MultiDimInterface >(from)) {
39  GUM_CONS_MOV(MultiDimAdressable);
40  }
MultiDimAdressable()
Default constructor.

◆ ~MultiDimAdressable()

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

Destructor.

Definition at line 51 of file multiDimAdressable_inl.h.

References operator=().

51  {
52  GUM_DESTRUCTOR(MultiDimAdressable);
53  }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ _replace()

◆ 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::MultiDimBucket< GUM_SCALAR >, gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >, gum::MultiDimFunctionGraph< Size >, gum::MultiDimFunctionGraph< double >, gum::MultiDimFunctionGraph< GUM_SCALAR >, gum::MultiDimFunctionGraph< double, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< Size, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< GUM_SCALAR, ExactTerminalNodePolicy >, gum::MultiDimFunctionGraph< gum::ActionSet, gum::SetTerminalNodePolicy >, gum::MultiDimFunctionGraph< bool >, gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, gum::MultiDimArray< GUM_SCALAR >, gum::MultiDimBijArray< GUM_SCALAR >, gum::MultiDimDecorator< GUM_SCALAR >, gum::MultiDimSparse< GUM_SCALAR >, and gum::MultiDimWithOffset< GUM_SCALAR >.

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

+ Here is the caller graph for this function:

◆ changeNotification()

◆ contains()

virtual bool gum::MultiDimInterface::contains ( const DiscreteVariable v) const
pure virtualinherited

Returns true if var is in *this.

Parameters
vA DiscreteVariable.
Returns
Returns true if var is in *this.

Implemented in gum::Instantiation, gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::MultiDimInterface::replace(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ domainSize()

virtual Size gum::MultiDimInterface::domainSize ( ) const
pure virtualinherited

Returns the product of the variables domain size.

Returns
Returns the product of the variables domain size.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::MultiDimICIModel< GUM_SCALAR >::copyFrom(), gum::MultiDimContainer< GUM_SCALAR >::copyFrom(), gum::MultiDimContainer< GUM_SCALAR >::operator==(), gum::MultiDimContainer< GUM_SCALAR >::populate(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ empty()

virtual bool gum::MultiDimInterface::empty ( ) const
pure virtualinherited

Returns true if no var is in *this.

Returns
Returns true if no var is in *this.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::Potential< GUM_SCALAR >::Potential(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ erase()

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

◆ getMasterRef() [1/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::MultiDimContainer< GUM_SCALAR >, and gum::MultiDimBucket< GUM_SCALAR >.

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

+ Here is the caller graph for this function:

◆ getMasterRef() [2/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::MultiDimContainer< GUM_SCALAR >, and gum::MultiDimBucket< GUM_SCALAR >.

◆ nbrDim()

virtual Idx gum::MultiDimInterface::nbrDim ( ) const
pure virtualinherited

Returns the number of vars in the multidimensional container.

Returns
Returns the number of vars in the multidimensional container.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::MultiDimContainer< GUM_SCALAR >::copy(), gum::MultiDimContainer< GUM_SCALAR >::extractFrom(), gum::MultiDimContainer< GUM_SCALAR >::operator==(), gum::MultiDimContainer< GUM_SCALAR >::toString(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ operator=() [1/2]

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

Default constructor.

Definition at line 56 of file multiDimAdressable_inl.h.

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

56  {
57  GUM_OP_CPY(MultiDimAdressable);
58  MultiDimInterface::operator=(from);
59  return *this;
60  }
MultiDimAdressable()
Default constructor.
+ Here is the caller graph for this function:

◆ operator=() [2/2]

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

Default constructor.

Definition at line 62 of file multiDimAdressable_inl.h.

62  {
63  GUM_OP_MOV(MultiDimAdressable);
64  MultiDimInterface::operator=(std::forward< MultiDimInterface >(from));
65  return *this;
66  }
MultiDimAdressable()
Default constructor.

◆ pos()

virtual Idx gum::MultiDimInterface::pos ( const DiscreteVariable v) const
pure virtualinherited

Returns the index of a variable.

Parameters
vThe variable for which the index is returned.
Returns
Returns the index of a variable.
Exceptions
NotFoundRaised if v is not in this multidimensional matrix.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ registerSlave()

virtual bool gum::MultiDimAdressable::registerSlave ( Instantiation i)
pure virtual

Register i as a slave of this MultiDimAdressable.

Parameters
iThe Instantiation to enslave.
Returns
Returns true if i becomes a slave of this MultiDimAdressable.

Implemented in gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, gum::MultiDimDecorator< GUM_SCALAR >, and gum::MultiDimWithOffset< GUM_SCALAR >.

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

+ Here is the caller graph for this function:

◆ 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 33 of file multiDimInterface_inl.h.

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

Referenced by gum::MultiDimImplementation< std::string >::_replace(), gum::MultiDimBucket< GUM_SCALAR >::_replace(), and gum::MultiDimInterface::~MultiDimInterface().

34  {
35  if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable"); }
36 
37  if (contains(y)) {
38  GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim");
39  }
40 
41  if (x.domainSize() != y.domainSize()) {
42  GUM_ERROR(OperationNotAllowed, "incompatible variables");
43  }
44 
45  _replace(&x, &y);
46  }
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.
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...
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setChangeNotification()

◆ setDecNotification()

◆ setFirstNotification()

◆ setIncNotification()

◆ setLastNotification()

◆ toString()

◆ unregisterSlave()

virtual bool gum::MultiDimAdressable::unregisterSlave ( Instantiation i)
pure virtual

Unregister i as a slave of this MultiDimAdressable.

Parameters
iThe Instantiation to free.
Returns
Returns true, whatever happens.

Implemented in gum::MultiDimBucket< GUM_SCALAR >, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, gum::MultiDimDecorator< GUM_SCALAR >, and gum::MultiDimWithOffset< GUM_SCALAR >.

Referenced by gum::Instantiation::forgetMaster(), and gum::Instantiation::~Instantiation().

+ Here is the caller graph for this function:

◆ variable() [1/2]

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

Returns a const ref to the ith var.

param i An index of this multidimensional matrix.

Returns
Returns a const ref to the ith var.
Exceptions
NotFoundRaised if i does not reference a variable in this multidimensional matrix.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::MultiDimContainer< GUM_SCALAR >::copy(), gum::MultiDimContainer< GUM_SCALAR >::extractFrom(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

◆ variable() [2/2]

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

Returns the variable with the name.

Parameters
nameThe index of the variable
Returns
Returns the variable qith the name in the tuple. This function is not O(1)
Exceptions
NotFoundRaised if the element cannot be found.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

◆ variablesSequence()

virtual const Sequence< const DiscreteVariable* >& gum::MultiDimInterface::variablesSequence ( ) const
pure virtualinherited

Returns a const ref to the sequence of DiscreteVariable*.

Returns
Returns a const ref to the sequence of DiscreteVariable*.

Implemented in gum::Instantiation, gum::MultiDimImplementation< GUM_SCALAR >, gum::MultiDimImplementation< std::string >, and gum::MultiDimDecorator< GUM_SCALAR >.

Referenced by gum::Instantiation::__init(), gum::MultiDimBucket< GUM_SCALAR >::add(), gum::MultiDimBucket< GUM_SCALAR >::erase(), gum::MultiDimContainer< GUM_SCALAR >::operator==(), gum::Potential< GUM_SCALAR >::Potential(), gum::Instantiation::synchronizeWithMaster(), and gum::MultiDimInterface::~MultiDimInterface().

+ Here is the caller graph for this function:

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