aGrUM  0.14.2
DBRowGenerator_tpl.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  ***************************************************************************/
26 
27 #ifndef DOXYGEN_SHOULD_SKIP_THIS
28 
29 namespace gum {
30 
31  namespace learning {
32 
34  template < template < typename > class ALLOC >
36  const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >
37  column_types,
38  const DBRowGeneratorGoal goal,
39  const typename DBRowGenerator< ALLOC >::allocator_type& alloc) :
40  _column_types(column_types, alloc),
41  _columns_of_interest(alloc), _goal(goal) {
42  GUM_CONSTRUCTOR(DBRowGenerator);
43  }
44 
45 
47  template < template < typename > class ALLOC >
49  const DBRowGenerator< ALLOC >& from,
50  const typename DBRowGenerator< ALLOC >::allocator_type& alloc) :
52  _column_types(from._column_types, alloc),
54  GUM_CONS_CPY(DBRowGenerator);
55  }
56 
57 
59  template < template < typename > class ALLOC >
61  const DBRowGenerator< ALLOC >& from) :
62  DBRowGenerator< ALLOC >(from, from.getAllocator()) {}
63 
64 
66  template < template < typename > class ALLOC >
68  DBRowGenerator< ALLOC >&& from,
69  const typename DBRowGenerator< ALLOC >::allocator_type& alloc) :
71  _column_types(std::move(from._column_types), alloc),
72  _columns_of_interest(std::move(from._columns_of_interest), alloc),
73  _goal(from._goal) {
74  GUM_CONS_MOV(DBRowGenerator);
75  }
76 
77 
79  template < template < typename > class ALLOC >
80  INLINE
81  DBRowGenerator< ALLOC >::DBRowGenerator(DBRowGenerator< ALLOC >&& from) :
82  DBRowGenerator< ALLOC >(std::move(from), from.getAllocator()) {}
83 
84 
86  template < template < typename > class ALLOC >
88  GUM_DESTRUCTOR(DBRowGenerator);
89  }
90 
91 
93  template < template < typename > class ALLOC >
94  INLINE DBRowGenerator< ALLOC >& DBRowGenerator< ALLOC >::
95  operator=(const DBRowGenerator< ALLOC >& from) {
96  _nb_remaining_output_rows = from._nb_remaining_output_rows;
97  _column_types = from._column_types;
98  _columns_of_interest = from._columns_of_interest;
99  _goal = from._goal;
100  return *this;
101  }
102 
103 
105  template < template < typename > class ALLOC >
106  INLINE DBRowGenerator< ALLOC >& DBRowGenerator< ALLOC >::
107  operator=(DBRowGenerator< ALLOC >&& from) {
108  _nb_remaining_output_rows = from._nb_remaining_output_rows;
109  _column_types = std::move(from._column_types);
110  _columns_of_interest = std::move(from._columns_of_interest);
111  _goal = from._goal;
112  return *this;
113  }
114 
115 
117  template < template < typename > class ALLOC >
118  INLINE bool DBRowGenerator< ALLOC >::hasRows() {
119  return _nb_remaining_output_rows != std::size_t(0);
120  }
121 
122 
124  template < template < typename > class ALLOC >
126  const DBRow< DBTranslatedValue, ALLOC >& row) {
128  return hasRows();
129  }
130 
131 
133  template < template < typename > class ALLOC >
136  }
137 
138 
140  template < template < typename > class ALLOC >
141  INLINE void DBRowGenerator< ALLOC >::reset() {
143  }
144 
145 
146  // sets the columns of interest: the output DBRow needs only
147  // contain values fot these columns
148  template < template < typename > class ALLOC >
150  const std::vector< std::size_t, ALLOC< std::size_t > >& cols_of_interest) {
151  _columns_of_interest = cols_of_interest;
152  }
153 
154 
155  // sets the columns of interest: the output DBRow needs only
156  // contain values fot these columns
157  template < template < typename > class ALLOC >
159  std::vector< std::size_t, ALLOC< std::size_t > >&& cols_of_interest) {
160  _columns_of_interest = std::move(cols_of_interest);
161  }
162 
163 
165  template < template < typename > class ALLOC >
166  INLINE const std::vector< std::size_t, ALLOC< std::size_t > >&
168  return _columns_of_interest;
169  }
170 
171 
173  template < template < typename > class ALLOC >
176  return _columns_of_interest.get_allocator();
177  }
178 
179 
181  template < template < typename > class ALLOC >
183  return _goal;
184  }
185 
186 
187  } /* namespace learning */
188 
189 } /* namespace gum */
190 
191 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
std::vector< std::size_t, ALLOC< std::size_t > > _columns_of_interest
the set of columns of interest
The base class for all DBRow generators.
bool setInputRow(const DBRow< DBTranslatedValue, ALLOC > &row)
sets the input row from which the generator will create its output rows
DBRowGeneratorGoal
the type of things that a DBRowGenerator is designed for
DBRowGenerator< ALLOC > & operator=(const DBRowGenerator< ALLOC > &)
copy constructor
void decreaseRemainingRows()
decrease the number of remaining output rows
virtual ~DBRowGenerator()
destructor
virtual 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 correct values fot these columns ...
STL namespace.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual std::size_t _computeRows(const DBRow< DBTranslatedValue, ALLOC > &row) final
computes the rows it will provide as output
virtual void reset()
resets the generator. There are therefore no more ouput row to generate
DBRowGeneratorGoal goal() const
returns the goal of the DBRowGenerator
bool hasRows()
returns true if there are still rows that can be output by the DBRowGenerator
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
allocator_type getAllocator() const
returns the allocator used
DBRowGeneratorGoal _goal
the goal of the DBRowGenerator (just remove missing values or not)
allocator_type getAllocator() const
returns the allocator used
DBRowGenerator(const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > column_types, const DBRowGeneratorGoal goal, const allocator_type &alloc=allocator_type())
default constructor
const std::vector< std::size_t, ALLOC< std::size_t > > & columnsOfInterest() const
returns the current set of columns of interest
std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > _column_types
the types of the columns in the DatabaseTable
std::size_t _nb_remaining_output_rows
the number of output rows still to retrieve through the generate method