aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
DBRowGeneratorIdentity_tpl.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
/** @file
23
* @brief A filtered row generator that returns exactly the rows it gets in
24
*input
25
*
26
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
27
*/
28
#
include
<
agrum
/
tools
/
database
/
DBRowGeneratorIdentity
.
h
>
29
30
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
31
32
namespace
gum
{
33
34
namespace
learning
{
35
36
/// returns the allocator used
37
template
<
template
<
typename
>
class
ALLOC
>
38
INLINE
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
39
DBRowGeneratorIdentity
<
ALLOC
>::
getAllocator
()
const
{
40
return
DBRowGenerator
<
ALLOC
>::
getAllocator
();
41
}
42
43
44
/// default constructor
45
template
<
template
<
typename
>
class
ALLOC
>
46
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
47
const
std
::
vector
<
DBTranslatedValueType
,
ALLOC
<
DBTranslatedValueType
> >
column_types
,
48
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
49
DBRowGenerator
<
ALLOC
>(
column_types
,
50
DBRowGeneratorGoal
::
OTHER_THINGS_THAN_REMOVE_MISSING_VALUES
,
51
alloc
) {
52
GUM_CONSTRUCTOR
(
DBRowGeneratorIdentity
);
53
}
54
55
56
/// copy constructor with a given allocator
57
template
<
template
<
typename
>
class
ALLOC
>
58
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
59
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
,
60
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
61
DBRowGenerator
<
ALLOC
>(
from
,
alloc
),
62
_input_row_
(
from
.
_input_row_
) {
63
GUM_CONS_CPY
(
DBRowGeneratorIdentity
);
64
}
65
66
67
/// copy constructor
68
template
<
template
<
typename
>
class
ALLOC
>
69
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
70
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
) :
71
DBRowGeneratorIdentity
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
72
73
74
/// move constructor with a given allocator
75
template
<
template
<
typename
>
class
ALLOC
>
76
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
77
DBRowGeneratorIdentity
<
ALLOC
>&&
from
,
78
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
79
DBRowGenerator
<
ALLOC
>(
std
::
move
(
from
),
alloc
),
80
_input_row_
(
from
.
_input_row_
) {
81
GUM_CONS_MOV
(
DBRowGeneratorIdentity
);
82
}
83
84
85
/// move constructor
86
template
<
template
<
typename
>
class
ALLOC
>
87
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
88
DBRowGeneratorIdentity
<
ALLOC
>&&
from
) :
89
DBRowGeneratorIdentity
<
ALLOC
>(
std
::
move
(
from
),
from
.
getAllocator
()) {}
90
91
92
/// virtual copy constructor with a given allocator
93
template
<
template
<
typename
>
class
ALLOC
>
94
DBRowGeneratorIdentity
<
ALLOC
>*
DBRowGeneratorIdentity
<
ALLOC
>::
clone
(
95
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
)
const
{
96
ALLOC
<
DBRowGeneratorIdentity
<
ALLOC
> >
allocator
(
alloc
);
97
DBRowGeneratorIdentity
<
ALLOC
>*
generator
=
allocator
.
allocate
(1);
98
try
{
99
allocator
.
construct
(
generator
, *
this
,
alloc
);
100
}
catch
(...) {
101
allocator
.
deallocate
(
generator
, 1);
102
throw
;
103
}
104
return
generator
;
105
}
106
107
108
/// virtual copy constructor
109
template
<
template
<
typename
>
class
ALLOC
>
110
DBRowGeneratorIdentity
<
ALLOC
>*
DBRowGeneratorIdentity
<
ALLOC
>::
clone
()
const
{
111
return
clone
(
this
->
getAllocator
());
112
}
113
114
115
/// destructor
116
template
<
template
<
typename
>
class
ALLOC
>
117
DBRowGeneratorIdentity
<
ALLOC
>::~
DBRowGeneratorIdentity
() {
118
GUM_DESTRUCTOR
(
DBRowGeneratorIdentity
);
119
}
120
121
122
/// copy operator
123
template
<
template
<
typename
>
class
ALLOC
>
124
DBRowGeneratorIdentity
<
ALLOC
>&
125
DBRowGeneratorIdentity
<
ALLOC
>::
operator
=(
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
) {
126
DBRowGenerator
<
ALLOC
>::
operator
=(
from
);
127
_input_row_
=
from
.
_input_row_
;
128
return
*
this
;
129
}
130
131
132
/// move operator
133
template
<
template
<
typename
>
class
ALLOC
>
134
DBRowGeneratorIdentity
<
ALLOC
>&
135
DBRowGeneratorIdentity
<
ALLOC
>::
operator
=(
DBRowGeneratorIdentity
<
ALLOC
>&&
from
) {
136
DBRowGenerator
<
ALLOC
>::
operator
=(
std
::
move
(
from
));
137
_input_row_
=
from
.
_input_row_
;
138
return
*
this
;
139
}
140
141
142
/// generates new lines from those the generator gets in input
143
template
<
template
<
typename
>
class
ALLOC
>
144
INLINE
const
DBRow
<
DBTranslatedValue
,
ALLOC
>&
DBRowGeneratorIdentity
<
ALLOC
>::
generate
() {
145
this
->
decreaseRemainingRows
();
146
return
*
_input_row_
;
147
}
148
149
150
/// computes the rows it will provide in output
151
template
<
template
<
typename
>
class
ALLOC
>
152
INLINE
std
::
size_t
153
DBRowGeneratorIdentity
<
ALLOC
>::
computeRows_
(
const
DBRow
<
DBTranslatedValue
,
ALLOC
>&
row
) {
154
_input_row_
= &
row
;
155
return
std
::
size_t
(1);
156
}
157
158
159
}
/* namespace learning */
160
161
}
/* namespace gum */
162
163
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643
gum::learning::genericBNLearner::Database::Database
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
Definition:
genericBNLearner_tpl.h:31