SG++-Doxygen-Documentation
sgpp::datadriven::FileSampleDecorator Class Reference

FileSampleDecorator provides an interface to provide generic manipulations for various kinds of sgpp::datadriven::FileSampleProvider using the decorator pattern. More...

#include <FileSampleDecorator.hpp>

Inheritance diagram for sgpp::datadriven::FileSampleDecorator:
sgpp::datadriven::FileSampleProvider sgpp::datadriven::SampleProvider

Public Member Functions

 FileSampleDecorator (FileSampleProvider *const fileSampleProvider)
 Constructor. More...
 
 FileSampleDecorator (const FileSampleDecorator &rhs)
 
 FileSampleDecorator (FileSampleDecorator &&rhs)=default
 
DatasetgetAllSamples () override
 Asks to return all available samples. More...
 
size_t getDim () const override
 Returns the maximal dimensionality of the data. More...
 
DatasetgetNextSamples (size_t howMany) override
 Lets the user request a certain amount of samples. More...
 
size_t getNumSamples () const override
 Returns the number of samples availible or throws if not possible. More...
 
FileSampleDecoratoroperator= (const FileSampleDecorator &rhs)
 
FileSampleDecoratoroperator= (FileSampleDecorator &&rhs)=default
 
void readFile (const std::string &fileName, bool hasTargets, size_t readinCutoff=-1, std::vector< size_t > readinColumns=std::vector< size_t >(), std::vector< double > readinClasses=std::vector< double >()) override
 Reads a file's content from a file. More...
 
void readString (const std::string &input, bool hasTargets, size_t readinCutoff=-1, std::vector< size_t > readinColumns=std::vector< size_t >(), std::vector< double > readinClasses=std::vector< double >()) override
 Reads a file's content. More...
 
 ~FileSampleDecorator ()=default
 
- Public Member Functions inherited from sgpp::datadriven::SampleProvider
virtual SampleProviderclone () const =0
 Clone pattern for polymorphic cloning (mainly interresting for copy constructors). More...
 
SampleProvideroperator= (const SampleProvider &rhs)=default
 
SampleProvideroperator= (SampleProvider &&rhs)=default
 
virtual void reset ()=0
 Resets the state of the sample provider (e.g. More...
 
 SampleProvider ()=default
 
 SampleProvider (const SampleProvider &rhs)=default
 
 SampleProvider (SampleProvider &&rhs)=default
 
virtual ~SampleProvider ()=default
 

Protected Attributes

std::unique_ptr< FileSampleProviderfileSampleProvider
 Delegate sgpp::datadriven::FileSampleProvider object. More...
 

Detailed Description

FileSampleDecorator provides an interface to provide generic manipulations for various kinds of sgpp::datadriven::FileSampleProvider using the decorator pattern.

Using inheritance and deligation we can manipulate input or output of sgpp::datadriven::FileSampleProvider member functions in a generic fashion e.g. apply decompression of compressed files before passing them to the actual sgpp::datadriven::FileSampleProvider without limiting ourselves to a specific implementation. Instead we use the decorated object's member functions as a black box.

Constructor & Destructor Documentation

◆ FileSampleDecorator() [1/3]

sgpp::datadriven::FileSampleDecorator::FileSampleDecorator ( FileSampleProvider *const  fileSampleProvider)
explicit

Constructor.

Parameters
fileSampleProviderPointer to a sgpp::datadriven::FileSampleProvider that will be wrapped as a deligate. The decorator will take ownership of this object and take care of its destruction.

References fileSampleProvider.

◆ FileSampleDecorator() [2/3]

sgpp::datadriven::FileSampleDecorator::FileSampleDecorator ( const FileSampleDecorator rhs)

References fileSampleProvider.

◆ FileSampleDecorator() [3/3]

sgpp::datadriven::FileSampleDecorator::FileSampleDecorator ( FileSampleDecorator &&  rhs)
default

◆ ~FileSampleDecorator()

sgpp::datadriven::FileSampleDecorator::~FileSampleDecorator ( )
default

Member Function Documentation

◆ getAllSamples()

Dataset * sgpp::datadriven::FileSampleDecorator::getAllSamples ( )
overridevirtual

Asks to return all available samples.

This functionality is designed for returning all available samples from an entire file.

Returns
sgpp::datadriven::Dataset* Pointer to a new sgpp::datadriven::Dataset object. This object is owned by the caller.

Implements sgpp::datadriven::SampleProvider.

References fileSampleProvider.

◆ getDim()

size_t sgpp::datadriven::FileSampleDecorator::getDim ( ) const
overridevirtual

Returns the maximal dimensionality of the data.

Returns
dimensionality of the sgpp::datadriven::Dataset.

Implements sgpp::datadriven::SampleProvider.

References fileSampleProvider.

Referenced by python.uq.dists.SGDEdist.SGDEdist::__str__(), and python.uq.dists.KDEDist.KDEDist::getBandwidths().

◆ getNextSamples()

Dataset * sgpp::datadriven::FileSampleDecorator::getNextSamples ( size_t  howMany)
overridevirtual

Lets the user request a certain amount of samples.

This functionality is is designed for streaming algorithms where data is processed in batches.

Parameters
howManynumber requested amount of samples. The amount of actually provided samples can be smaller, if there is not sufficient data.
Returns
sgpp::datadriven::Dataset* Pointer to a new sgpp::datadriven::Dataset object containing at most the requested amount of samples. This object is owned by the caller.

Implements sgpp::datadriven::SampleProvider.

References fileSampleProvider.

◆ getNumSamples()

size_t sgpp::datadriven::FileSampleDecorator::getNumSamples ( ) const
overridevirtual

Returns the number of samples availible or throws if not possible.

Returns
the number of samples availible

Implements sgpp::datadriven::SampleProvider.

References fileSampleProvider.

◆ operator=() [1/2]

FileSampleDecorator & sgpp::datadriven::FileSampleDecorator::operator= ( const FileSampleDecorator rhs)

References fileSampleProvider.

◆ operator=() [2/2]

FileSampleDecorator& sgpp::datadriven::FileSampleDecorator::operator= ( FileSampleDecorator &&  rhs)
default

◆ readFile()

void sgpp::datadriven::FileSampleDecorator::readFile ( const std::string &  fileName,
bool  hasTargets,
size_t  readinCutoff = -1,
std::vector< size_t >  readinColumns = std::vector<size_t>(),
std::vector< double >  readinClasses = std::vector<double>() 
)
overridevirtual

Reads a file's content from a file.

Parameters
fileNamepath to the file
hasTargetswhether the file has targets (i.e. supervised learning)
readinCutoffsee FileSampleProvider.hpp
readinColumnssee FileSampleProvider.hpp
readinClassessee FileSampleProvider.hpp

Implements sgpp::datadriven::FileSampleProvider.

References fileSampleProvider.

◆ readString()

void sgpp::datadriven::FileSampleDecorator::readString ( const std::string &  input,
bool  hasTargets,
size_t  readinCutoff = -1,
std::vector< size_t >  readinColumns = std::vector<size_t>(),
std::vector< double >  readinClasses = std::vector<double>() 
)
overridevirtual

Reads a file's content.

Parameters
inputthe file's content
hasTargetswhether the file has targets (i.e. supervised learning)
readinCutoffsee FileSampleProvider.hpp
readinColumnssee FileSampleProvider.hpp
readinClassessee FileSampleProvider.hpp

Implements sgpp::datadriven::FileSampleProvider.

References fileSampleProvider.

Member Data Documentation

◆ fileSampleProvider

std::unique_ptr<FileSampleProvider> sgpp::datadriven::FileSampleDecorator::fileSampleProvider
protected

Delegate sgpp::datadriven::FileSampleProvider object.

Calls to the object will be wrapped by the decorator performing pre-processing or post-processing to member functions which will be used by the decorator as a black box, passing through calls which are not overridden.

Referenced by FileSampleDecorator(), getAllSamples(), getDim(), getNextSamples(), getNumSamples(), operator=(), readFile(), and readString().


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