SG++
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 total amount of samples available in the file. More...
 
FileSampleDecoratoroperator= (const FileSampleDecorator &rhs)
 
FileSampleDecoratoroperator= (FileSampleDecorator &&rhs)=default
 
void readFile (const std::string &fileName) override
 Read the contents of the file at the given path. More...
 
void readString (const std::string &input) override
 Read the contents of a string, for example a deflated archive. 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
 
 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

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.

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

References fileSampleProvider.

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

Member Function Documentation

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.

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.

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.

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

Returns the total amount of samples available in the file.

Only works after calling readFile or readString.

Returns
the total amount of samples available in the file.

Implements sgpp::datadriven::FileSampleProvider.

References fileSampleProvider.

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

References fileSampleProvider.

FileSampleDecorator& sgpp::datadriven::FileSampleDecorator::operator= ( FileSampleDecorator &&  rhs)
default
void sgpp::datadriven::FileSampleDecorator::readFile ( const std::string &  filePath)
overridevirtual

Read the contents of the file at the given path.

Has to throw an exception if file can not be opened or parsed. Results of parsing can be optained via sgpp::datadriven::SampleProvider member functions.

Parameters
filePathvalid path to an existing file.

Implements sgpp::datadriven::FileSampleProvider.

References fileSampleProvider.

void sgpp::datadriven::FileSampleDecorator::readString ( const std::string &  input)
overridevirtual

Read the contents of a string, for example a deflated archive.

Has to throw an exception if string can not be parsed. Results of parsing can be optained via sgpp::datadriven::SampleProvider member functions.

Implements sgpp::datadriven::FileSampleProvider.

References fileSampleProvider.

Member Data Documentation

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: