aGrUM  0.16.0
forall_tpl.h
Go to the documentation of this file.
1 
30 #include <sstream>
31 // to ease parser in IDEs
33 
34 namespace gum {
35 
36  namespace aggregator {
37  template < typename GUM_SCALAR >
39  MultiDimAggregator< GUM_SCALAR >(), __value(value) {
40  GUM_CONSTRUCTOR(Forall);
41  }
42 
43  template < typename GUM_SCALAR >
45  MultiDimAggregator< GUM_SCALAR >(from) {
46  __value = from.__value;
47  GUM_CONS_CPY(Forall);
48  }
49 
50  template < typename GUM_SCALAR >
52  GUM_DESTRUCTOR(Forall);
53  }
54 
55  template < typename GUM_SCALAR >
57  return (Idx)1;
58  }
59 
60  template < typename GUM_SCALAR >
62  Idx i1,
63  Idx i2,
64  bool& stop_iteration) const {
65  if (i1 == __value) {
66  return (Idx)1;
67  } else {
68  stop_iteration = true;
69  return (Idx)0;
70  }
71  }
72 
73  template < typename GUM_SCALAR >
74  INLINE
75 
76  std::string
78  std::stringstream ss;
79  ss << "forall[" << __value << "]";
80  return ss.str();
81  }
82 
83  template < typename GUM_SCALAR >
86  return new Forall< GUM_SCALAR >(__value);
87  }
88 
89  } // namespace aggregator
90 } // namespace gum
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
<agrum/multidim/aggregators/multiDimAggregator.h>
forall aggregator
Definition: forall.h:55
virtual std::string aggregatorName() const
Definition: forall_tpl.h:77
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:85
virtual Idx _neutralElt() const
_neutralElt() is the result value for the first application of _fold
Definition: forall_tpl.h:56
Size Idx
Type for indexes.
Definition: types.h:53
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:61