Commit bcfa21aa authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[CHANGE] Moved dataHandler member variable for all WLoaderXYZ down to WLoader.

parent f36c59de
......@@ -30,8 +30,9 @@
#include "exceptions/WDHIOFailure.h"
WLoader::WLoader( std::string fileName ) throw( WDHIOFailure )
: m_fileName( fileName )
WLoader::WLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler ) throw( WDHIOFailure )
: m_fileName( fileName ),
m_dataHandler( dataHandler )
{
boost::filesystem::path p( m_fileName );
if( !boost::filesystem::exists( p ) )
......
......@@ -27,7 +27,10 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include "exceptions/WDHIOFailure.h"
#include "WDataHandler.h"
/**
* Base class to all WLoaders which imports data from a given file and generate
......@@ -38,7 +41,11 @@
class WLoader
{
public:
explicit WLoader( std::string fileName ) throw( WDHIOFailure );
/**
* Constructs basic Loader with access to the DataHandler (for inserting
* new stuff) and a file name.
*/
explicit WLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHanlder ) throw( WDHIOFailure );
virtual ~WLoader()
{
......@@ -52,7 +59,15 @@ public:
virtual void operator()() = 0;
protected:
/**
* Name of file to load.
*/
std::string m_fileName;
/**
* Reference to DataHandler
*/
boost::shared_ptr< WDataHandler > m_dataHandler;
private:
};
......
......@@ -37,8 +37,7 @@
#include "../../common/WException.h"
WLoaderBiosig::WLoaderBiosig( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fileName ),
m_dataHandler( dataHandler ),
: WLoader( fileName, dataHandler ),
m_columns( 0 ),
m_rows( 0 )
{
......
......@@ -57,7 +57,6 @@ protected:
private:
void biosigLoader();
void fillSegment( std::vector<std::vector<double> >* segment, biosig_data_type* data );
boost::shared_ptr< WDataHandler > m_dataHandler;
/**
* Header of file
......
......@@ -35,8 +35,7 @@
#include "../../common/WStringUtils.hpp"
WLoaderEEGASCII::WLoaderEEGASCII( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fileName ),
m_dataHandler( dataHandler )
: WLoader( fileName, dataHandler )
{
}
......
......@@ -52,7 +52,6 @@ public:
protected:
private:
boost::shared_ptr< WDataHandler > m_dataHandler;
};
#endif // WLOADEREEGASCII_H
......@@ -39,8 +39,7 @@
WLoaderNIfTI::WLoaderNIfTI( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fileName ),
m_dataHandler( dataHandler )
: WLoader( fileName, dataHandler )
{
}
......
......@@ -56,10 +56,10 @@ public:
protected:
private:
template < typename T > std::vector< T > copyArray( const T* dataArray, const size_t nbValues,
const size_t vDim );
boost::shared_ptr< WDataHandler > m_dataHandler;
/**
* TODO(wiebel): Document this: Alex, why do we need this Function?
*/
template < typename T > std::vector< T > copyArray( const T* dataArray, const size_t nbValues, const size_t vDim );
};
#endif // WLOADERNIFTI_H
......@@ -33,8 +33,7 @@
#include "../../common/WStringUtils.hpp"
WLoaderVTK::WLoaderVTK( std::string fname, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fname ),
m_dataHandler( dataHandler )
: WLoader( fname, dataHandler )
{
}
......
......@@ -95,7 +95,6 @@ protected:
std::vector< std::string > m_header;
private:
boost::shared_ptr< WDataHandler > m_dataHandler;
};
#endif // WLOADERVTK_H
......@@ -37,8 +37,8 @@
class DummyLoader : public WLoader
{
public:
explicit DummyLoader( std::string fileName )
: WLoader( fileName )
explicit DummyLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHandler )
: WLoader( fileName, dataHandler )
{
}
......@@ -58,11 +58,12 @@ public:
*/
void testExceptionOnInvalidFilename( void )
{
TS_ASSERT_THROWS_EQUALS( DummyLoader( "no such file" ),
boost::shared_ptr< WDataHandler > dummyDH = boost::shared_ptr< WDataHandler >( new WDataHandler() );
TS_ASSERT_THROWS_EQUALS( DummyLoader( "no such file", dummyDH ),
const WDHIOFailure &e,
e.what(),
std::string( "file 'no such file' doesn't exists." ) );
TS_ASSERT_THROWS_NOTHING( DummyLoader( "fixtures/scalar_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( DummyLoader( "fixtures/scalar_float.nii.gz", dummyDH ) );
}
};
......
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