31 #ifndef GUM_IDATABASE_TABLE_H 32 #define GUM_IDATABASE_TABLE_H 55 template <
template <
typename >
class ALLOC,
bool ENABLE_INSERT >
58 template <
template <
typename >
class ALLOC >
60 template <
typename TX_DATA >
61 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
63 template <
typename TX_DATA >
66 template <
typename TX_DATA >
68 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
94 virtual void insertRow(
95 const std::vector< std::string, ALLOC< std::string > >& new_row) = 0;
104 template <
template <
typename >
class ALLOC >
106 template <
typename TX_DATA >
107 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
109 template <
typename TX_DATA >
112 template <
typename TX_DATA >
114 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
119 virtual void insertRow(
120 const std::vector< std::string, ALLOC< std::string > >& new_row) = 0;
255 template <
typename T_DATA,
256 template <
typename >
class ALLOC = std::allocator >
260 !std::is_same< T_DATA, DBCell >::value >
261 ,
private ALLOC< T_DATA > {
264 template <
typename TX_DATA >
265 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
268 template <
typename TX_DATA >
272 template <
typename TX_DATA >
274 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
276 template <
template <
typename >
class XALLOC >
389 template <
typename TX_DATA >
390 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
392 template <
typename TX_DATA >
395 template <
typename TX_DATA >
396 using Matrix = std::vector< DBRow< TX_DATA, ALLOC >,
397 ALLOC< DBRow< TX_DATA, ALLOC > > >;
437 virtual Handler& operator++() final;
443 virtual
Handler& operator--() final;
449 virtual
Handler& operator+=(const
std::
size_t i) final;
455 virtual
Handler& operator-=(const
std::
size_t i) final;
458 virtual
bool operator==(const
Handler& handler) const final;
461 virtual
bool operator!=(const
Handler& handler) const final;
493 virtual
std::
size_t size() const final;
496 virtual
std::
size_t DBSize() const final;
521 virtual
void nextRow() final;
524 virtual
std::
size_t numRow() const final;
527 virtual
bool hasRows() const final;
530 virtual
void reset() final;
557 virtual
void setRange(
std::
size_t begin,
std::
size_t end) final;
560 virtual
std::pair<
std::
size_t,
std::
size_t > range() const final;
563 virtual const
DBVector<
std::
string >& variableNames() const final;
566 virtual
std::
size_t nbVariables() const final;
576 #ifndef DOXYGEN_SHOULD_SKIP_THIS 588 std::size_t __index{std::size_t(0)};
591 std::size_t __begin_index{std::size_t(0)};
594 std::size_t __end_index{std::size_t(0)};
748 #ifndef DOXYGEN_SHOULD_SKIP_THIS 752 void __attachHandler();
755 void __detachHandler();
786 template <
template <
typename >
class VARALLOC,
787 template <
typename >
791 const std::vector< std::string, VARALLOC< std::string > >& var_names,
792 const ALLOC< T_DATA >& alloc);
833 const iterator& end() const noexcept;
847 const
Matrix< T_DATA >& content() const noexcept;
857 const
DBVector<
std::
string >& variableNames() const noexcept;
885 virtual
void setVariableNames(
886 const
std::vector<
std::
string, ALLOC<
std::
string > >& names,
887 const
bool from_external_object = true) = 0;
915 template < template < typename > class OTHER_ALLOC >
916 void setVariableNames(
917 const
std::vector<
std::
string, OTHER_ALLOC<
std::
string > >& names,
918 const
bool from_external_object = true);
923 const
std::
string& variableName(const
std::
size_t k) const;
931 std::
size_t columnFromVariableName(const
std::
string& name) const;
938 columnsFromVariableName(const
std::
string& name) const;
941 std::
size_t nbVariables() const noexcept;
944 std::
size_t nbRows() const noexcept;
947 std::
size_t size() const noexcept;
950 bool empty() const noexcept;
982 virtual
void ignoreColumn(const
std::
size_t k,
983 const
bool from_external_object = true) = 0;
986 virtual const
DBVector<
std::
size_t > ignoredColumns() const = 0;
990 virtual const
DBVector<
std::
size_t > inputColumns() const = 0;
994 !
std::is_same< T_DATA,
DBCell >::value >::insertRow;
1002 template < template < typename > class OTHER_ALLOC >
1004 const
std::vector<
std::
string, OTHER_ALLOC<
std::
string > >& new_row);
1013 virtual
void insertRow(
Row< T_DATA >&& new_row,
1023 virtual
void insertRow(const
Row< T_DATA >& new_row,
1028 !
std::is_same< T_DATA,
DBCell >::value >::insertRows;
1043 virtual
void insertRows(
Matrix< T_DATA >&& new_rows,
1059 virtual
void insertRows(const
Matrix< T_DATA >& new_rows,
1066 void eraseRow(
std::
size_t index);
1071 void eraseFirstRow();
1076 void eraseLastRow();
1081 void eraseFirstRows(const
std::
size_t k);
1086 void eraseLastRows(const
std::
size_t k);
1090 void eraseRows(
std::
size_t deb,
std::
size_t end);
1093 void eraseAllRows();
1096 virtual
void clear();
1099 ALLOC< T_DATA > getAllocator() const;
1102 const
DBVector<
std::
string >& missingSymbols() const;
1105 bool hasMissingValues() const;
1108 bool hasMissingValues(const
std::
size_t k) const;
1114 void setMaxNbThreads(const
std::
size_t nb) const;
1117 std::
size_t nbThreads() const;
1128 void setMinNbRowsPerThread(const
std::
size_t nb) const;
1131 std::
size_t minNbRowsPerThread() const;
1134 void setAllRowsWeight(const
double new_weight);
1139 void setWeight(const
std::
size_t i, const
double weight);
1144 double weight(const
std::
size_t i) const;
1147 double weight() const;
1166 mutable
std::
size_t _max_nb_threads{
1171 mutable std::size_t _min_nb_rows_per_thread{100};
1176 bool _isRowSizeOK(
const std::size_t size)
const;
1187 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1195 mutable std::mutex __safe_handlers_mutex;
1198 Handler* __end{
nullptr};
1204 void __attachHandler(HandlerSafe* handler)
const;
1207 void __detachHandler(HandlerSafe* handler)
const;
1210 void __updateHandlers(std::size_t new_size)
const;
1213 void __createEndIterators();
1219 friend class Handler;
1220 friend class HandlerSafe;
The common class for the tabular database tables.
std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > > Matrix
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
the type for the vectors used in the IDatabaseTable
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > > Matrix
The class representing the original values of the cells of databases.
std::ptrdiff_t difference_type
Types for STL compliance.
the (unsafe) handler for the tabular databases
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > > Matrix
unsigned int getMaxNumberOfThreads()
Returns the maximum number of threads at any time.
std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > > Matrix
the type for the matrices stored into the database
std::vector< std::string, XALLOC< std::string > > MissingValType
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
the type for the allocated vectors in IDatabases
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const Handler const_iterator
std::ptrdiff_t difference_type
const HandlerSafe const_iterator_safe
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The base class for all database handlers.
std::random_access_iterator_tag iterator_category
Types for STL compliance.
the safe handler of the tabular databases
The class for storing a record in a database.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
typename DBHandler< T_DATA, ALLOC >::value_type value_type
Types for STL compliance.
ALLOC< DBCell > allocator_type
ALLOC< void > allocator_type
Types for STL compliance.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HandlerSafe iterator_safe