aGrUM  0.14.2
forall_tpl.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 #include <sstream>
28 // to ease parser in IDEs
30 
31 namespace gum {
32 
33  namespace aggregator {
34  template < typename GUM_SCALAR >
36  MultiDimAggregator< GUM_SCALAR >(), __value(value) {
37  GUM_CONSTRUCTOR(Forall);
38  }
39 
40  template < typename GUM_SCALAR >
42  MultiDimAggregator< GUM_SCALAR >(from) {
43  __value = from.__value;
44  GUM_CONS_CPY(Forall);
45  }
46 
47  template < typename GUM_SCALAR >
49  GUM_DESTRUCTOR(Forall);
50  }
51 
52  template < typename GUM_SCALAR >
54  return (Idx)1;
55  }
56 
57  template < typename GUM_SCALAR >
59  Idx i1,
60  Idx i2,
61  bool& stop_iteration) const {
62  if (i1 == __value) {
63  return (Idx)1;
64  } else {
65  stop_iteration = true;
66  return (Idx)0;
67  }
68  }
69 
70  template < typename GUM_SCALAR >
71  INLINE
72 
73  std::string
75  std::stringstream ss;
76  ss << "forall[" << __value << "]";
77  return ss.str();
78  }
79 
80  template < typename GUM_SCALAR >
83  return new Forall< GUM_SCALAR >(__value);
84  }
85 
86  } // namespace aggregator
87 } // namespace gum
forall aggregator
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.
<agrum/multidim/aggregators/multiDimAggregator.h>
forall aggregator
Definition: forall.h:52
virtual std::string aggregatorName() const
Definition: forall_tpl.h:74
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
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()
Definition: forall_tpl.h:82
virtual Idx _neutralElt() const
_neutralElt() is the result value for the first application of _fold
Definition: forall_tpl.h:53
Size Idx
Type for indexes.
Definition: types.h:50
virtual Idx _fold(const DiscreteVariable &v, Idx i1, Idx i2, bool &stop_iteration) const
_fold is applied on value i1 for variable v. the actual result for precedent applications is i2...
Definition: forall_tpl.h:58