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

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

#include <agrum/tools/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 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 58 of file multiDimAdressable.h.

Constructor & Destructor Documentation

◆ MultiDimAdressable() [1/3]

INLINE gum::MultiDimAdressable::MultiDimAdressable ( )

Default constructor.

Definition at line 44 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

44 { GUM_CONSTRUCTOR(MultiDimAdressable); }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

◆ MultiDimAdressable() [2/3]

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

Copy constructor.

Definition at line 46 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

46  {
47  GUM_CONS_CPY(MultiDimAdressable);
48  }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

◆ MultiDimAdressable() [3/3]

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

Class move constructor.

Definition at line 39 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

39  :
40  MultiDimInterface(std::forward< MultiDimInterface >(from)) {
41  GUM_CONS_MOV(MultiDimAdressable);
42  }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

◆ ~MultiDimAdressable()

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

Destructor.

Definition at line 50 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

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

Member Function Documentation

◆ add()

◆ changeNotification()

◆ contains()

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

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

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

◆ erase()

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

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

◆ operator=() [1/2]

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

Default constructor.

Definition at line 52 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

52  {
53  GUM_OP_CPY(MultiDimAdressable);
54  MultiDimInterface::operator=(from);
55  return *this;
56  }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

◆ operator=() [2/2]

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

Default constructor.

Definition at line 57 of file multiDimAdressable_inl.h.

References gum::Set< Key, Alloc >::emplace().

57  {
58  GUM_OP_MOV(MultiDimAdressable);
59  MultiDimInterface::operator=(std::forward< MultiDimInterface >(from));
60  return *this;
61  }
MultiDimAdressable()
Default constructor.
+ Here is the call graph for this function:

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

◆ registerSlave()

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

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

References gum::Set< Key, Alloc >::emplace().

35  {
36  if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable") }
37 
38  if (contains(y)) { GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim") }
39 
40  if (x.domainSize() != y.domainSize()) {
41  GUM_ERROR(OperationNotAllowed, "incompatible variables")
42  }
43 
44  replace_(&x, &y);
45  }
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:51
+ Here is the call graph for this function:

◆ replace_()

◆ setChangeNotification()

◆ setDecNotification()

◆ setFirstNotification()

◆ setIncNotification()

◆ setLastNotification()

◆ toString()

◆ unregisterSlave()

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

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

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


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