Commit 191ecbd2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents 3ea635a9 6f068ff5
......@@ -25,7 +25,7 @@
#include <iostream>
#include "WConditionOneShot.h"
#include "../common/WLogger.h"
#include "WLogger.h"
#include "WThreadedRunner.h"
......@@ -34,7 +34,6 @@ WThreadedRunner::WThreadedRunner():
{
// initialize members
m_FinishRequested = false;
m_Thread = NULL;
}
WThreadedRunner::~WThreadedRunner()
......@@ -42,20 +41,16 @@ WThreadedRunner::~WThreadedRunner()
// cleanup
// XXX is this working if thread already has finished?
// wait( true ); <-- no
if( m_Thread )
{
delete m_Thread;
}
}
void WThreadedRunner::run()
{
m_Thread = new boost::thread( boost::bind( &WThreadedRunner::threadMain, this ) );
run( boost::bind( &WThreadedRunner::threadMain, this ) );
}
void WThreadedRunner::run( THREADFUNCTION f )
{
m_Thread = new boost::thread( f );
m_thread = boost::thread( f );
}
void WThreadedRunner::wait( bool requestFinish )
......@@ -69,7 +64,7 @@ void WThreadedRunner::wait( bool requestFinish )
m_FinishRequested = true;
m_shutdownFlag( true );
}
m_Thread->join();
m_thread.join();
}
void WThreadedRunner::waitForStop()
......@@ -88,7 +83,7 @@ void WThreadedRunner::notifyStop()
void WThreadedRunner::yield() const
{
m_Thread->yield();
m_thread.yield();
}
void WThreadedRunner::sleep( const int32_t t ) const
......
......@@ -91,7 +91,7 @@ protected:
/**
* Thread instance.
*/
boost::thread* m_Thread;
boost::thread m_thread;
/**
* True if thread should end execution. NOTE: do not use this. Use m_shutdownFlag instead.
......@@ -128,6 +128,21 @@ protected:
WBoolFlag m_shutdownFlag;
private:
/**
* Disallow copy construction.
*
* \param rhs the other threaded runner.
*/
WThreadedRunner( const WThreadedRunner & rhs );
/**
* Disallow copy assignment.
*
* \param rhs the other threaded runner.
* \return this.
*/
WThreadedRunner& operator=( const WThreadedRunner & rhs );
};
#endif // WTHREADEDRUNNER_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cstddef>
#include <sstream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "../common/exceptions/WOutOfBounds.h"
#include "io/WPagerEEG.h"
#include "WEEG2.h"
WEEG2::WEEG2( boost::shared_ptr< WPagerEEG > pager )
{
m_segments.reserve( pager->getNumberOfSegments() );
for( std::size_t segmentID = 0; segmentID < pager->getNumberOfSegments(); ++segmentID )
{
m_segments.push_back( boost::shared_ptr< WEEG2Segment >( new WEEG2Segment( pager, segmentID ) ) );
}
}
std::size_t WEEG2::getNumberOfSegments() const
{
return m_segments.size();
}
boost::shared_ptr< WEEG2Segment > WEEG2::getSegment( std::size_t segmentID ) const
{
if( segmentID >= m_segments.size() )
{
std::ostringstream stream;
stream << "The EEG has no segment number " << segmentID;
throw WOutOfBounds( stream.str() );
}
return m_segments[segmentID];
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEEG2_H
#define WEEG2_H
#include <cstddef>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "io/WPagerEEG.h"
#include "WEEG2Segment.h"
#include "WRecording.h"
/**
* Class which contains EEG recording data, read from a WPagerEEG.
* \ingroup dataHandler
*/
class WEEG2 : public WRecording
{
public:
/**
* Constructor
*
* \param pager pager class which contains the data, read from a file on
* demand
*/
explicit WEEG2( boost::shared_ptr< WPagerEEG > pager );
/**
* Get the number of segments this EEG consists of.
*
* \return number of segments
*/
std::size_t getNumberOfSegments() const;
/**
* Get one segment.
*
* \param segmentID number of segment
* \return segment
*/
boost::shared_ptr< WEEG2Segment > getSegment( std::size_t segmentID ) const;
protected:
private:
std::vector< boost::shared_ptr< WEEG2Segment > > m_segments; //!< list of all segments this EEG consists of
};
#endif // WEEG2_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cstddef>
#include <sstream>
#include <boost/shared_ptr.hpp>
#include "../common/exceptions/WOutOfBounds.h"
#include "exceptions/WDHException.h"
#include "io/WPagerEEG.h"
#include "WEEGValueMatrix.h"
#include "WEEG2Segment.h"
WEEG2Segment::WEEG2Segment( boost::shared_ptr< WPagerEEG > pager, std::size_t segmentID )
: m_pager( pager ),
m_segmentID( segmentID )
{
if( !m_pager )
{
throw WDHException( "Couldn't construct new EEG segment: pager invalid" );
}
if( m_segmentID >= m_pager->getNumberOfSegments() )
{
std::ostringstream stream;
stream << "The EEG has no segment number " << m_segmentID;
throw WOutOfBounds( stream.str() );
}
}
boost::shared_ptr< WEEGValueMatrix > WEEG2Segment::getValues( std::size_t start, std::size_t length ) const
{
// No test whether start and length are valid - this should be done only
// one time by the pager.
return m_pager->getValues( m_segmentID, start, length );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEEG2SEGMENT_H
#define WEEG2SEGMENT_H
#include <cstddef>
#include <boost/shared_ptr.hpp>
#include "io/WPagerEEG.h"
#include "WEEGValueMatrix.h"
/**
* Class which contains one segment of an EEG recording, read from a WPagerEEG.
* \ingroup dataHandler
*/
class WEEG2Segment
{
public:
/**
* Constructor
*
* \param pager pager class which contains the data, read from a file on
* demand
* \param segmentID number of this segment
*/
WEEG2Segment( boost::shared_ptr< WPagerEEG > pager, std::size_t segmentID );
/**
* Get the values of all channels for a given sample range.
*
* \param start start sample of the sample range
* \param length length of the sample range
* \return matrix of values
*/
boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t start, std::size_t length ) const;
protected:
private:
boost::shared_ptr< WPagerEEG > m_pager; //!< pager class which contains the data, read from a file on demand
std::size_t m_segmentID; //!< number of this segment
};
#endif // WEEG2SEGMENT_H
......@@ -46,15 +46,21 @@ public:
*/
virtual ~WPagerEEG();
/**
* Get the number of segments this EEG consists of.
* \return number of segments
*/
virtual std::size_t getNumberOfSegments() const = 0;
/**
* Get the values of all channels for a given sample range.
*
* \param segment segment number to read the values from
* \param segmentID segment number to read the values from
* \param start start sample of the sample range
* \param length length of the sample range
* \return matrix of values
*/
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segment, std::size_t start, std::size_t length ) = 0;
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const = 0;
protected:
/**
......
......@@ -88,12 +88,17 @@ WPagerEEGLibeep::~WPagerEEGLibeep()
}
}
boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t segment, std::size_t start, std::size_t length )
std::size_t WPagerEEGLibeep::getNumberOfSegments() const
{
if( segment != 0 )
return 1;
}
boost::shared_ptr< WEEGValueMatrix > WPagerEEGLibeep::getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const
{
if( segmentID != 0 )
{
std::ostringstream stream;
stream << m_fileName << " has no segment number " << segment;
stream << m_fileName << " has no segment number " << segmentID;
throw WOutOfBounds( stream.str() );
}
......
......@@ -58,7 +58,9 @@ public:
*/
virtual ~WPagerEEGLibeep();
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segment, std::size_t start, std::size_t length );
virtual std::size_t getNumberOfSegments() const;
virtual boost::shared_ptr< WEEGValueMatrix > getValues( std::size_t segmentID, std::size_t start, std::size_t length ) const;
protected:
private:
......
......@@ -391,7 +391,7 @@ void WMainWindow::projectLoad()
QStringList::const_iterator constIterator;
for ( constIterator = fileNames.constBegin(); constIterator != fileNames.constEnd(); ++constIterator )
{
WModuleProjectFileCombiner proj = WModuleProjectFileCombiner( ( *constIterator ).toStdString() );
WModuleProjectFileCombiner proj( ( *constIterator ).toStdString() );
proj.run();
}
}
......
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