Commit 736a3ee7 authored by Christophe Gonzales's avatar Christophe Gonzales

added types to DBRowGenerators to discriminate those that are only intended to…

added types to DBRowGenerators to discriminate those that are only intended to remove missing values
parent b8594ff3
......@@ -35,6 +35,22 @@ namespace gum {
namespace learning {
/** @enum DBRowGeneratorGoal
* @headerfile DBRowGenerator.h <agrum/learning/database/DBRowGenerator.h>
* @brief the type of things that a DBRowGenerator is designed for
*
* @ingroup learning_database
*/
enum class DBRowGeneratorGoal : char {
// the generator's goal is only to remove all missing values
ONLY_REMOVE_MISSING_VALUES,
// the generator does something else than just missing values
OTHER_THINGS_THAN_REMOVE_MISSING_VALUES
};
/** @class DBRowGenerator
* @headerfile DBRowGenerator.h <agrum/learning/database/DBRowGenerator.h>
* @ingroup learning_database
......@@ -232,6 +248,7 @@ namespace gum {
* @param alloc the allocator used by all the methods */
DBRowGenerator( const std::vector<DBTranslatedValueType,
ALLOC<DBTranslatedValueType>> column_types,
const DBRowGeneratorGoal goal,
const allocator_type& alloc = allocator_type () );
/// copy constructor
......@@ -331,6 +348,9 @@ namespace gum {
/// returns the allocator used
allocator_type getAllocator () const;
/// returns the goal of the DBRowGenerator
DBRowGeneratorGoal goal () const;
/// @}
......@@ -347,6 +367,10 @@ namespace gum {
/// the set of columns of interest
std::vector<std::size_t,ALLOC<std::size_t>> _columns_of_interest;
/// the goal of the DBRowGenerator (just remove missing values or not)
DBRowGeneratorGoal
_goal { DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES };
/// copy constructor
......
......@@ -37,7 +37,9 @@ namespace gum {
const std::vector<DBTranslatedValueType,
ALLOC<DBTranslatedValueType>> column_types,
const typename DBRowGeneratorIdentity<ALLOC>::allocator_type& alloc )
: DBRowGenerator<ALLOC> ( column_types, alloc ) {
: DBRowGenerator<ALLOC>
( column_types,
DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES, alloc ) {
GUM_CONSTRUCTOR( DBRowGeneratorIdentity );
}
......
......@@ -35,9 +35,11 @@ namespace gum {
DBRowGenerator<ALLOC>::DBRowGenerator(
const std::vector<DBTranslatedValueType,ALLOC<DBTranslatedValueType>>
column_types,
const DBRowGeneratorGoal goal,
const allocator_type& alloc )
: _column_types ( column_types, alloc )
, _columns_of_interest ( alloc ) {
, _columns_of_interest ( alloc )
, _goal ( goal ) {
GUM_CONSTRUCTOR( DBRowGenerator );
}
......@@ -49,7 +51,8 @@ namespace gum {
const typename DBRowGenerator<ALLOC>::allocator_type& alloc )
: _nb_remaining_output_rows ( from._nb_remaining_output_rows )
, _column_types ( from._column_types, alloc )
, _columns_of_interest ( from._columns_of_interest, alloc ) {
, _columns_of_interest ( from._columns_of_interest, alloc )
, _goal ( from._goal ) {
GUM_CONS_CPY( DBRowGenerator );
}
......@@ -68,7 +71,8 @@ namespace gum {
const typename DBRowGenerator<ALLOC>::allocator_type& alloc )
: _nb_remaining_output_rows ( from._nb_remaining_output_rows )
, _column_types ( std::move ( from._column_types ), alloc )
, _columns_of_interest ( std::move ( from._columns_of_interest ), alloc ) {
, _columns_of_interest ( std::move ( from._columns_of_interest ), alloc )
, _goal ( from._goal ) {
GUM_CONS_MOV( DBRowGenerator );
}
......@@ -94,6 +98,7 @@ namespace gum {
_nb_remaining_output_rows = from._nb_remaining_output_rows;
_column_types = from._column_types;
_columns_of_interest = from._columns_of_interest;
_goal = from._goal;
return *this;
}
......@@ -105,6 +110,7 @@ namespace gum {
_nb_remaining_output_rows = from._nb_remaining_output_rows;
_column_types = std::move ( from._column_types );
_columns_of_interest = std::move ( from._columns_of_interest );
_goal = from._goal;
return *this;
}
......@@ -169,6 +175,13 @@ namespace gum {
DBRowGenerator<ALLOC>::getAllocator () const {
return _columns_of_interest.get_allocator ();
}
/// returns the goal of the DBRowGenerator
template <template<typename> class ALLOC>
INLINE DBRowGeneratorGoal DBRowGenerator<ALLOC>::goal () const {
return _goal;
}
} /* namespace learning */
......
......@@ -49,7 +49,7 @@ namespace gum {
ALLOC<DBTranslatedValueType>> column_types,
const std::size_t nb_duplicates,
const allocator_type& alloc = allocator_type () )
: DBRowGenerator<ALLOC> ( column_types, alloc )
: DBRowGenerator<ALLOC> ( column_types, DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES, alloc )
, __nb_duplicates ( nb_duplicates ) {
GUM_CONSTRUCTOR( MyGenerator );
}
......
......@@ -50,7 +50,7 @@ namespace gum {
ALLOC<DBTranslatedValueType>> column_types,
const std::size_t nb_duplicates,
const allocator_type& alloc = allocator_type () )
: DBRowGenerator<ALLOC> ( column_types, alloc )
: DBRowGenerator<ALLOC> ( column_types, DBRowGeneratorGoal::OTHER_THINGS_THAN_REMOVE_MISSING_VALUES, alloc )
, __nb_duplicates ( nb_duplicates ) {
GUM_CONSTRUCTOR( MyGenerator2 );
}
......
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