28 #ifndef GUM_IDATABASE_TABLE_H 29 #define GUM_IDATABASE_TABLE_H 52 template <
template <
typename >
class ALLOC,
bool ENABLE_INSERT >
55 template <
template <
typename >
class ALLOC >
57 template <
typename TX_DATA >
58 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
60 template <
typename TX_DATA >
63 template <
typename TX_DATA >
65 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
91 virtual void insertRow(
92 const std::vector< std::string, ALLOC< std::string > >& new_row) = 0;
101 template <
template <
typename >
class ALLOC >
103 template <
typename TX_DATA >
104 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
106 template <
typename TX_DATA >
109 template <
typename TX_DATA >
111 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
116 virtual void insertRow(
117 const std::vector< std::string, ALLOC< std::string > >& new_row) = 0;
252 template <
typename T_DATA,
253 template <
typename >
class ALLOC = std::allocator >
257 !std::is_same< T_DATA, DBCell >::value >
258 ,
private ALLOC< T_DATA > {
261 template <
typename TX_DATA >
262 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
265 template <
typename TX_DATA >
269 template <
typename TX_DATA >
271 std::vector< DBRow< TX_DATA, ALLOC >, ALLOC< DBRow< TX_DATA, ALLOC > > >;
273 template <
template <
typename >
class XALLOC >
386 template <
typename TX_DATA >
387 using DBVector = std::vector< TX_DATA, ALLOC< TX_DATA > >;
389 template <
typename TX_DATA >
392 template <
typename TX_DATA >
393 using Matrix = std::vector< DBRow< TX_DATA, ALLOC >,
394 ALLOC< DBRow< TX_DATA, ALLOC > > >;
434 virtual Handler& operator++() final;
440 virtual
Handler& operator--() final;
446 virtual
Handler& operator+=(const
std::
size_t i) final;
452 virtual
Handler& operator-=(const
std::
size_t i) final;
455 virtual
bool operator==(const
Handler& handler) const final;
458 virtual
bool operator!=(const
Handler& handler) const final;
490 virtual
std::
size_t size() const final;
493 virtual
std::
size_t DBSize() const final;
518 virtual
void nextRow() final;
521 virtual
std::
size_t numRow() const final;
524 virtual
bool hasRows() const final;
527 virtual
void reset() final;
554 virtual
void setRange(
std::
size_t begin,
std::
size_t end) final;
557 virtual
std::pair<
std::
size_t,
std::
size_t > range() const final;
560 virtual const
DBVector<
std::
string >& variableNames() const final;
563 virtual
std::
size_t nbVariables() const final;
573 #ifndef DOXYGEN_SHOULD_SKIP_THIS 585 std::size_t __index{std::size_t(0)};
588 std::size_t __begin_index{std::size_t(0)};
591 std::size_t __end_index{std::size_t(0)};
745 #ifndef DOXYGEN_SHOULD_SKIP_THIS 749 void __attachHandler();
752 void __detachHandler();
783 template <
template <
typename >
class VARALLOC,
784 template <
typename >
788 const std::vector< std::string, VARALLOC< std::string > >& var_names,
789 const ALLOC< T_DATA >& alloc);
830 const iterator& end() const noexcept;
844 const
Matrix< T_DATA >& content() const noexcept;
854 const
DBVector<
std::
string >& variableNames() const noexcept;
882 virtual
void setVariableNames(
883 const
std::vector<
std::
string, ALLOC<
std::
string > >& names,
884 const
bool from_external_object = true) = 0;
912 template < template < typename > class OTHER_ALLOC >
913 void setVariableNames(
914 const
std::vector<
std::
string, OTHER_ALLOC<
std::
string > >& names,
915 const
bool from_external_object = true);
920 const
std::
string& variableName(const
std::
size_t k) const;
928 std::
size_t columnFromVariableName(const
std::
string& name) const;
935 columnsFromVariableName(const
std::
string& name) const;
938 std::
size_t nbVariables() const noexcept;
941 std::
size_t nbRows() const noexcept;
944 std::
size_t size() const noexcept;
947 bool empty() const noexcept;
979 virtual
void ignoreColumn(const
std::
size_t k,
980 const
bool from_external_object = true) = 0;
983 virtual const
DBVector<
std::
size_t > ignoredColumns() const = 0;
987 virtual const
DBVector<
std::
size_t > inputColumns() const = 0;
991 !
std::is_same< T_DATA,
DBCell >::value >::insertRow;
999 template < template < typename > class OTHER_ALLOC >
1001 const
std::vector<
std::
string, OTHER_ALLOC<
std::
string > >& new_row);
1010 virtual
void insertRow(
Row< T_DATA >&& new_row,
1020 virtual
void insertRow(const
Row< T_DATA >& new_row,
1025 !
std::is_same< T_DATA,
DBCell >::value >::insertRows;
1040 virtual
void insertRows(
Matrix< T_DATA >&& new_rows,
1056 virtual
void insertRows(const
Matrix< T_DATA >& new_rows,
1063 void eraseRow(
std::
size_t index);
1068 void eraseFirstRow();
1073 void eraseLastRow();
1078 void eraseFirstRows(const
std::
size_t k);
1083 void eraseLastRows(const
std::
size_t k);
1087 void eraseRows(
std::
size_t deb,
std::
size_t end);
1090 void eraseAllRows();
1093 virtual
void clear();
1096 ALLOC< T_DATA > getAllocator() const;
1099 const
DBVector<
std::
string >& missingSymbols() const;
1102 bool hasMissingValues() const;
1105 bool hasMissingValues(const
std::
size_t k) const;
1111 void setMaxNbThreads(const
std::
size_t nb) const;
1114 std::
size_t nbThreads() const;
1125 void setMinNbRowsPerThread(const
std::
size_t nb) const;
1128 std::
size_t minNbRowsPerThread() const;
1131 void setAllRowsWeight(const
double new_weight);
1150 mutable
std::
size_t _max_nb_threads{
1155 mutable std::size_t _min_nb_rows_per_thread{100};
1160 bool _isRowSizeOK(
const std::size_t size)
const;
1171 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1179 mutable std::mutex __safe_handlers_mutex;
1182 Handler* __end{
nullptr};
1188 void __attachHandler(HandlerSafe* handler)
const;
1191 void __detachHandler(HandlerSafe* handler)
const;
1194 void __updateHandlers(std::size_t new_size)
const;
1197 void __createEndIterators();
1203 friend class Handler;
1204 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
The base class for all database handlers.
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
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
gum is the global namespace for all aGrUM entities
std::vector< TX_DATA, ALLOC< TX_DATA > > DBVector
the type for the allocated vectors in IDatabases
C++11 threads convenience utilities for agrum.
The class representing a record stored in a tabular database.
const Handler const_iterator
std::ptrdiff_t difference_type
const HandlerSafe const_iterator_safe
The class representing the original values of the cells of databases.
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.
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.
The base class for all the tabular databases' cell translators.
unsigned int getMaxNumberOfThreads()
returns the maximum number of threads possible
The implementation of the common class for tabular databases.
HandlerSafe iterator_safe