aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
PRMType_inl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by 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 Inline implementation of type.
25
*
26
* @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27
*
28
*/
29
#
include
<
agrum
/
PRM
/
elements
/
PRMType
.
h
>
30
31
namespace
gum
{
32
namespace
prm
{
33
34
35
INLINE PRMType&
PRMType
::
superType
() {
36
if
(
_superType_
) {
37
return
*
_superType_
;
38
}
else
{
39
GUM_ERROR
(
NotFound
,
"No super type for this type."
)
40
}
41
}
42
43
44
INLINE
DiscreteVariable
&
PRMType
::
variable
() {
return
*
_var_
; }
45
46
47
INLINE
const
DiscreteVariable
&
PRMType
::
variable
()
const
{
return
*
_var_
; }
48
49
50
INLINE
DiscreteVariable
&
PRMType
::
operator
*() {
return
*
_var_
; }
51
52
53
INLINE
const
DiscreteVariable
&
PRMType
::
operator
*()
const
{
return
*
_var_
; }
54
55
56
INLINE
DiscreteVariable
*
PRMType
::
operator
->() {
return
_var_
; }
57
58
59
INLINE
DiscreteVariable
const
*
PRMType
::
operator
->()
const
{
return
_var_
; }
60
61
62
INLINE
PRMObject
::
prm_type
PRMType
::
obj_type
()
const
{
return
PRMObject
::
prm_type
::
TYPE
; }
63
64
65
INLINE
const
std
::
string
&
PRMType
::
name
()
const
{
return
PRMObject
::
name
(); }
66
67
68
INLINE
const
PRMType
&
PRMType
::
superType
()
const
{
69
if
(
_superType_
) {
70
return
*
_superType_
;
71
}
else
{
72
GUM_ERROR
(
NotFound
,
"No super type for this type."
)
73
}
74
}
75
76
77
INLINE
void
PRMType
::
setSuper
(
PRMType
&
t
) {
78
try
{
79
if
(
t
!=
superType
()) {
80
GUM_ERROR
(
TypeError
,
"The given type is not a valid super type for this Type"
)
81
}
82
}
catch
(
NotFound
&) {
GUM_ERROR
(
OperationNotAllowed
,
"This Type has no super Type"
) }
83
84
_superType_
= &
t
;
85
}
86
87
88
INLINE
const
std
::
vector
<
Idx
>&
PRMType
::
label_map
()
const
{
89
if
(
_label_map_
) {
90
return
*
_label_map_
;
91
}
else
{
92
GUM_ERROR
(
NotFound
,
"No super type for this type."
)
93
}
94
}
95
96
97
INLINE
bool
PRMType
::
isSubType
()
const
{
return
_superType_
!=
nullptr
; }
98
99
100
INLINE
bool
PRMType
::
isSuperTypeOf
(
const
PRMType
&
t
)
const
{
return
t
.
isSubTypeOf
(*
this
); }
101
102
103
INLINE
bool
PRMType
::
operator
==(
const
PRMObject
&
obj
)
const
{
return
name
() ==
obj
.
name
(); }
104
105
106
INLINE
bool
PRMType
::
operator
!=(
const
PRMObject
&
obj
)
const
{
return
name
() !=
obj
.
name
(); }
107
108
}
/* namespace prm */
109
}
/* namespace gum */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643
gum::prm::ParamScopeData::ParamScopeData
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
Definition:
PRMClass_tpl.h:1032