28 #ifndef GUM_LEARNING_DB_ROW_H 29 #define GUM_LEARNING_DB_ROW_H 33 #include <initializer_list> 54 template <
typename T_DATA,
55 template <
typename >
class ALLOC = std::allocator >
70 DBRow(
const ALLOC< T_DATA >& alloc);
75 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
78 DBRow(
const std::size_t size,
79 const T_DATA default_value,
81 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
84 DBRow(std::initializer_list< T_DATA > list,
85 const double weight = 1.0,
86 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
89 template <
template <
typename >
class OTHER_ALLOC >
90 DBRow(
const std::vector< T_DATA, OTHER_ALLOC< T_DATA > >& cells,
91 const double weight = 1.0,
92 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
95 DBRow(std::vector< T_DATA, ALLOC< T_DATA > >&& cells,
96 const double weight = 1.0,
97 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
145 const T_DATA&
operator[](
const std::size_t i)
const;
157 const std::vector< T_DATA, ALLOC< T_DATA > >&
row() const noexcept;
160 std::vector< T_DATA, ALLOC< T_DATA > >&
row() noexcept;
163 const
double& weight() const noexcept;
166 double& weight() noexcept;
169 template < template < typename > class OTHER_ALLOC >
170 void setRow(const
std::vector< T_DATA, OTHER_ALLOC< T_DATA > >& new_row);
173 void setRow(
std::vector< T_DATA, ALLOC< T_DATA > >&& new_row);
179 std::
size_t size() const noexcept;
207 template <
typename TX_DATA,
template <
typename >
class OTHER_ALLOC >
DBRow< T_DATA, ALLOC > * clone() const
virtual copy constructor
double _weight
the weight of the row
DBRow()
default constructor
DBRow< T_DATA, ALLOC > & operator=(const DBRow< T_DATA, ALLOC > &from)
copy operator
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ALLOC< T_DATA > allocator_type
std::vector< T_DATA, ALLOC< T_DATA > > _row
the row itself
void setRow(const std::vector< T_DATA, OTHER_ALLOC< T_DATA > > &new_row)
sets a new row (without changing the weight)
void setWeight(const double new_weight)
sets a new weight
The class for storing a record in a database.
const std::vector< T_DATA, ALLOC< T_DATA > > & row() const noexcept
returns the current row (without the weight)
const double & weight() const noexcept
returns the weight assigned to the DBRow
void resize(const std::size_t new_size)
resize a given row, i.e., its number of elements
std::size_t size() const noexcept
returns the number of elements in the row
T_DATA & operator[](const std::size_t i)
returns the ith content of the row
void reserve(const std::size_t new_size)
reserve a size for the elements of a given row
ALLOC< T_DATA > getAllocator() const
returns the allocator used by the DBRow
void pushBack(const T_DATA &elt)
adds a new element at the end of the row
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.