Commit 01e46b61 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[CHANGE #104] fileName and name are in WDataSet resp. WSubject now.

parent 155b8d00
......@@ -21,9 +21,23 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WDataSet.h"
WDataSet::WDataSet()
: m_fileName( "" )
{
}
void WDataSet::setFileName( const std::string fileName )
{
assert( fileName != "" );
m_fileName = fileName;
}
std::string WDataSet::getFileName() const
{
return m_fileName;
}
......@@ -24,6 +24,7 @@
#ifndef WDATASET_H
#define WDATASET_H
#include <string>
#include <boost/shared_ptr.hpp>
/**
......@@ -40,7 +41,7 @@ public:
* Since every DataSet should have a MetaInfo, we ensure hereby you never
* go without one.
*/
explicit WDataSet();
WDataSet();
/**
* Since WDataSet is a base class and thus should be polymorphic we add
......@@ -49,8 +50,24 @@ public:
virtual ~WDataSet()
{
}
/**
* Set the name of the file that this data set stems from.
*/
void setFileName( const std::string fileName );
/**
* Get the name of the file that this data set stems from.
*/
std::string getFileName() const;
protected:
private:
/**
* Name of the file this data set was loaded from. This information
* may allow hollowing data sets later.
*/
std::string m_fileName;
};
#endif // WDATASET_H
......@@ -21,14 +21,29 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WSubject.h"
#include "exceptions/WNoSuchDataSetException.h"
WSubject::WSubject()
: m_name( "Not named yet" ),
m_dataSets( 0 )
{
}
WSubject::WSubject( std::string name )
: m_name( name ),
m_dataSets( 0 )
{
}
std::string WSubject::getName() const
{
return m_name;
}
boost::shared_ptr< const WDataSet > WSubject::getDataSet( const unsigned int dataSetId ) const
{
if( dataSetId >= m_dataSets.size() )
......@@ -41,13 +56,11 @@ boost::shared_ptr< const WDataSet > WSubject::operator[]( const unsigned int dat
return getDataSet( dataSetId );
}
void WSubject::addDataSet( boost::shared_ptr< WDataSet > newDataSet )
{
m_dataSets.push_back( newDataSet );
}
unsigned int WSubject::getNumberOfDataSets() const
{
return m_dataSets.size();
......
......@@ -42,6 +42,16 @@ public:
*/
WSubject();
/**
* Allows to give the subject a name during construction
*/
explicit WSubject( std::string name );
/**
* Returns the name of the subject. See WSubject::m_name for details on the name.
*/
std::string getName() const;
/**
* Get the pointer to the i'th WDataSet. The return type is const since we
* want to ensure that each DataSet cannot modified after retrival.
......@@ -65,6 +75,12 @@ public:
unsigned int getNumberOfDataSets() const;
protected:
private:
/**
* Name of subject. As not all data formats contain real names
* this may also be some kind of id (e.g. initials).
*/
std::string m_name;
/**
* A container for all WDataSets belonging to the subject.
*/
......
......@@ -138,6 +138,7 @@ void WLoaderBiosig::biosigLoader()
{
subject = m_dataHandler->getSubject( 0 );
}
eeg->setFileName( m_fileName );
subject->addDataSet( eeg );
std::cout << "BIOSIG loading done." << std::endl;
......
......@@ -95,5 +95,6 @@ void WLoaderEEGASCII::operator()()
{
subject = m_dataHandler->getSubject( 0 );
}
eeg->setFileName( m_fileName );
subject->addDataSet( eeg );
}
......@@ -127,13 +127,13 @@ void WLoaderNIfTI::operator()()
newGrid = boost::shared_ptr< WGrid >();
}
// TODO( wiebel ): fill this info into the subject instead
// TODO(wiebel): fill this info into the subject instead
// 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
// 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 )
......@@ -145,15 +145,14 @@ void WLoaderNIfTI::operator()()
{
subject = m_dataHandler->getSubject( 0 );
}
newDataSet->setFileName( m_fileName );
subject->addDataSet( newDataSet );
}
// TODO( wiebel ): fill this info into the subject instead
// TODO(wiebel): fill this info into the subject instead
// void WLoaderNIfTI::fillMetaInfo( boost::shared_ptr< WMetaInfo > metaInfo, nifti_image* header )
// {
// metaInfo->setName( m_fileName );
// metaInfo->setFileName( m_fileName );
// metaInfo->setDataType( header->datatype );
// metaInfo->setValueDim( header->dim[4] );
// metaInfo->setNx( header->nx );
......
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