aGrUM  0.14.2
DBRowGenerator.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_DBROW_GENERATOR_H
26 #define GUM_LEARNING_DBROW_GENERATOR_H
27 
28 #include <vector>
29 
30 #include <agrum/agrum.h>
33 
34 namespace gum {
35 
36  namespace learning {
37 
44  enum class DBRowGeneratorGoal : char {
45  // the generator's goal is only to remove all missing values
47 
48  // the generator does something else than just missing values
50  };
51 
52 
231  template < template < typename > class ALLOC = std::allocator >
233  public:
235  using allocator_type = ALLOC< DBTranslatedValue >;
236 
237  // ##########################################################################
239  // ##########################################################################
240 
242 
244 
248  const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >
249  column_types,
250  const DBRowGeneratorGoal goal,
251  const allocator_type& alloc = allocator_type());
252 
255 
258  const allocator_type& alloc);
259 
262 
265 
267  virtual DBRowGenerator< ALLOC >* clone() const = 0;
268 
270  virtual DBRowGenerator< ALLOC >*
271  clone(const allocator_type& alloc) const = 0;
272 
274  virtual ~DBRowGenerator();
275 
277 
278 
279  // ##########################################################################
281  // ##########################################################################
282 
284 
287  bool hasRows();
288 
290 
292  bool setInputRow(const DBRow< DBTranslatedValue, ALLOC >& row);
293 
295  virtual const DBRow< DBTranslatedValue, ALLOC >& generate() = 0;
296 
298 
303  void decreaseRemainingRows();
304 
306  virtual void reset();
307 
322  virtual void setColumnsOfInterest(
323  const std::vector< std::size_t, ALLOC< std::size_t > >& cols_of_interest);
324 
339  virtual void setColumnsOfInterest(
340  std::vector< std::size_t, ALLOC< std::size_t > >&& cols_of_interest);
341 
343  const std::vector< std::size_t, ALLOC< std::size_t > >&
344  columnsOfInterest() const;
345 
347  allocator_type getAllocator() const;
348 
350  DBRowGeneratorGoal goal() const;
351 
353 
354 
355  protected:
357  std::size_t _nb_remaining_output_rows{std::size_t(0)};
358 
360 
362  std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >
364 
366  std::vector< std::size_t, ALLOC< std::size_t > > _columns_of_interest;
367 
371 
372 
375 
378 
381  virtual std::size_t
382  _computeRows(const DBRow< DBTranslatedValue, ALLOC >& row) = 0;
383  };
384 
385  } /* namespace learning */
386 
387 } /* namespace gum */
388 
389 
390 // always include the template implementation
392 
393 #endif /* GUM_LEARNING_DBROW_GENERATOR_H */
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
The union class for storing the translated values in learning databases.
std::vector< std::size_t, ALLOC< std::size_t > > _columns_of_interest
the set of columns of interest
DBRowGeneratorGoal
the type of things that a DBRowGenerator is designed for
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class representing a record stored in a tabular database.
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
The class for storing a record in a database.
Definition: DBRow.h:53
Template implementation of DBRowGenerator.
std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > _column_types
the types of the columns in the DatabaseTable
The base class for all DBRow generators.