aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
DBRowGeneratorIdentity_tpl.h
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
/** @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
> >
48
column_types
,
49
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
50
DBRowGenerator
<
ALLOC
>(
51
column_types
,
52
DBRowGeneratorGoal
::
OTHER_THINGS_THAN_REMOVE_MISSING_VALUES
,
53
alloc
) {
54
GUM_CONSTRUCTOR
(
DBRowGeneratorIdentity
);
55
}
56
57
58
/// copy constructor with a given allocator
59
template
<
template
<
typename
>
class
ALLOC
>
60
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
61
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
,
62
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
63
DBRowGenerator
<
ALLOC
>(
from
,
alloc
),
64
input_row__
(
from
.
input_row__
) {
65
GUM_CONS_CPY
(
DBRowGeneratorIdentity
);
66
}
67
68
69
/// copy constructor
70
template
<
template
<
typename
>
class
ALLOC
>
71
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
72
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
) :
73
DBRowGeneratorIdentity
<
ALLOC
>(
from
,
from
.
getAllocator
()) {}
74
75
76
/// move constructor with a given allocator
77
template
<
template
<
typename
>
class
ALLOC
>
78
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
79
DBRowGeneratorIdentity
<
ALLOC
>&&
from
,
80
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
) :
81
DBRowGenerator
<
ALLOC
>(
std
::
move
(
from
),
alloc
),
82
input_row__
(
from
.
input_row__
) {
83
GUM_CONS_MOV
(
DBRowGeneratorIdentity
);
84
}
85
86
87
/// move constructor
88
template
<
template
<
typename
>
class
ALLOC
>
89
DBRowGeneratorIdentity
<
ALLOC
>::
DBRowGeneratorIdentity
(
90
DBRowGeneratorIdentity
<
ALLOC
>&&
from
) :
91
DBRowGeneratorIdentity
<
ALLOC
>(
std
::
move
(
from
),
from
.
getAllocator
()) {}
92
93
94
/// virtual copy constructor with a given allocator
95
template
<
template
<
typename
>
class
ALLOC
>
96
DBRowGeneratorIdentity
<
ALLOC
>*
DBRowGeneratorIdentity
<
ALLOC
>::
clone
(
97
const
typename
DBRowGeneratorIdentity
<
ALLOC
>::
allocator_type
&
alloc
)
98
const
{
99
ALLOC
<
DBRowGeneratorIdentity
<
ALLOC
> >
allocator
(
alloc
);
100
DBRowGeneratorIdentity
<
ALLOC
>*
generator
=
allocator
.
allocate
(1);
101
try
{
102
allocator
.
construct
(
generator
, *
this
,
alloc
);
103
}
catch
(...) {
104
allocator
.
deallocate
(
generator
, 1);
105
throw
;
106
}
107
return
generator
;
108
}
109
110
111
/// virtual copy constructor
112
template
<
template
<
typename
>
class
ALLOC
>
113
DBRowGeneratorIdentity
<
ALLOC
>*
114
DBRowGeneratorIdentity
<
ALLOC
>::
clone
()
const
{
115
return
clone
(
this
->
getAllocator
());
116
}
117
118
119
/// destructor
120
template
<
template
<
typename
>
class
ALLOC
>
121
DBRowGeneratorIdentity
<
ALLOC
>::~
DBRowGeneratorIdentity
() {
122
GUM_DESTRUCTOR
(
DBRowGeneratorIdentity
);
123
}
124
125
126
/// copy operator
127
template
<
template
<
typename
>
class
ALLOC
>
128
DBRowGeneratorIdentity
<
ALLOC
>&
DBRowGeneratorIdentity
<
ALLOC
>::
operator
=(
129
const
DBRowGeneratorIdentity
<
ALLOC
>&
from
) {
130
DBRowGenerator
<
ALLOC
>::
operator
=(
from
);
131
input_row__
=
from
.
input_row__
;
132
return
*
this
;
133
}
134
135
136
/// move operator
137
template
<
template
<
typename
>
class
ALLOC
>
138
DBRowGeneratorIdentity
<
ALLOC
>&
DBRowGeneratorIdentity
<
ALLOC
>::
operator
=(
139
DBRowGeneratorIdentity
<
ALLOC
>&&
from
) {
140
DBRowGenerator
<
ALLOC
>::
operator
=(
std
::
move
(
from
));
141
input_row__
=
from
.
input_row__
;
142
return
*
this
;
143
}
144
145
146
/// generates new lines from those the generator gets in input
147
template
<
template
<
typename
>
class
ALLOC
>
148
INLINE
const
DBRow
<
DBTranslatedValue
,
ALLOC
>&
149
DBRowGeneratorIdentity
<
ALLOC
>::
generate
() {
150
this
->
decreaseRemainingRows
();
151
return
*
input_row__
;
152
}
153
154
155
/// computes the rows it will provide in output
156
template
<
template
<
typename
>
class
ALLOC
>
157
INLINE
std
::
size_t
DBRowGeneratorIdentity
<
ALLOC
>::
computeRows_
(
158
const
DBRow
<
DBTranslatedValue
,
ALLOC
>&
row
) {
159
input_row__
= &
row
;
160
return
std
::
size_t
(1);
161
}
162
163
164
}
/* namespace learning */
165
166
}
/* namespace gum */
167
168
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669
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