aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
rawDatabaseTable.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 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-2025 *
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
61#ifndef GUM_RAW_DATABASE_TABLE_H
62#define GUM_RAW_DATABASE_TABLE_H
63
64
65#include <agrum/agrum.h>
66
68
69namespace gum {
70
71 namespace learning {
72
134 class RawDatabaseTable: public IDatabaseTable< DBCell > {
135 public:
137 template < typename TX_DATA >
138 using DBVector = std::vector< TX_DATA >;
139
141 template < typename TX_DATA >
143
145 template < typename TX_DATA >
147
148 using MissingValType = std::vector< std::string >;
149
152
155
157
164 using const_pointer = const value_type*;
165 using size_type = std::size_t;
166 using difference_type = std::ptrdiff_t;
170
171
172 // ##########################################################################
174 // ##########################################################################
176
178 RawDatabaseTable(const MissingValType& missing_symbols,
179 const std::vector< std::string >& var_names);
180
182 RawDatabaseTable(const MissingValType& missing_symbols);
183
186
189
192
194 virtual RawDatabaseTable* clone() const final;
195
198
200
201
202 // ##########################################################################
204 // ##########################################################################
206
208 RawDatabaseTable& operator=(const RawDatabaseTable& from);
209
212
214
215
216 // ##########################################################################
218 // ##########################################################################
220
222
224
249 void setVariableNames(const std::vector< std::string >& names,
250 const bool from_external_object = true) final;
251
253
282 void ignoreColumn(const std::size_t k, const bool from_external_object = true) final;
283
285 const DBVector< std::size_t > ignoredColumns() const final;
286
289 const DBVector< std::size_t > inputColumns() const final;
290
292
294
300 void insertRow(const std::vector< std::string >& new_row) final;
301
303 virtual void clear() final;
304
306
307
308#ifndef DOXYGEN_SHOULD_SKIP_THIS
309
310 private:
311 // the set of ignored columns, sorted by increasing order
312 DBVector< std::size_t > _ignored_cols_;
313
315 DBCell _convert_(const std::string& elt) const;
316
317#endif /* DOXYGEN_SHOULD_SKIP_THIS */
318 };
319
320 } /* namespace learning */
321
322} /* namespace gum */
323
324// include the inlined functions if necessary
325#ifndef GUM_NO_INLINE
327#endif /* GUM_NO_INLINE */
328
329#endif /* GUM_RAW_DATABASE_TABLE_H */
The common class for the tabular database tables.
The class representing the original values of the cells of databases.
Definition DBCell.h:93
the safe handler of the tabular databases
the (unsafe) handler for the tabular databases
IDatabaseTable(const MissingValType &missing_symbols, const std::vector< std::string > &var_names)
typename IDatabaseTable< DBCell >::Handler Handler
the unsafe handler type
std::vector< std::string > MissingValType
value_type * pointer
Types for STL compliance.
RawDatabaseTable(RawDatabaseTable &&from)
move constructor
std::ptrdiff_t difference_type
Types for STL compliance.
Handler iterator
Types for STL compliance.
virtual void clear() final
erase the content of the database, including the names of the variables
DBRow< TX_DATA > Row
a row of the database
typename IDatabaseTable< DBCell >::IsMissing IsMissing
const value_type * const_pointer
Types for STL compliance.
virtual RawDatabaseTable * clone() const final
virtual copy constructor
HandlerSafe iterator_safe
Types for STL compliance.
Row< DBCell > value_type
Types for STL compliance.
void insertRow(const std::vector< std::string > &new_row) final
insert a new row at the end of the database
DBVector< Row< TX_DATA > > Matrix
the type for the matrices stored into the database
const DBVector< std::size_t > ignoredColumns() const final
returns the set of columns of the original dataset that are ignored
std::size_t size_type
Types for STL compliance.
value_type & reference
Types for STL compliance.
RawDatabaseTable(const MissingValType &missing_symbols)
default constructor
RawDatabaseTable(const MissingValType &missing_symbols, const std::vector< std::string > &var_names)
default constructor
RawDatabaseTable()
default constructor
RawDatabaseTable(const RawDatabaseTable &from)
copy constructor
void ignoreColumn(const std::size_t k, const bool from_external_object=true) final
makes the database table ignore from now on the kth column
void setVariableNames(const std::vector< std::string > &names, const bool from_external_object=true) final
sets the names of the variables
std::vector< TX_DATA > DBVector
the type for the vectors used in the RawDatabaseTable
const DBVector< std::size_t > inputColumns() const final
returns the set of columns of the original dataset that are present in the RawDatabaseTable
const value_type & const_reference
Types for STL compliance.
typename IDatabaseTable< DBCell >::HandlerSafe HandlerSafe
the safe handler type
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
The implementation of raw tabular databases stored in memory (RAM).