23 #ifndef BASEEXPERIMENT_H
24 #define BASEEXPERIMENT_H
28 #include "component.h"
29 #include "workerthread.h"
30 #include "parametersettable.h"
31 #include "parametersettableui.h"
32 #include "baseexception.h"
33 #include "configurationhelper.h"
36 #include <QMutexLocker>
37 #include <QWaitCondition>
38 #include <QSignalMapper>
49 class BaseExperimentGUI;
56 namespace __BaseExperiment_internal {
57 class BaseExperimentUIManager;
74 OperationStepDelayChanged
110 StartOperationPaused,
267 class Notifee :
public NewDatumNotifiable<__BaseExperiment_internal::OperationControl>
301 friend class Notifee;
316 QString getName()
const
325 bool getUseSeparateThread()
const
327 return useSeparateThread;
333 bool getSteppable()
const
355 virtual void executeOperation() = 0;
366 bool useSeparateThread;
383 friend class std::auto_ptr;
405 m_experiment(experiment),
406 m_operation(operation)
421 virtual void executeOperation()
423 (m_experiment->*m_operation)();
429 T*
const m_experiment;
435 void (T::*m_operation)();
451 virtual ~BaseExperiment();
463 virtual void configure(ConfigurationParameters& params, QString prefix);
474 virtual void save(ConfigurationParameters& params, QString prefix);
491 static void describe(QString type);
500 virtual void postConfigureInitialization();
510 virtual ParameterSettableUI* getUIManager();
521 virtual void fillActionsMenu(QMenu* actionsMenu);
535 virtual QList<ParameterSettableUIViewer> getViewers(QWidget* parent, Qt::WindowFlags flags);
542 virtual void addAdditionalMenus(QMenuBar* menuBar);
595 void changeInterval(
unsigned long interval);
602 unsigned long currentInterval()
const;
609 const QVector<AbstractOperationWrapper*>& getOperations()
const;
619 DataUploaderDownloader<__BaseExperiment_internal::OperationStatus, __BaseExperiment_internal::OperationControl>* getUploaderDownloader();
629 virtual void stopCurrentOperation(
bool wait);
636 virtual void stopCurrentOperation();
646 void exceptionDuringOperation(farsa::BaseException *e);
656 void runOperation(
int operationID);
670 QList<QAction*> getActionsForOperations(QObject* actionsParent)
const;
697 void addOperation(QString name,
void (T::*func)(),
bool useSeparateThread,
bool steppable =
false)
699 std::auto_ptr<AbstractOperationWrapper> newOp(
new OperationWrapper<T>(static_cast<T*>(
this), func));
701 newOp->useSeparateThread = useSeparateThread;
702 newOp->steppable = steppable;
704 m_operationsVector.push_back(newOp.release());
715 bool batchRunning()
const;
723 bool stopSimulation();
763 void changeInterval(
unsigned long interval,
bool sendNotificationToGUI);
768 QVector<AbstractOperationWrapper*> m_operationsVector;
776 std::auto_ptr<QSignalMapper> m_actionSignalsMapper;
781 std::auto_ptr<WorkerThread>
const m_workerThread;
789 int m_runningOperationID;
811 QWaitCondition m_waitCondition;
823 bool m_previousPauseStatus;
828 unsigned long m_delay;
859 #define DECLARE_THREAD_OPERATION(classname, op) addOperation(#op, &classname::op, true, false);
869 #define DECLARE_STEPPABLE_THREAD_OPERATION(classname, op) addOperation(#op, &classname::op, true, true);
879 #define DECLARE_IMMEDIATE_OPERATION(classname, op) addOperation(#op, &classname::op, false);