aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
IDBInitializer.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
48
#ifndef GUM_LEARNING_IDB_INITILIALIZER_H
49
#define GUM_LEARNING_IDB_INITILIALIZER_H
50
51
#include <string>
52
#include <vector>
53
54
#include <
agrum/agrum.h
>
55
56
#include <
agrum/base/database/DBCell.h
>
57
#include <
agrum/base/database/DBRow.h
>
58
59
namespace
gum
{
60
61
namespace
learning
{
62
135
class
GUM_SHARED_PUBLIC
IDBInitializer
{
136
public
:
139
enum class
InputType
:
char
{ STRING, DBCELL };
140
141
// ##########################################################################
143
// ##########################################################################
145
147
149
IDBInitializer
(
const
InputType
type);
150
152
IDBInitializer
(
const
IDBInitializer
& from);
153
155
IDBInitializer
(
IDBInitializer
&& from);
156
158
[[nodiscard]]
virtual
IDBInitializer
*
clone
()
const
= 0;
159
161
virtual
~IDBInitializer
();
162
164
165
166
// ##########################################################################
168
// ##########################################################################
170
172
const
std::vector< std::string >&
variableNames
();
173
175
177
template
<
class
DATABASE >
178
void
fillDatabase
(DATABASE& database,
const
bool
retry_insertion =
false
);
179
182
std::size_t
throwingColumn
()
const
;
183
185
186
187
protected
:
189
IDBInitializer
&
operator=
(
const
IDBInitializer
& from);
190
192
IDBInitializer
&
operator=
(
IDBInitializer
&& from);
193
195
virtual
std::vector< std::string >
variableNames_
() = 0;
196
198
199
virtual
const
std::vector< std::string >&
currentStringRow_
();
200
202
203
virtual
const
DBRow< DBCell >
&
currentDBCellRow_
();
204
206
virtual
bool
nextRow_
() = 0;
207
208
209
#ifndef DOXYGEN_SHOULD_SKIP_THIS
210
211
private
:
212
// the names of the variables
213
std::vector< std::string > _var_names_;
214
215
// the types of the input data read to fill the database
216
InputType
_input_type_;
217
218
// indicates whether an exception was raised when adding the last row
219
// into the database. If so, when filling again the database, we may
220
// try to insert again the same row
221
bool
_last_insertion_failed_{
false
};
222
223
225
template
<
class
DATABASE >
226
void
_fillDatabaseFromStrings_(DATABASE& database,
const
bool
retry_insertion);
227
229
template
<
class
DATABASE >
230
void
_fillDatabaseFromDBCells_(DATABASE& database,
const
bool
retry_insertion);
231
232
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
233
};
234
235
}
/* namespace learning */
236
237
}
/* namespace gum */
238
240
#ifndef GUM_NO_INLINE
241
# include <
agrum/base/database/IDBInitializer_inl.h
>
242
#endif
/* GUM_NO_INLINE */
243
244
// always include the template implementation
245
#include <
agrum/base/database/IDBInitializer_tpl.h
>
246
247
#endif
/* GUM_LEARNING_IDB_INITILIALIZER_H */
DBCell.h
The class representing the original values of the cells of databases.
DBRow.h
The class representing a record stored in a tabular database.
IDBInitializer_inl.h
Inlined implementation for initializing DatabaseTables and RawDatabaseTables from files or sql databa...
IDBInitializer_tpl.h
The base class for initializing DatabaseTables and RawDatabaseTables from files or sql databases.
agrum.h
gum::learning::DBRow
The class for storing a record in a database.
Definition
DBRow.h:75
gum::learning::IDBInitializer::~IDBInitializer
virtual ~IDBInitializer()
destructor
gum::learning::IDBInitializer::operator=
IDBInitializer & operator=(const IDBInitializer &from)
copy operator
gum::learning::IDBInitializer::currentDBCellRow_
virtual const DBRow< DBCell > & currentDBCellRow_()
asks the child class for the content of the current row using dbcells
gum::learning::IDBInitializer::clone
virtual IDBInitializer * clone() const =0
virtual copy constructor
gum::learning::IDBInitializer::operator=
IDBInitializer & operator=(IDBInitializer &&from)
move operator
gum::learning::IDBInitializer::IDBInitializer
IDBInitializer(IDBInitializer &&from)
move constructor
gum::learning::IDBInitializer::IDBInitializer
IDBInitializer(const InputType type)
default constructor
gum::learning::IDBInitializer::fillDatabase
void fillDatabase(DATABASE &database, const bool retry_insertion=false)
fills the rows of the database table
gum::learning::IDBInitializer::InputType
InputType
the enumeration indicating the type of the data the IDBInitializer expects as input data
Definition
IDBInitializer.h:139
gum::learning::IDBInitializer::variableNames_
virtual std::vector< std::string > variableNames_()=0
ask the child class for the names of the variables
gum::learning::IDBInitializer::nextRow_
virtual bool nextRow_()=0
indicates whether there is a next row to read (and point on it)
gum::learning::IDBInitializer::variableNames
const std::vector< std::string > & variableNames()
returns the names of the variables in the input dataset
gum::learning::IDBInitializer::throwingColumn
std::size_t throwingColumn() const
This method indicates which column filling raised an exception, if any, during the execution of fillD...
gum::learning::IDBInitializer::IDBInitializer
IDBInitializer(const IDBInitializer &from)
copy constructor
gum::learning::IDBInitializer::currentStringRow_
virtual const std::vector< std::string > & currentStringRow_()
asks the child class for the content of the current row using strings
gum::learning
include the inlined functions if necessary
Definition
CSVParser.h:55
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0