Commit 4ce9d6d1 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[ADD #13] WLoader has now its own commitDataSet member function which shall be...

[ADD #13] WLoader has now its own commitDataSet member function which shall be used in the subclasses
parent 8e0db2f3
......@@ -40,3 +40,20 @@ WLoader::WLoader( std::string fileName, boost::shared_ptr< WDataHandler > dataHa
throw WDHIOFailure( "file '" + m_fileName + "' doesn't exists." );
}
}
void WLoader::commitDataSet( boost::shared_ptr< WDataSet > data )
{
// TODO(wiebel): this is a dummy implementation. We need to fix
// this as soon as we can distinguish which data belongs to which subject.
boost::shared_ptr< WSubject > subject;
if( m_dataHandler->getNumberOfSubjects() == 0 )
{
subject = boost::shared_ptr< WSubject >( new WSubject );
m_dataHandler->addSubject( subject );
}
else
{
subject = m_dataHandler->getSubject( 0 );
}
subject->addDataSet( data );
}
......@@ -31,6 +31,7 @@
#include "exceptions/WDHIOFailure.h"
#include "WDataHandler.h"
#include "WSubject.h"
/**
* Base class to all WLoaders which imports data from a given file and generate
......@@ -68,6 +69,12 @@ protected:
* Reference to DataHandler
*/
boost::shared_ptr< WDataHandler > m_dataHandler;
/**
* Commit new data into the DataHandler.
*/
void commitDataSet( boost::shared_ptr< WDataSet > data );
private:
};
......
......@@ -126,20 +126,8 @@ void WLoaderBiosig::biosigLoader()
}
boost::shared_ptr< WEEG > eeg = boost::shared_ptr< WEEG >( new WEEG( segments, lib, labels ) );
// TODO(wiebel): this is a dummy implementation. We need to fix
// this as soon as we can distinguish which data belongs to which subject.
boost::shared_ptr< WSubject > subject;
if( m_dataHandler->getNumberOfSubjects() == 0 )
{
subject = boost::shared_ptr< WSubject >( new WSubject );
m_dataHandler->addSubject( subject );
}
else
{
subject = m_dataHandler->getSubject( 0 );
}
eeg->setFileName( m_fileName );
subject->addDataSet( eeg );
commitDataSet( eeg );
std::cout << "BIOSIG loading done." << std::endl;
std::cout << "===================================" << std::endl;
......
......@@ -82,19 +82,6 @@ void WLoaderEEGASCII::operator()()
WEEGElectrodeLibrary lib; // TODO(wiebel): this is a dummy
boost::shared_ptr< WEEG > eeg = boost::shared_ptr< WEEG >( new WEEG( segments, lib, labels ) );
// TODO(wiebel): this is a dummy implementation. We need to fix
// this as soon as we can distinguish which data belongs to which subject.
boost::shared_ptr< WSubject > subject;
if( m_dataHandler->getNumberOfSubjects() == 0 )
{
subject = boost::shared_ptr< WSubject >( new WSubject );
m_dataHandler->addSubject( subject );
}
else
{
subject = m_dataHandler->getSubject( 0 );
}
eeg->setFileName( m_fileName );
subject->addDataSet( eeg );
commitDataSet( eeg );
}
......@@ -83,17 +83,7 @@ void WLoaderFibers::operator()() throw()
shared_ptr< WDataSetFibers > fibers = shared_ptr< WDataSetFibers >( new WDataSetFibers( data ) );
fibers->setFileName( m_fileName );
boost::shared_ptr< WSubject > subject;
if( m_dataHandler->getNumberOfSubjects() == 0 )
{
subject = boost::shared_ptr< WSubject >( new WSubject );
m_dataHandler->addSubject( subject );
}
else
{
subject = m_dataHandler->getSubject( 0 );
}
subject->addDataSet( fibers );
commitDataSet( fibers );
}
void WLoaderFibers::readHeader() throw( WDHIOFailure, WDHException )
......
......@@ -116,21 +116,8 @@ void WLoaderNIfTI::operator()()
// fillMetaInfo( metaInfo, header );
boost::shared_ptr< WDataSet > newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSingle( newValueSet, newGrid ) );
// TODO(wiebel): this is a dummy implementation. We need to fix
// this as soon as we can distinguish which data belongs to which subject.
boost::shared_ptr< WSubject > subject;
if( m_dataHandler->getNumberOfSubjects() == 0 )
{
subject = boost::shared_ptr< WSubject >( new WSubject );
m_dataHandler->addSubject( subject );
}
else
{
subject = m_dataHandler->getSubject( 0 );
}
newDataSet->setFileName( m_fileName );
subject->addDataSet( newDataSet );
commitDataSet( newDataSet );
}
......
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