aGrUM  0.16.0
labelizedVariable.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LABELIZED_DISCRETE_VARIABLE_H
29 #define GUM_LABELIZED_DISCRETE_VARIABLE_H
30 
31 #include <iostream>
32 #include <sstream>
33 #include <string>
34 
35 #include <agrum/agrum.h>
36 
37 #include <agrum/core/sequence.h>
39 
40 namespace gum {
41  /* =========================================================================*/
42  /* =========================================================================*/
43  /* === GUM_LABELIZED_VARIABLE === */
44  /* =========================================================================*/
45  /* =========================================================================*/
50  /* =========================================================================*/
51 
53  public:
54  // ############################################################################
56  // ############################################################################
58 
65  LabelizedVariable(const std::string& aName,
66  const std::string& aDesc = "",
67  const Size nbrLabel = 2);
68 
75  LabelizedVariable(const std::string& aName,
76  const std::string& aDesc,
77  const std::vector< std::string >& labels);
78 
80 
85 
87 
88  virtual ~LabelizedVariable();
89 
91  virtual LabelizedVariable* clone() const;
92 
94 
95  // ############################################################################
97  // ############################################################################
99 
101 
103 
104 
106 
109  virtual Idx index(const std::string& label) const;
110 
112 
113  // ############################################################################
115  // ############################################################################
117 
123  bool isLabel(const std::string& aLabel) const;
124 
127 
132  LabelizedVariable& addLabel(const std::string& aLabel);
133 
135 
144  void changeLabel(Idx pos, const std::string& aLabel) const;
145 
147  void eraseLabels();
148 
150 
152  virtual std::string label(Idx i) const;
153 
155  Idx posLabel(const std::string& label) const;
156 
158  virtual double numerical(Idx indice) const;
159 
161  virtual Size domainSize() const;
162 
164  virtual VarType varType() const;
165 
167  virtual const std::string domain() const;
168 
170 
171  protected:
173  LabelizedVariable() { GUM_CONSTRUCTOR(LabelizedVariable); };
174 
176 
177  void _copy(const LabelizedVariable& aLDRV);
178 
179  private:
182  };
183 
184 } /* namespace gum */
185 
186 /* ==============================================================================
187  */
188 /* ==============================================================================
189  */
190 /* === LabelizedVariable IMPLEMENTATION === */
191 /* ==============================================================================
192  */
193 /* ==============================================================================
194  */
195 #ifndef GUM_NO_INLINE
197 #endif /* GUM_NO_INLINE */
198 
199 #endif /* GUM_LABELIZED_DISCRETE_VARIABLE_H */
virtual double numerical(Idx indice) const
get a numerical representation of he indice-the value.
std::vector< std::string > labels() const
vector of labels
virtual const std::string domain() const
Returns the domain.
void changeLabel(Idx pos, const std::string &aLabel) const
change a label for this index
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
class LabelizedVariable
virtual std::string label(Idx i) const
returns the ith label
virtual VarType varType() const
returns the type of variable
void eraseLabels()
erase all the labels
virtual Size domainSize() const
returns the size of the random discrete variable domain
Base class for discrete random variable.
virtual ~LabelizedVariable()
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool isLabel(const std::string &aLabel) const
indicates whether the variable already has the label passed in argument
void _copy(const LabelizedVariable &aLDRV)
copies the content of aLDRV
Sequence< std::string > __labels
the set of labels contained in the variable
VarType
Definition: variable.h:41
Idx posLabel(const std::string &label) const
return the pos from label
virtual LabelizedVariable * clone() const
a virtual clone ...
LabelizedVariable & operator=(const LabelizedVariable &aLDRV)
copy operator
LabelizedVariable()
(protected) Default constructor
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
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
virtual Idx index(const std::string &label) const
returns the index of a given label