aGrUM  0.13.2
gum::learning::DBRowGeneratorIdentity< ALLOC > Class Template Reference

A DBRowGenerator class that returns exactly the rows it gets in input. More...

#include <agrum/learning/database/DBRowGeneratorIdentity.h>

+ Inheritance diagram for gum::learning::DBRowGeneratorIdentity< ALLOC >:
+ Collaboration diagram for gum::learning::DBRowGeneratorIdentity< ALLOC >:

Public Member Functions

Constructors / Destructors
 DBRowGeneratorIdentity (const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > column_types, const allocator_type &alloc=allocator_type())
 default constructor More...
 
 DBRowGeneratorIdentity (const DBRowGeneratorIdentity< ALLOC > &from)
 copy constructor More...
 
 DBRowGeneratorIdentity (const DBRowGeneratorIdentity< ALLOC > &from, const allocator_type &alloc)
 copy constructor with a given allocator More...
 
 DBRowGeneratorIdentity (DBRowGeneratorIdentity< ALLOC > &&from)
 move constructor More...
 
 DBRowGeneratorIdentity (DBRowGeneratorIdentity< ALLOC > &&from, const allocator_type &alloc)
 move constructor with a given allocator More...
 
virtual DBRowGeneratorIdentity< ALLOC > * clone () const
 virtual copy constructor More...
 
virtual DBRowGeneratorIdentity< ALLOC > * clone (const allocator_type &alloc) const
 virtual copy constructor with a given allocator More...
 
 ~DBRowGeneratorIdentity ()
 destructor More...
 
Operators
DBRowGeneratorIdentity< ALLOC > & operator= (const DBRowGeneratorIdentity< ALLOC > &from)
 copy operator More...
 
DBRowGeneratorIdentity< ALLOC > & operator= (DBRowGeneratorIdentity< ALLOC > &&from)
 move operator More...
 
Accessors / Modifiers
virtual const DBRow< DBTranslatedValue, ALLOC > & generate () final
 generates one ouput DBRow for each DBRow passed to method setInputRow More...
 
Accessors / Modifiers
bool hasRows ()
 returns true if there are still rows that can be output by the DBRowGenerator More...
 
bool setInputRow (const DBRow< DBTranslatedValue, ALLOC > &row)
 sets the input row from which the generator will create its output rows More...
 
void decreaseRemainingRows ()
 decrease the number of remaining output rows More...
 
virtual void reset ()
 resets the generator. There are therefore no more ouput row to generate More...
 
virtual void setColumnsOfInterest (const std::vector< std::size_t, ALLOC< std::size_t > > &cols_of_interest)
 sets the columns of interest: the output DBRow needs only contain correct values fot these columns More...
 
virtual void setColumnsOfInterest (std::vector< std::size_t, ALLOC< std::size_t > > &&cols_of_interest)
 sets the columns of interest: the output DBRow needs only contain correct values fot these columns More...
 
const std::vector< std::size_t, ALLOC< std::size_t > > & columnsOfInterest () const
 returns the current set of columns of interest More...
 
allocator_type getAllocator () const
 returns the allocator used More...
 
DBRowGeneratorGoal goal () const
 returns the goal of the DBRowGenerator More...
 

Public Types

using allocator_type = ALLOC< DBTranslatedValue >
 type for the allocators passed in arguments of methods More...
 

Protected Attributes

std::size_t _nb_remaining_output_rows {std::size_t(0)}
 the number of output rows still to retrieve through the generate method More...
 
std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > _column_types
 the types of the columns in the DatabaseTable More...
 
std::vector< std::size_t, ALLOC< std::size_t > > _columns_of_interest
 the set of columns of interest More...
 
DBRowGeneratorGoal _goal
 the goal of the DBRowGenerator (just remove missing values or not) More...
 

Protected Member Functions

virtual std::size_t _computeRows (const DBRow< DBTranslatedValue, ALLOC > &row) final
 computes the rows it will provide as output More...
 

Detailed Description

template<template< typename > class ALLOC = std::allocator>
class gum::learning::DBRowGeneratorIdentity< ALLOC >

A DBRowGenerator class that returns exactly the rows it gets in input.

This class is a dummy DBRowGenerator that can be essentially used for debugging purposes. The DBRowGeneratorIdentity class is designed to take as input DBRow instances via its method setInputRow and to ouput them without any additional processing via its method generate. See class DBRowGenerator for further details on how DBRowGenerator works.

The standard usage of a DBRowGenerator is the following:

// create a DatabaseTable and fill it
for ( int i = 0; i < 10; ++i )
// fill the database
// keep in a vector the types of the columns in the database
const std::vector<gum::learning::DBTranslatedValueType>
// create the generator
// parse the database and produce output rows
for ( auto dbrow : database ) {
generator.setInputRow ( dbrow );
const auto& output_dbrow = generator.generate ();
// do something with the output dbrow
}

Definition at line 73 of file DBRowGeneratorIdentity.h.

Member Typedef Documentation

template<template< typename > class ALLOC = std::allocator>
using gum::learning::DBRowGeneratorIdentity< ALLOC >::allocator_type = ALLOC< DBTranslatedValue >

type for the allocators passed in arguments of methods

Definition at line 76 of file DBRowGeneratorIdentity.h.

Constructor & Destructor Documentation

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::DBRowGeneratorIdentity ( const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >  column_types,
const allocator_type alloc = allocator_type() 
)

default constructor

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::DBRowGeneratorIdentity ( const DBRowGeneratorIdentity< ALLOC > &  from)

copy constructor

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::DBRowGeneratorIdentity ( const DBRowGeneratorIdentity< ALLOC > &  from,
const allocator_type alloc 
)

copy constructor with a given allocator

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::DBRowGeneratorIdentity ( DBRowGeneratorIdentity< ALLOC > &&  from)

move constructor

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::DBRowGeneratorIdentity ( DBRowGeneratorIdentity< ALLOC > &&  from,
const allocator_type alloc 
)

move constructor with a given allocator

template<template< typename > class ALLOC = std::allocator>
gum::learning::DBRowGeneratorIdentity< ALLOC >::~DBRowGeneratorIdentity ( )

destructor

Member Function Documentation

template<template< typename > class ALLOC = std::allocator>
virtual std::size_t gum::learning::DBRowGeneratorIdentity< ALLOC >::_computeRows ( const DBRow< DBTranslatedValue, ALLOC > &  row)
finalprotectedvirtual

computes the rows it will provide as output

Implements gum::learning::DBRowGenerator< ALLOC >.

template<template< typename > class ALLOC = std::allocator>
virtual DBRowGeneratorIdentity< ALLOC >* gum::learning::DBRowGeneratorIdentity< ALLOC >::clone ( ) const
virtual

virtual copy constructor

Implements gum::learning::DBRowGenerator< ALLOC >.

template<template< typename > class ALLOC = std::allocator>
virtual DBRowGeneratorIdentity< ALLOC >* gum::learning::DBRowGeneratorIdentity< ALLOC >::clone ( const allocator_type alloc) const
virtual

virtual copy constructor with a given allocator

Implements gum::learning::DBRowGenerator< ALLOC >.

template<template< typename > class ALLOC = std::allocator>
const std::vector< std::size_t, ALLOC< std::size_t > >& gum::learning::DBRowGenerator< ALLOC >::columnsOfInterest ( ) const
inherited

returns the current set of columns of interest

template<template< typename > class ALLOC = std::allocator>
void gum::learning::DBRowGenerator< ALLOC >::decreaseRemainingRows ( )
inherited

decrease the number of remaining output rows

When method setInputRow is performed, the DBRowGenerator knows how many output rows it will be able to generate. Each time method decreaseRemainingRows is called, we decrement this number. When the number becomes equal to 0, then there remains no new output row to generate.

template<template< typename > class ALLOC = std::allocator>
virtual const DBRow< DBTranslatedValue, ALLOC >& gum::learning::DBRowGeneratorIdentity< ALLOC >::generate ( )
finalvirtual

generates one ouput DBRow for each DBRow passed to method setInputRow

Implements gum::learning::DBRowGenerator< ALLOC >.

template<template< typename > class ALLOC = std::allocator>
allocator_type gum::learning::DBRowGenerator< ALLOC >::getAllocator ( ) const
inherited

returns the allocator used

template<template< typename > class ALLOC = std::allocator>
DBRowGeneratorGoal gum::learning::DBRowGenerator< ALLOC >::goal ( ) const
inherited

returns the goal of the DBRowGenerator

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::DBRowGenerator< ALLOC >::hasRows ( )
inherited

returns true if there are still rows that can be output by the DBRowGenerator

template<template< typename > class ALLOC = std::allocator>
DBRowGeneratorIdentity< ALLOC >& gum::learning::DBRowGeneratorIdentity< ALLOC >::operator= ( const DBRowGeneratorIdentity< ALLOC > &  from)

copy operator

template<template< typename > class ALLOC = std::allocator>
DBRowGeneratorIdentity< ALLOC >& gum::learning::DBRowGeneratorIdentity< ALLOC >::operator= ( DBRowGeneratorIdentity< ALLOC > &&  from)

move operator

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::DBRowGenerator< ALLOC >::reset ( )
virtualinherited

resets the generator. There are therefore no more ouput row to generate

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::DBRowGenerator< ALLOC >::setColumnsOfInterest ( const std::vector< std::size_t, ALLOC< std::size_t > > &  cols_of_interest)
virtualinherited

sets the columns of interest: the output DBRow needs only contain correct values fot these columns

This method is useful, e.g., for EM-like algorithms that need to know which unobserved variables/values need be filled. In this case, the DBRowGenerator still outputs DBRows with the same columns as the DatabaseTable, but only the columns of these DBRows corresponding to those passed in argument to Method setColumnsOfInterest are meaningful. For instance, if a DatabaseTable contains 10 columns and Method setColumnsOfInterest() is applied with vector<> { 0, 3, 4 }, then the DBRowGenerator will output DBRows with 10 columns, in which only columns 0, 3 and 4 are guaranteed to have correct values (columns are always indexed, starting from 0).

template<template< typename > class ALLOC = std::allocator>
virtual void gum::learning::DBRowGenerator< ALLOC >::setColumnsOfInterest ( std::vector< std::size_t, ALLOC< std::size_t > > &&  cols_of_interest)
virtualinherited

sets the columns of interest: the output DBRow needs only contain correct values fot these columns

This method is useful, e.g., for EM-like algorithms that need to know which unobserved variables/values need be filled. In this case, the DBRowGenerator still outputs DBRows with the same columns as the DatabaseTable, but only the columns of these DBRows corresponding to those passed in argument to Method setColumnsOfInterest are meaningful. For instance, if a DatabaseTable contains 10 columns and Method setColumnsOfInterest() is applied with vector<> { 0, 3, 4 }, then the DBRowGenerator will output DBRows with 10 columns, in which only columns 0, 3 and 4 are guaranteed to have correct values (columns are always indexed, starting from 0).

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::DBRowGenerator< ALLOC >::setInputRow ( const DBRow< DBTranslatedValue, ALLOC > &  row)
inherited

sets the input row from which the generator will create its output rows

Returns
a Boolean indicating whether, from this input DBRow, the DBRowGenerator is capable of outputing at least one row or not

Member Data Documentation

template<template< typename > class ALLOC = std::allocator>
std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > gum::learning::DBRowGenerator< ALLOC >::_column_types
protectedinherited

the types of the columns in the DatabaseTable

This is useful to determine whether we need to use the .discr_val field or the .cont_val field in DBTranslatedValue instances.

Definition at line 363 of file DBRowGenerator.h.

template<template< typename > class ALLOC = std::allocator>
std::vector< std::size_t, ALLOC< std::size_t > > gum::learning::DBRowGenerator< ALLOC >::_columns_of_interest
protectedinherited

the set of columns of interest

Definition at line 366 of file DBRowGenerator.h.

template<template< typename > class ALLOC = std::allocator>
DBRowGeneratorGoal gum::learning::DBRowGenerator< ALLOC >::_goal
protectedinherited
Initial value:

the goal of the DBRowGenerator (just remove missing values or not)

Definition at line 369 of file DBRowGenerator.h.

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::DBRowGenerator< ALLOC >::_nb_remaining_output_rows {std::size_t(0)}
protectedinherited

the number of output rows still to retrieve through the generate method

Definition at line 357 of file DBRowGenerator.h.


The documentation for this class was generated from the following file: