aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBRowGenerator.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
47#ifndef GUM_LEARNING_DBROW_GENERATOR_H
48#define GUM_LEARNING_DBROW_GENERATOR_H
49
50#include <vector>
51
52#include <agrum/agrum.h>
53
56
57namespace gum {
58
59 namespace learning {
60
67 enum class DBRowGeneratorGoal : char {
68 // the generator's goal is only to remove all missing values
70
71 // the generator does something else than just missing values
73 };
74
224 public:
225 // ##########################################################################
227 // ##########################################################################
228
230
232
235 DBRowGenerator(const std::vector< DBTranslatedValueType >& column_types,
237
240
243
245 virtual DBRowGenerator* clone() const = 0;
246
249
251
252
253 // ##########################################################################
255 // ##########################################################################
256
258
261 bool hasRows();
262
264
267
270
272
278
280 virtual void reset();
281
296 virtual void setColumnsOfInterest(const std::vector< std::size_t >& cols_of_interest);
297
312 virtual void setColumnsOfInterest(std::vector< std::size_t >&& cols_of_interest);
313
315 const std::vector< std::size_t >& columnsOfInterest() const;
316
319
321
322
323 protected:
325 std::size_t nb_remaining_output_rows_{std::size_t(0)};
326
328
330 std::vector< DBTranslatedValueType > column_types_;
331
333 std::vector< std::size_t > columns_of_interest_;
334
337
338
341
344
347 virtual std::size_t computeRows_(const DBRow< DBTranslatedValue >& row) = 0;
348 };
349
350 } /* namespace learning */
351
352} /* namespace gum */
353
354// include the inlined functions if necessary
355#ifndef GUM_NO_INLINE
357#endif /* GUM_NO_INLINE */
358
359#endif /* GUM_LEARNING_DBROW_GENERATOR_H */
Template implementation of DBRowGenerator.
The class representing a record stored in a tabular database.
The union class for storing the translated values in learning databases.
bool setInputRow(const DBRow< DBTranslatedValue > &row)
sets the input row from which the generator will create its output rows
std::vector< std::size_t > columns_of_interest_
the set of columns of interest
DBRowGenerator(const std::vector< DBTranslatedValueType > &column_types, const DBRowGeneratorGoal goal)
default constructor
const std::vector< std::size_t > & columnsOfInterest() const
returns the current set of columns of interest
bool hasRows()
returns true if there are still rows that can be output by the DBRowGenerator
DBRowGenerator & operator=(const DBRowGenerator &)
copy constructor
DBRowGeneratorGoal goal_
the goal of the DBRowGenerator (just remove missing values or not)
DBRowGenerator(DBRowGenerator &&from)
move constructor
virtual const DBRow< DBTranslatedValue > & generate()=0
generate new rows from the input row
virtual void setColumnsOfInterest(std::vector< std::size_t > &&cols_of_interest)
sets the columns of interest: the output DBRow needs only contain correct values fot these columns
std::size_t nb_remaining_output_rows_
the number of output rows still to retrieve through the generate method
DBRowGenerator & operator=(DBRowGenerator &&)
move constructor
DBRowGenerator(const DBRowGenerator &from)
copy constructor
std::vector< DBTranslatedValueType > column_types_
the types of the columns in the DatabaseTable
void decreaseRemainingRows()
decrease the number of remaining output rows
virtual DBRowGenerator * clone() const =0
virtual copy constructor
virtual std::size_t computeRows_(const DBRow< DBTranslatedValue > &row)=0
the method that computes the set of DBRow instances to output after method setInputRow has been calle...
DBRowGeneratorGoal goal() const
returns the goal of the DBRowGenerator
virtual void setColumnsOfInterest(const std::vector< std::size_t > &cols_of_interest)
sets the columns of interest: the output DBRow needs only contain correct values fot these columns
virtual void reset()
resets the generator. There are therefore no more ouput row to generate
virtual ~DBRowGenerator()
destructor
The class for storing a record in a database.
Definition DBRow.h:75
DBRowGeneratorGoal
the type of things that a DBRowGenerator is designed for
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46