Commit 76e0e4a1 authored by Christophe Gonzales's avatar Christophe Gonzales

fixed MacOS virtual function hidden in IDatabaseTable

parent d6f089d5
Pipeline #20201223 failed with stages
in 9 minutes and 7 seconds
......@@ -44,13 +44,16 @@ namespace gum {
genericBNLearner::Database::Database(const DatabaseTable<>& db)
: __database(db)
, __modalities ( db.domainSizes () ) {
: __database(db) {
// get the variables names
const auto& var_names = __database.variableNames ();
const std::size_t nb_vars = var_names.size ();
for ( std::size_t i = 0; i < nb_vars; ++i )
__modalities.resize ( nb_vars );
const auto domainSizes = __database.domainSizes ();
for ( std::size_t i = 0; i < nb_vars; ++i ) {
__name2nodeId.insert ( var_names[i], i );
__modalities[i] = domainSizes[i];
}
// create the parser
__parser = new DBRowGeneratorParser<> ( __database.handler (),
......
......@@ -52,11 +52,16 @@ namespace gum {
template<template<typename> class ALLOC>
struct IDatabaseTableInsert4DBCell<ALLOC,true> {
template <typename T_DATA>
using Row = DBRow<T_DATA,ALLOC>;
template <typename TX_DATA>
using DBVector = std::vector<TX_DATA,ALLOC<TX_DATA>>;
template <typename TX_DATA>
using Row = DBRow<TX_DATA,ALLOC>;
template <typename TX_DATA>
using Matrix = std::vector<DBRow<TX_DATA,ALLOC>,
ALLOC<DBRow<TX_DATA,ALLOC>>>;
template <typename T_DATA>
using Matrix = std::vector<Row<T_DATA>,ALLOC<Row<T_DATA>>>;
/// insert a new DBRow at the end of the database
/** The new row passed in argument is supposed to come from an external
......@@ -81,18 +86,39 @@ namespace gum {
/// insert a new row at the end of the database
/** The new row passed in argument is supposed to come from an external
* database. So it must contain data for the ignored columns. */
virtual void insertRow (
const std::vector<std::string,ALLOC<std::string>>& new_row ) = 0;
virtual void insertRow ( const DBVector<std::string>& new_row ) = 0;
/// insert new rows at the end of the database
/** The new rows passed in argument are supposed to come from an external
* database. So they must contain data for the ignored columns. */
virtual void insertRows (
const DBVector<DBVector<std::string>>& new_row );
};
template<template<typename> class ALLOC>
struct IDatabaseTableInsert4DBCell<ALLOC,false> {
template <typename TX_DATA>
using DBVector = std::vector<TX_DATA,ALLOC<TX_DATA>>;
template <typename TX_DATA>
using Row = DBRow<TX_DATA,ALLOC>;
template <typename TX_DATA>
using Matrix = std::vector<DBRow<TX_DATA,ALLOC>,
ALLOC<DBRow<TX_DATA,ALLOC>>>;
/// insert a new row at the end of the database
/** The new row passed in argument is supposed to come from an external
* database. So it must contain data for the ignored columns. */
virtual void insertRow (
const std::vector<std::string,ALLOC<std::string>>& new_row ) = 0;
/// insert new rows at the end of the database
/** The new rows passed in argument are supposed to come from an external
* database. So they must contain data for the ignored columns. */
virtual void insertRows (
const DBVector<DBVector<std::string>>& new_row );
};
......@@ -242,7 +268,8 @@ namespace gum {
/// the type for the matrices stored into the database
template<typename TX_DATA>
using Matrix = DBVector<Row<TX_DATA>>;
using Matrix = std::vector<DBRow<TX_DATA,ALLOC>,
ALLOC<DBRow<TX_DATA,ALLOC>>>;
template <template<typename> class XALLOC>
using MissingValType = std::vector<std::string,XALLOC<std::string>>;
......@@ -362,7 +389,8 @@ namespace gum {
using Row = DBRow<TX_DATA,ALLOC>;
template<typename TX_DATA>
using Matrix = DBVector<Row<TX_DATA>>;
using Matrix = std::vector<DBRow<TX_DATA,ALLOC>,
ALLOC<DBRow<TX_DATA,ALLOC>>>;
// ########################################################################
......@@ -979,6 +1007,9 @@ namespace gum {
* the number of columns retained in the IDatabaseTable */
virtual void insertRow( const Row<T_DATA>& new_row );
using IDatabaseTableInsert4DBCell<ALLOC,
!std::is_same<T_DATA,DBCell>::value>::insertRows;
/// insert a set of new DBRows at the end of the database
/** Unlike methods insertRows for data whose type is different from T_DATA,
* this method assumes that the new rows passed in argument do not contain
......
......@@ -1123,6 +1123,25 @@ namespace gum {
return __missing_symbols;
}
/// insert new rows at the end of the database
template <template<typename> class ALLOC>
void IDatabaseTableInsert4DBCell<ALLOC,true>::insertRows (
const typename IDatabaseTableInsert4DBCell<ALLOC,true>::template
DBVector<DBVector<std::string>>& new_rows ) {
for ( const auto& new_row : new_rows )
this->insertRow ( new_row );
}
/// insert new rows at the end of the database
template <template<typename> class ALLOC>
void IDatabaseTableInsert4DBCell<ALLOC,false>::insertRows (
const typename IDatabaseTableInsert4DBCell<ALLOC,false>::template
DBVector<DBVector<std::string>>& new_rows ) {
for ( const auto& new_row : new_rows )
this->insertRow ( new_row );
}
} /* namespace learning */
......
......@@ -186,7 +186,8 @@ namespace gum {
/// the type for the matrices stored into the database
template<typename TX_DATA>
using Matrix = DBVector<Row<TX_DATA>>;
using Matrix = std::vector<DBRow<TX_DATA,ALLOC>,
ALLOC<DBRow<TX_DATA,ALLOC>>>;
template <template<typename> class XALLOC>
using MissingValType = std::vector<std::string,XALLOC<std::string>>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment