2012-01-24 15:13:07 +01:00
|
|
|
/*
|
|
|
|
|
~ author: dviid
|
|
|
|
|
~ contact: dviid@labs.ciid.dk
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "AbstractAnalysis.h"
|
|
|
|
|
|
|
|
|
|
#include "Poco/Thread.h"
|
|
|
|
|
#include "Poco/RunnableAdapter.h"
|
|
|
|
|
|
|
|
|
|
using Poco::Thread;
|
|
|
|
|
using Poco::RunnableAdapter;
|
|
|
|
|
|
|
|
|
|
class AnalysisAdaptor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AnalysisAdaptor(AbstractAnalysis* analysis) : _analysis(analysis) {;}
|
|
|
|
|
virtual ~AnalysisAdaptor(){ delete _runnable; }
|
|
|
|
|
|
|
|
|
|
void start()
|
|
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
_stopping = false;
|
2012-02-11 18:54:46 +01:00
|
|
|
_runnable = new RunnableAdapter<AbstractAnalysis>(*_analysis, &AbstractAnalysis::do_synthesize);
|
2012-01-24 15:13:07 +01:00
|
|
|
_worker.start(*_runnable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stop()
|
|
|
|
|
{
|
2012-02-21 21:18:25 +01:00
|
|
|
if(_stopping) return;
|
|
|
|
|
_stopping = true;
|
2012-01-24 15:13:07 +01:00
|
|
|
_analysis->_state = STATE_STOP;
|
2012-02-21 21:18:25 +01:00
|
|
|
_worker.join();
|
2012-01-24 15:13:07 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-15 07:58:30 +01:00
|
|
|
protected:
|
2012-01-24 15:13:07 +01:00
|
|
|
AbstractAnalysis* _analysis;
|
|
|
|
|
Thread _worker; //
|
2012-02-21 21:18:25 +01:00
|
|
|
RunnableAdapter<AbstractAnalysis>* _runnable;
|
|
|
|
|
bool _stopping;
|
2012-01-24 15:13:07 +01:00
|
|
|
};
|
|
|
|
|
|