aGrUM  0.14.2
DBRowGeneratorParser.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
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 #ifndef GUM_LEARNING_DB_ROW_GENERATOR_PARSER_H
26 #define GUM_LEARNING_DB_ROW_GENERATOR_PARSER_H
27 
28 #include <limits>
29 
30 #include <agrum/agrum.h>
34 
35 namespace gum {
36 
37  namespace learning {
38 
85  template <template<typename> class ALLOC = std::allocator>
87  public:
88 
90  using allocator_type = ALLOC<DBTranslatedValue>;
91 
92  // ##########################################################################
94  // ##########################################################################
95 
97 
100  const DBRowGeneratorSet<ALLOC>& generator_set,
101  const allocator_type& alloc = allocator_type () );
102 
105 
108  const allocator_type& alloc );
109 
112 
115  const allocator_type& alloc );
116 
118  virtual DBRowGeneratorParser<ALLOC>* clone () const;
119 
122  clone (const allocator_type& alloc) const;
123 
125  virtual ~DBRowGeneratorParser();
126 
128 
129  // ##########################################################################
131  // ##########################################################################
132 
134 
138 
142 
144 
145  // ##########################################################################
147  // ##########################################################################
148 
150 
177  bool hasRows();
178 
180 
204 
206  void reset();
207 
210 
212  const typename DatabaseTable<ALLOC>::Handler& handler() const;
213 
215  const DatabaseTable<ALLOC>& database () const;
216 
219 
221  const DBRowGeneratorSet<ALLOC>& generatorSet() const;
222 
224 
234  void setRange(std::size_t begin, std::size_t end);
235 
246  void setColumnsOfInterest (
247  const std::vector<std::size_t,ALLOC<std::size_t>>& cols_of_interest );
248 
259  void setColumnsOfInterest (
260  std::vector<std::size_t,ALLOC<std::size_t>>&& cols_of_interest );
261 
263 
268  template < typename GUM_SCALAR >
269  void setBayesNet (const BayesNet<GUM_SCALAR>& new_bn);
270 
272  allocator_type getAllocator () const;
273 
275 
276 
277  private:
278 
281 
284 
286  std::size_t __generator_size;
287 
288  };
289 
290  } /* namespace learning */
291 
292 } /* namespace gum */
293 
294 // always include the template implementation
296 
297 #endif /* GUM_LEARNING_DB_ROW_GENERATOR_PARSER_H */
DatabaseTable< ALLOC >::Handler & handler()
returns the handler used by the parser
Class representing a Bayesian Network.
Definition: BayesNet.h:76
std::size_t __generator_size
the size of the generator set
virtual DBRowGeneratorParser< ALLOC > * clone() const
virtual copy constructor
The class representing a tabular database stored in RAM.
void setBayesNet(const BayesNet< GUM_SCALAR > &new_bn)
assign a new Bayes net to all the generators that depend on a BN
The base class for all database handlers.
The class used to pack sets of generators.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
DBRowGeneratorParser< ALLOC > & operator=(const DBRowGeneratorParser< ALLOC > &from)
copy operator
void setColumnsOfInterest(const std::vector< std::size_t, ALLOC< std::size_t >> &cols_of_interest)
sets the columns of interest: the output DBRow needs only contain values fot these columns ...
typename IDatabaseTable< DBTranslatedValue, ALLOC >::Handler Handler
the unsafe handler type
allocator_type getAllocator() const
returns the allocator used
virtual ~DBRowGeneratorParser()
destructor
Template implementation of the DBRowGeneratorParser class.
The class for storing a record in a database.
Definition: DBRow.h:53
const DBRow< DBTranslatedValue, ALLOC > & row()
returns a new output row with its corresponding weight
The class representing a tabular database as used by learning tasks.
bool hasRows()
returns true if there are still rows that can be output by the DBRowGeneratorParser ...
class for packing sets of generators
DBRowGeneratorSet< ALLOC > & generatorSet()
returns the generator set that is actually used
const DatabaseTable< ALLOC > & database() const
returns a reference on the database
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
DBRowGeneratorSet< ALLOC > __generator_set
the set of DBRow generators (might be empty)
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
void setRange(std::size_t begin, std::size_t end)
sets the area in the database the handler will handle
DBRowGeneratorParser(const typename DatabaseTable< ALLOC >::Handler &handler, const DBRowGeneratorSet< ALLOC > &generator_set, const allocator_type &alloc=allocator_type())
default constructor
DatabaseTable< ALLOC >::Handler __handler
the handler that is really used to parse the database