aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
variable.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
50#ifndef GUM_VARIABLE_H
51#define GUM_VARIABLE_H
52
53#include <iostream>
54#include <string>
55
56#include <agrum/agrum.h>
57
58namespace gum {
59
61
62 /* ===========================================================================
63 */
64 /* ===========================================================================
65 */
66 /* === GUM_VARIABLE ===
67 */
68 /* ===========================================================================
69 */
70 /* ===========================================================================
71 */
76 /* ===========================================================================
77 */
78
79 class Variable {
80 public:
81 // ############################################################################
83 // ############################################################################
85
87
88 virtual ~Variable();
89
92 virtual Variable* clone() const = 0;
93
95
96 // ############################################################################
98 // ############################################################################
100
102
104
106
108 bool operator==(const Variable& aRV) const;
109
110
112
113 // ############################################################################
115 // ############################################################################
117
119
120 void setName(const std::string& theValue);
121
123 const std::string& name() const;
124
127
128 void setDescription(const std::string& theValue) const;
129
131 const std::string& description() const;
132
134 virtual VarType varType() const = 0;
135
137 virtual std::string domain() const = 0;
138
140
141 protected:
143 Variable() { GUM_CONSTRUCTOR(Variable); }
144
146
147 void copy_(const Variable& aRV);
148
150
152 Variable(const std::string& aName, const std::string& aDesc);
153
155
156 Variable(const Variable& aRV);
157
158 private:
160 std::string _name_;
161
165 mutable std::string _description_;
166
168
171 virtual bool _checkSameDomain_(const Variable& aRV) const = 0;
172 };
173
174} /* namespace gum */
175
177std::ostream& operator<<(std::ostream& s, const gum::Variable& LDRV);
178
179#ifndef GUM_NO_INLINE
181#endif /* GUM_NO_INLINE */
182
183#endif /* GUM_VARIABLE_H */
Base class for every random variable.
Definition variable.h:79
void setName(const std::string &theValue)
sets the name of the variable
virtual Variable * clone() const =0
Copy Factory.
void setDescription(const std::string &theValue) const
sets the description of the variable
std::string _name_
the name of the variable
Definition variable.h:160
virtual bool _checkSameDomain_(const Variable &aRV) const =0
check the domain
void copy_(const Variable &aRV)
protected copy
Variable()
(protected) Default constructor
Definition variable.h:143
const std::string & name() const
returns the name of the variable
virtual VarType varType() const =0
returns the type of variable
std::string _description_
the description of the variable since description is not a characteristic of a variable,...
Definition variable.h:165
Variable(const Variable &aRV)
copy constructor
const std::string & description() const
returns the description of the variable
virtual std::string domain() const =0
string represent the domain of the variable
Variable & operator=(const Variable &aRV)
Copy operator.
Variable(const std::string &aName, const std::string &aDesc)
constructor
virtual ~Variable()
destructor
bool operator==(const Variable &aRV) const
equality operator
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
VarType
Definition variable.h:60
std::ostream & operator<<(std::ostream &s, const gum::Variable &LDRV)
for friendly displaying the content of the variable