aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
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-2026 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-2026 *
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
58
#include <string_view>
59
60
namespace
gum
{
61
62
enum class
VarType
:
char
{
DISCRETIZED
,
LABELIZED
,
INTEGER
,
NUMERICAL
,
RANGE
, CONTINUOUS };
63
64
/* ===========================================================================
65
*/
66
/* ===========================================================================
67
*/
68
/* === GUM_VARIABLE ===
69
*/
70
/* ===========================================================================
71
*/
72
/* ===========================================================================
73
*/
78
/* ===========================================================================
79
*/
80
81
class
GUM_SHARED_PUBLIC
Variable
{
82
public
:
83
// ############################################################################
85
// ############################################################################
87
89
90
virtual
~Variable
();
91
94
[[nodiscard]]
virtual
Variable
*
clone
()
const
= 0;
95
97
98
// ############################################################################
100
// ############################################################################
102
104
106
107
Variable
&
operator=
(
const
Variable
& aRV);
108
110
bool
operator==
(
const
Variable
& aRV)
const
;
111
112
114
115
// ############################################################################
117
// ############################################################################
119
121
122
void
setName
(std::string_view theValue);
123
125
const
std::string&
name
()
const
;
126
129
130
void
setDescription
(std::string_view theValue)
const
;
131
133
const
std::string&
description
()
const
;
134
136
virtual
VarType
varType
()
const
= 0;
137
139
virtual
std::string
domain
()
const
= 0;
140
142
143
protected
:
145
Variable
() { GUM_CONSTRUCTOR(
Variable
); }
146
148
149
void
copy_
(
const
Variable
& aRV);
150
152
154
Variable
(std::string_view aName, std::string_view aDesc);
155
157
158
Variable
(
const
Variable
& aRV);
159
160
private
:
162
std::string
_name_
;
163
167
mutable
std::string
_description_
;
168
170
173
virtual
bool
_checkSameDomain_
(
const
Variable
& aRV)
const
= 0;
174
};
175
176
}
/* namespace gum */
177
179
std::ostream&
operator<<
(std::ostream& s,
const
gum::Variable
& LDRV);
180
181
#ifndef GUM_NO_INLINE
182
# include <
agrum/base/variables/variable_inl.h
>
183
#endif
/* GUM_NO_INLINE */
184
185
#endif
/* GUM_VARIABLE_H */
agrum.h
gum::Variable
Base class for every random variable.
Definition
variable.h:81
gum::Variable::setDescription
void setDescription(std::string_view theValue) const
sets the description of the variable
gum::Variable::clone
virtual Variable * clone() const =0
Copy Factory.
gum::Variable::_name_
std::string _name_
the name of the variable
Definition
variable.h:162
gum::Variable::Variable
Variable(std::string_view aName, std::string_view aDesc)
constructor
gum::Variable::_checkSameDomain_
virtual bool _checkSameDomain_(const Variable &aRV) const =0
check the domain
gum::Variable::copy_
void copy_(const Variable &aRV)
protected copy
gum::Variable::Variable
Variable()
(protected) Default constructor
Definition
variable.h:145
gum::Variable::name
const std::string & name() const
returns the name of the variable
gum::Variable::varType
virtual VarType varType() const =0
returns the type of variable
gum::Variable::_description_
std::string _description_
the description of the variable since description is not a characteristic of a variable,...
Definition
variable.h:167
gum::Variable::Variable
Variable(const Variable &aRV)
copy constructor
gum::Variable::description
const std::string & description() const
returns the description of the variable
gum::Variable::domain
virtual std::string domain() const =0
string represent the domain of the variable
gum::Variable::operator=
Variable & operator=(const Variable &aRV)
Copy operator.
gum::Variable::setName
void setName(std::string_view theValue)
sets the name of the variable
gum::Variable::~Variable
virtual ~Variable()
destructor
gum::Variable::operator==
bool operator==(const Variable &aRV) const
equality operator
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::VarType
VarType
Definition
variable.h:62
gum::VarType::RANGE
@ RANGE
Definition
variable.h:62
gum::VarType::DISCRETIZED
@ DISCRETIZED
Definition
variable.h:62
gum::VarType::NUMERICAL
@ NUMERICAL
Definition
variable.h:62
gum::VarType::INTEGER
@ INTEGER
Definition
variable.h:62
gum::VarType::LABELIZED
@ LABELIZED
Definition
variable.h:62
operator<<
std::ostream & operator<<(std::ostream &s, const gum::Variable &LDRV)
for friendly displaying the content of the variable
variable_inl.h
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0