aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
v
Variables
Typedefs
Enumerations
+
Enumerator
a
c
e
f
g
h
i
l
p
s
t
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
v
+
Enumerations
a
b
c
e
f
i
k
l
n
p
r
s
t
+
Enumerator
a
b
c
d
e
f
i
l
m
n
o
p
r
s
t
u
v
+
Related Functions
b
c
d
f
g
h
l
m
n
o
p
r
s
t
+
Files
File List
+
File Members
+
All
a
b
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Functions
Variables
Enumerations
Enumerator
+
Macros
a
b
d
e
f
g
i
l
m
r
s
t
u
v
PRMType.cpp
Go to the documentation of this file.
1
/**
2
*
3
* Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/**
23
* @file
24
* @brief Source implementation of type.
25
*
26
* @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27
*
28
*/
29
30
#
include
<
agrum
/
PRM
/
elements
/
PRMType
.
h
>
31
32
#
ifdef
GUM_NO_INLINE
33
#
include
<
agrum
/
PRM
/
elements
/
PRMType_inl
.
h
>
34
#
endif
// GUM_NO_INLINE
35
36
namespace
gum
{
37
38
namespace
prm
{
39
40
41
void
PRMType
::
updateName__
() {
42
const
void
*
address
=
static_cast
<
const
void
* >(
this
);
43
std
::
stringstream
ss
;
44
ss
<<
this
->
name
() <<
"-"
<<
address
;
45
this
->
var__
->
setName
(
ss
.
str
());
46
}
47
48
49
PRMType
::
PRMType
(
const
DiscreteVariable
&
var
) :
50
PRMObject
(
var
.
name
()),
var__
(
var
.
clone
()),
superType__
(0),
label_map__
(0) {
51
GUM_CONSTRUCTOR
(
PRMType
);
52
this
->
updateName__
();
53
}
54
55
56
PRMType
::
PRMType
(
PRMType
&
super_type
,
57
const
std
::
vector
<
Idx
>&
label_map
,
58
const
DiscreteVariable
&
var
) :
59
PRMObject
(
var
.
name
()),
60
var__
(
var
.
clone
()),
superType__
(&
super_type
),
61
label_map__
(
new
std
::
vector
<
Idx
>(
label_map
)) {
62
GUM_CONSTRUCTOR
(
PRMType
);
63
this
->
updateName__
();
64
65
if
(!
isValid__
()) {
66
delete
label_map__
;
67
label_map__
= 0;
68
GUM_ERROR
(
OperationNotAllowed
,
"Invalid label map."
);
69
}
70
}
71
72
73
PRMType
::
PRMType
(
const
PRMType
&
from
) :
74
PRMObject
(
from
),
var__
(
from
.
var__
->
clone
()),
superType__
(
from
.
superType__
),
75
label_map__
(0) {
76
GUM_CONS_CPY
(
PRMType
);
77
this
->
updateName__
();
78
79
if
(
superType__
) {
label_map__
=
new
std
::
vector
<
Idx
>(
from
.
label_map
()); }
80
}
81
82
83
PRMType
::
PRMType
(
PRMType
&&
from
) :
PRMObject
(
from
) {
84
GUM_CONS_MOV
(
PRMType
);
85
GUM_ERROR
(
FatalError
,
"Move constructor must not be used"
);
86
}
87
88
89
PRMType
::~
PRMType
() {
90
GUM_DESTRUCTOR
(
PRMType
);
91
delete
var__
;
92
if
(
label_map__
) {
delete
label_map__
; }
93
}
94
95
96
PRMType
&
PRMType
::
operator
=(
const
PRMType
&
from
) {
97
GUM_ERROR
(
FatalError
,
"Copy operator must not be used"
);
98
}
99
100
101
PRMType
&
PRMType
::
operator
=(
PRMType
&&
from
) {
102
GUM_ERROR
(
FatalError
,
"Move operator must not be used"
);
103
}
104
105
106
bool
PRMType
::
isSubTypeOf
(
const
PRMType
&
super
)
const
{
107
if
((*
this
) ==
super
) {
108
return
true
;
109
}
else
if
(
superType__
) {
110
return
superType__
->
isSubTypeOf
(
super
);
111
}
else
{
112
return
false
;
113
}
114
}
115
116
117
bool
PRMType
::
isValid__
()
const
{
118
if
(!
superType__
) {
return
var__
->
domainSize
() > 1; }
119
120
if
(
label_map__
->
size
() ==
var__
->
domainSize
()) {
121
for
(
size_t
i
= 0;
i
<
label_map__
->
size
(); ++
i
) {
122
if
(
label_map__
->
at
(
i
) >= (**
superType__
).
domainSize
()) {
return
false
; }
123
}
124
125
return
true
;
126
}
127
128
return
false
;
129
}
130
131
132
}
/* namespace prm */
133
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
gum::prm::ParamScopeData::ParamScopeData
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
Definition:
PRMClass_tpl.h:1101