aGrUM  0.16.0
multiDimWithOffset.h
Go to the documentation of this file.
1 
30 #ifndef GUM_MULTI_DIM_WITH_OFFSET_H
31 #define GUM_MULTI_DIM_WITH_OFFSET_H
32 
33 #include <agrum/agrum.h>
35 #include <vector>
36 
37 namespace gum {
38  // ==========================================================================
39  // === GUM_MULTI_DIM_WITH_OFFSET === */
40  // ==========================================================================
51  template < typename GUM_SCALAR >
52  class MultiDimWithOffset : public MultiDimImplementation< GUM_SCALAR > {
53  public:
54  // =========================================================================
56  // =========================================================================
58 
63 
73 
77  virtual ~MultiDimWithOffset();
78 
86 
87  virtual MultiDimContainer< GUM_SCALAR >* newFactory() const = 0;
88 
90  // =========================================================================
92  // =========================================================================
94 
95  virtual void add(const DiscreteVariable& v);
96 
97  virtual void erase(const DiscreteVariable& v);
98 
99  virtual void fill(const GUM_SCALAR& d) const = 0;
100 
101  virtual const std::string toString(const Instantiation* i) const;
102 
103  virtual void changeNotification(const Instantiation& i,
104  const DiscreteVariable* const var,
105  Idx oldval,
106  Idx newval);
107 
108  virtual void setChangeNotification(const Instantiation& i);
109 
110  virtual void setFirstNotification(const Instantiation& i);
111 
112  virtual void setLastNotification(const Instantiation& i);
113 
114  void setIncNotification(const Instantiation& i);
115 
116  void setDecNotification(const Instantiation& i);
117 
118  virtual bool registerSlave(Instantiation& i);
119 
120  virtual bool unregisterSlave(Instantiation& i);
121 
123  // =========================================================================
125  // =========================================================================
127 
129 
138  Size toOffset(const Instantiation& i) const;
139 
152  Instantiation& fromOffset(Instantiation& i, Size offset) const;
153 
155 
156  protected:
170  Size _getOffs(const Instantiation& i) const;
171 
181 
184 
195  void _computeInstantiationValue(Instantiation& result, Size indice) const;
196 
197  virtual GUM_SCALAR& _get(const Instantiation& i) const = 0;
198  };
199 } /* namespace gum */
200 
202 
203 #endif /* GUM_MULTI_DIM_WITH_OFFSET_H */
virtual void setLastNotification(const Instantiation &i)
Listen to setLast in a given Instantiation.
Instantiation & fromOffset(Instantiation &i, Size offset) const
Set the Instantiation to the values corresponding to the offset (in this array).
void _computeInstantiationValue(Instantiation &result, Size indice) const
For a given index of a value in the vector values, this method computes the corresponding instantiati...
void setDecNotification(const Instantiation &i)
Listen to increment in each recorded Instantiation.
Size toOffset(const Instantiation &i) const
Compute offset from an Instantiation (in this array).
virtual bool unregisterSlave(Instantiation &i)
Unregister i as a slave of this MultiDimAdressable.
virtual void fill(const GUM_SCALAR &d) const =0
Fill the table with d.
HashTable< const Instantiation *, Size > _offsets
The position in the array of each slave Instantiation.
virtual void setChangeNotification(const Instantiation &i)
Listen to an assignment of a value in a Instantiation.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual GUM_SCALAR & _get(const Instantiation &i) const =0
Return a data, given a Instantiation.
virtual const std::string toString() const
Returns a representation of this MultiDimContainer.
virtual void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval)
Listen to changes in a given Instantiation.
MultiDimWithOffset< GUM_SCALAR > & operator=(const MultiDimWithOffset< GUM_SCALAR > &from)
Copy operator.
HashTable< const DiscreteVariable *, Size > _gaps
The gaps between consecutive values of a given variable.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Abstract base class for all multi dimensionnal containers.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~MultiDimWithOffset()
Class destrucor.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
The class for generic Hash Tables.
Definition: hashTable.h:679
Abstract class for Multidimensional matrix stored as an array in memory and with an offset associated...
MultiDimWithOffset()
Class constructor.
void setIncNotification(const Instantiation &i)
Listen to increment in a given Instantiation.
virtual void erase(const DiscreteVariable &v)
Removes a var from the variables of the multidimensional matrix.
Size _getOffs(const Instantiation &i) const
Compute the offset of a Instantiation.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const =0
Class constructor.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
virtual void setFirstNotification(const Instantiation &i)
Listen to setFirst in a given Instantiation.
<agrum/multidim/multiDimImplementation.h>
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
virtual bool registerSlave(Instantiation &i)
Register i as a slave of this MultiDimAdressable.