aGrUM  0.14.2
multiDimAggregator.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_MULTI_DIM_AGGREGATOR_H
28 #define GUM_MULTI_DIM_AGGREGATOR_H
29 
31 
32 namespace gum {
33  namespace aggregator {
34  // =========================================================================
35  // === GUM_MULTI_DIM_AGGREGATOR ===
36  // =========================================================================
37 
60  template < typename GUM_SCALAR >
61  class MultiDimAggregator : public MultiDimReadOnly< GUM_SCALAR > {
62  public:
63  // =======================================================================
65  // =======================================================================
67 
72 
77 
81  virtual ~MultiDimAggregator();
82 
84 
102  virtual MultiDimContainer< GUM_SCALAR >* newFactory() const override = 0;
103 
104  // =======================================================================
106  // =======================================================================
108 
109  public:
110  virtual GUM_SCALAR get(const Instantiation& i) const override;
111 
112  virtual std::string aggregatorName() const = 0;
113  const std::string toString() const override;
114 
116  const gum::DiscreteVariable* const,
117  gum::Idx,
118  gum::Idx) override{};
119 
120  void setFirstNotification(const gum::Instantiation&) override{};
121 
122  void setLastNotification(const gum::Instantiation&) override{};
123 
124  void setIncNotification(const gum::Instantiation&) override{};
125 
126  void setDecNotification(const gum::Instantiation&) override{};
127 
128  void setChangeNotification(const gum::Instantiation&) override{};
129 
130  const std::string toString(const gum::Instantiation* i) const override {
131  return i->toString();
132  };
133 
139  Size realSize() const override { return 0; };
140 
152  const std::string& name() const override;
153 
163  void copyFrom(const MultiDimContainer< GUM_SCALAR >& src) const override;
164 
166  protected:
171  virtual Idx _buildValue(const gum::Instantiation& i) const;
172 
173 
175  virtual Idx _neutralElt() const = 0;
176 
180  virtual Idx _fold(const DiscreteVariable& v,
181  Idx i1,
182  Idx i2,
183  bool& stop_iteration) const = 0;
184  };
185 
186 
187 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
188  extern template class MultiDimAggregator< double >;
189 #endif
190 
192  template < typename GUM_SCALAR >
193  std::ostream& operator<<(std::ostream& s,
195 
196  } /* namespace aggregator */
197 } /* namespace gum */
198 
200 
201 #endif /* GUM_MULTI_DIM_AGGREGATOR_H */
virtual ~MultiDimAggregator()
Class destructor.
const std::string toString() const override
Header of the MultiDimReadOnly class.
const std::string & name() const override
Returns the real name of the multiDimArray.
void setChangeNotification(const gum::Instantiation &) override
const std::string toString(const gum::Instantiation *i) const override
void setDecNotification(const gum::Instantiation &) override
virtual Idx _fold(const DiscreteVariable &v, Idx i1, Idx i2, bool &stop_iteration) const =0
_fold is applied on value i1 for variable v. the actual result for precedent applications is i2...
virtual std::string aggregatorName() const =0
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Abstract base class for all multi dimensionnal containers.
void copyFrom(const MultiDimContainer< GUM_SCALAR > &src) const override
Copy of a multiDimICIModel.
Abstract base class for all multi dimensionnal read only structure.
void changeNotification(const gum::Instantiation &, const gum::DiscreteVariable *const, gum::Idx, gum::Idx) override
<agrum/multidim/aggregators/multiDimAggregator.h>
void setIncNotification(const gum::Instantiation &) override
void setFirstNotification(const gum::Instantiation &) override
virtual Idx _neutralElt() const =0
_neutralElt() is the result value for the first application of _fold
std::string toString() const
Give a string version of instantiation.
void setLastNotification(const gum::Instantiation &) override
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
virtual Idx _buildValue(const gum::Instantiation &i) const
by default, _buildValue uses a "fold" scheme and the user has to implement _neutralElt and _fold but ...
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const override=0
This method creates a clone of this object, withouth its content (including variable), you must use this method if you want to ensure that the generated object has the same type than the object containing the called newFactory()
Size Idx
Type for indexes.
Definition: types.h:50
MultiDimAggregator.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
std::ostream & operator<<(std::ostream &s, const MultiDimAggregator< GUM_SCALAR > &ag)
For friendly displaying the content of the array.