aGrUM  0.17.2
a C++ library for (probabilistic) graphical models
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 >&
134  const DBRowGenerator4CompleteRows< ALLOC >& from) {
136  __input_row = from.__input_row;
137  return *this;
138  }
139 
140 
142  template < template < typename > class ALLOC >
143  DBRowGenerator4CompleteRows< ALLOC >&
145  DBRowGenerator4CompleteRows< ALLOC >&& from) {
146  DBRowGenerator< ALLOC >::operator=(std::move(from));
147  __input_row = from.__input_row;
148  return *this;
149  }
150 
151 
153  template < template < typename > class ALLOC >
154  INLINE const DBRow< DBTranslatedValue, ALLOC >&
156  this->decreaseRemainingRows();
157  return *__input_row;
158  }
159 
160 
162  template < template < typename > class ALLOC >
164  const DBRow< DBTranslatedValue, ALLOC >& row) {
165  // check that all the values are observed
166  const auto& xrow = row.row();
167  for (const auto col: this->_columns_of_interest) {
168  switch (this->_column_types[col]) {
170  if (xrow[col].discr_val == std::numeric_limits< std::size_t >::max()) {
171  __input_row = nullptr;
172  return std::size_t(0);
173  }
174  break;
175 
177  if (xrow[col].cont_val == std::numeric_limits< float >::max()) {
178  __input_row = nullptr;
179  return std::size_t(0);
180  }
181  break;
182 
183  default:
184  GUM_ERROR(NotImplementedYet,
185  "DBTranslatedValueType " << int(this->_column_types[col])
186  << " is not supported yet");
187  break;
188  }
189  }
190  __input_row = &row;
191  return std::size_t(1);
192  }
193 
194 
195  } /* namespace learning */
196 
197 } /* namespace gum */
198 
199 #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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55