aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBRowGeneratorParser_inl.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (c) 2005-2024 by Christophe GONZALES(_at_AMU) and Pierre-Henri WUILLEMIN(_at_LIP6) *
3 * info_at_agrum_dot_org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
25
26#ifndef DOXYGEN_SHOULD_SKIP_THIS
27
28namespace gum {
29
30 namespace learning {
31
34 if (this != &from) {
35 _handler_ = from._handler_;
36 _generator_set_ = from._generator_set_;
37 _generator_size_ = from._generator_size_;
38 }
39 return *this;
40 }
41
42
45 if (this != &from) {
46 _handler_ = std::move(from._handler_);
47 _generator_set_ = std::move(from._generator_set_);
48 _generator_size_ = from._generator_size_;
49 }
50 return *this;
51 }
52
53
55 INLINE bool DBRowGeneratorParser::hasRows() {
56 if (!_generator_size_) return _handler_.hasRows();
57
58 while (!_generator_set_.hasRows()) {
59 if (!_handler_.hasRows()) return false;
60 _generator_set_.setInputRow(*_handler_);
61 ++_handler_;
62 }
63 return true;
64 }
65
66
69 // if there exists no generator in the generator set, we just return
70 // the row pointed to by the handler
71 if (!_generator_size_) {
72 const auto& pointed_row = *_handler_;
73 ++_handler_;
74 return pointed_row;
75 } else {
76 return _generator_set_.generate();
77 }
78 }
79
80
82 INLINE void DBRowGeneratorParser::reset() {
83 _handler_.reset();
84 _generator_set_.reset();
85 }
86
87
88 // returns the handler used by the filter
90
91
92 // returns the handler used by the filter
93 INLINE const typename DatabaseTable::Handler& DBRowGeneratorParser::handler() const {
94 return _handler_;
95 }
96
97
99 INLINE const DatabaseTable& DBRowGeneratorParser::database() const {
100 return static_cast< const DatabaseTable& >(_handler_.database());
101 }
102
103
106
107
109 INLINE void DBRowGeneratorParser::setRange(std::size_t begin, std::size_t end) {
110 _handler_.setRange(begin, end);
111 }
112
113
116 return _generator_set_;
117 }
118
119
123 const std::vector< std::size_t >& cols_of_interest) {
124 _generator_set_.setColumnsOfInterest(cols_of_interest);
125 }
126
127
130 INLINE void
131 DBRowGeneratorParser::setColumnsOfInterest(std::vector< std::size_t >&& cols_of_interest) {
132 _generator_set_.setColumnsOfInterest(std::move(cols_of_interest));
133 }
134
135
136 } /* namespace learning */
137
138} /* namespace gum */
139
140#endif /* DOXYGEN_SHOULD_SKIP_THIS */
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
void reset()
resets the parser
std::size_t _generator_size_
the size of the generator set
const DatabaseTable & database() const
returns a reference on the database
DBRowGeneratorParser & operator=(const DBRowGeneratorParser &from)
copy operator
bool hasRows()
returns true if there are still rows that can be output by the DBRowGeneratorParser
void setRange(std::size_t begin, std::size_t end)
sets the area in the database the handler will handle
void setColumnsOfInterest(const std::vector< std::size_t > &cols_of_interest)
sets the columns of interest: the output DBRow needs only contain values fot these columns
DBRowGeneratorSet _generator_set_
the set of DBRow generators (might be empty)
DatabaseTable::Handler _handler_
the handler that is really used to parse the database
DBRowGeneratorSet & generatorSet()
returns the generator set that is actually used
const DBRow< DBTranslatedValue > & row()
returns a new output row with its corresponding weight
DatabaseTable::Handler & handler()
returns the handler used by the parser
The class used to pack sets of generators.
The class for storing a record in a database.
Definition DBRow.h:75
The class representing a tabular database as used by learning tasks.
typename IDatabaseTable< DBTranslatedValue >::Handler Handler
the unsafe 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