aGrUM  0.14.2
variable.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  ***************************************************************************/
28 #ifndef GUM_VARIABLE_H
29 #define GUM_VARIABLE_H
30 
31 #include <iostream>
32 #include <string>
33 
34 #include <agrum/agrum.h>
35 
36 namespace gum {
37 
38  enum class VarType : char { Discretized, Labelized, Range, Continuous };
39 
40  class Variable;
41 
43 
44  std::ostream& operator<<(std::ostream& s, const Variable& LDRV);
45 
46  /* ===========================================================================
47  */
48  /* ===========================================================================
49  */
50  /* === GUM_VARIABLE ===
51  */
52  /* ===========================================================================
53  */
54  /* ===========================================================================
55  */
60  /* ===========================================================================
61  */
62 
63  class Variable {
64  public:
65  // ############################################################################
67  // ############################################################################
69 
71 
72  virtual ~Variable();
73 
76 
77  virtual Variable* clone() const = 0;
78 
80 
81  // ############################################################################
83  // ############################################################################
85 
87 
90  Variable& operator=(const Variable& aRV);
91 
93 
94  virtual bool operator==(const Variable& aRV) const;
95 
97 
98  virtual bool operator!=(const Variable& aRV) const;
99 
101 
102  // ############################################################################
104  // ############################################################################
106 
108 
110  void setName(const std::string& theValue);
111 
113 
114  const std::string& name() const;
115 
118 
120  void setDescription(const std::string& theValue) const;
121 
123 
124  const std::string& description() const;
125 
127 
128  virtual VarType varType() const = 0;
129 
131  virtual const std::string domain() const = 0;
132 
134 
135  protected:
137  Variable() { GUM_CONSTRUCTOR(Variable); };
138 
140 
142  void _copy(const Variable& aRV);
143 
145 
148  Variable(const std::string& aName, const std::string& aDesc);
149 
151 
153  Variable(const Variable& aRV);
154 
155  private:
157  std::string __name;
158 
162  mutable std::string __description;
163  };
164 
165 } /* namespace gum */
166 
167 #ifndef GUM_NO_INLINE
169 #endif /* GUM_NO_INLINE */
170 
171 #endif /* GUM_VARIABLE_H */
Base class for every random variable.
Definition: variable.h:63
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:583
VarType
Definition: variable.h:38
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:243
std::string __name
the name of the variable
Definition: variable.h:157
bool operator!=(const TiXmlString &a, const TiXmlString &b)
Definition: tinystr.h:251
Variable()
(protected) Default constructor
Definition: variable.h:137
std::string __description
the description of the variable since description is not a characteristic of a variable, we allow the description to be changed even in a const reference.
Definition: variable.h:162