aGrUM  0.16.0
DBRowGenerator4CompleteRows_tpl.h
Go to the documentation of this file.
1 
30 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 
33 namespace gum {
34 
35  namespace learning {
36 
38  template < template < typename > class ALLOC >
42  }
43 
44 
46  template < template < typename > class ALLOC >
48  const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >
49  column_types,
51  alloc) :
52  DBRowGenerator< ALLOC >(
53  column_types, DBRowGeneratorGoal::ONLY_REMOVE_MISSING_VALUES, alloc) {
54  GUM_CONSTRUCTOR(DBRowGenerator4CompleteRows);
55  }
56 
57 
59  template < template < typename > class ALLOC >
61  const DBRowGenerator4CompleteRows< ALLOC >& from,
63  alloc) :
64  DBRowGenerator< ALLOC >(from, alloc),
65  __input_row(from.__input_row) {
66  GUM_CONS_CPY(DBRowGenerator4CompleteRows);
67  }
68 
69 
71  template < template < typename > class ALLOC >
73  const DBRowGenerator4CompleteRows< ALLOC >& from) :
74  DBRowGenerator4CompleteRows< ALLOC >(from, from.getAllocator()) {}
75 
76 
78  template < template < typename > class ALLOC >
80  DBRowGenerator4CompleteRows< ALLOC >&& from,
82  alloc) :
83  DBRowGenerator< ALLOC >(std::move(from), alloc),
84  __input_row(from.__input_row) {
85  GUM_CONS_MOV(DBRowGenerator4CompleteRows);
86  }
87 
88 
90  template < template < typename > class ALLOC >
92  DBRowGenerator4CompleteRows< ALLOC >&& from) :
93  DBRowGenerator4CompleteRows< ALLOC >(std::move(from),
94  from.getAllocator()) {}
95 
96 
98  template < template < typename > class ALLOC >
99  DBRowGenerator4CompleteRows< ALLOC >*
102  alloc) const {
103  ALLOC< DBRowGenerator4CompleteRows< ALLOC > > allocator(alloc);
104  DBRowGenerator4CompleteRows< ALLOC >* generator = allocator.allocate(1);
105  try {
106  allocator.construct(generator, *this, alloc);
107  } catch (...) {
108  allocator.deallocate(generator, 1);
109  throw;
110  }
111  return generator;
112  }
113 
114 
116  template < template < typename > class ALLOC >
117  DBRowGenerator4CompleteRows< ALLOC >*
119  return clone(this->getAllocator());
120  }
121 
122 
124  template < template < typename > class ALLOC >
126  GUM_DESTRUCTOR(DBRowGenerator4CompleteRows);
127  }
128 
129 
131  template < template < typename > class ALLOC >
132  DBRowGenerator4CompleteRows< ALLOC >& DBRowGenerator4CompleteRows< ALLOC >::
133  operator=(const DBRowGenerator4CompleteRows< ALLOC >& from) {
135  __input_row = from.__input_row;
136  return *this;
137  }
138 
139 
141  template < template < typename > class ALLOC >
142  DBRowGenerator4CompleteRows< ALLOC >& DBRowGenerator4CompleteRows< ALLOC >::
143  operator=(DBRowGenerator4CompleteRows< ALLOC >&& from) {
144  DBRowGenerator< ALLOC >::operator=(std::move(from));
145  __input_row = from.__input_row;
146  return *this;
147  }
148 
149 
151  template < template < typename > class ALLOC >
152  INLINE const DBRow< DBTranslatedValue, ALLOC >&
154  this->decreaseRemainingRows();
155  return *__input_row;
156  }
157 
158 
160  template < template < typename > class ALLOC >
162  const DBRow< DBTranslatedValue, ALLOC >& row) {
163  // check that all the values are observed
164  const auto& xrow = row.row();
165  for (const auto col : this->_columns_of_interest) {
166  switch (this->_column_types[col]) {
168  if (xrow[col].discr_val == std::numeric_limits< std::size_t >::max()) {
169  __input_row = nullptr;
170  return std::size_t(0);
171  }
172  break;
173 
175  if (xrow[col].cont_val == std::numeric_limits< float >::max()) {
176  __input_row = nullptr;
177  return std::size_t(0);
178  }
179  break;
180 
181  default:
182  GUM_ERROR(NotImplementedYet,
183  "DBTranslatedValueType " << int(this->_column_types[col])
184  << " is not supported yet");
185  break;
186  }
187  }
188  __input_row = &row;
189  return std::size_t(1);
190  }
191 
192 
193  } /* namespace learning */
194 
195 } /* namespace gum */
196 
197 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
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
DBRowGenerator< ALLOC > & operator=(const DBRowGenerator< ALLOC > &)
copy constructor
void decreaseRemainingRows()
decrease the number of remaining output rows
STL namespace.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual std::size_t _computeRows(const DBRow< DBTranslatedValue, ALLOC > &row) final
computes the rows it will provide as output
DBRowGenerator4CompleteRows< ALLOC > & operator=(const DBRowGenerator4CompleteRows< ALLOC > &from)
copy operator
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
allocator_type getAllocator() const
returns the allocator used
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
DBRowGenerator4CompleteRows(const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > column_types, const allocator_type &alloc=allocator_type())
default constructor
std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > _column_types
the types of the columns in the DatabaseTable
virtual const DBRow< DBTranslatedValue, ALLOC > & generate() final
generates one ouput DBRow for each DBRow passed to method setInputRow
virtual DBRowGenerator4CompleteRows< ALLOC > * clone() const override final
virtual copy constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55