Rev 493 | Rev 498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
105 | Werner | 2 | #ifndef MODELCONTROLLER_H |
3 | #define MODELCONTROLLER_H |
||
128 | Werner | 4 | #include <QObject> |
105 | Werner | 5 | |
128 | Werner | 6 | class Model; |
7 | class ModelController: public QObject |
||
105 | Werner | 8 | { |
128 | Werner | 9 | Q_OBJECT |
105 | Werner | 10 | public: |
11 | ModelController(); |
||
128 | Werner | 12 | ~ModelController(); |
13 | Model *model() const { return mModel; } |
||
14 | // bool checkers... |
||
145 | Werner | 15 | bool canCreate(); ///< return true if the model can be created (settings loaded and model does not exist) |
16 | bool canDestroy(); ///< model may be destroyed |
||
17 | bool canRun(); ///< model may be run |
||
161 | werner | 18 | bool isRunning(); ///< model is running |
225 | werner | 19 | bool isFinished(); ///< returns true if there is a valid model state, but the run is finished |
497 | werner | 20 | int currentYear() const; ///< return current year of the model |
21 | int totalYears() const { return mYearsToRun - 1; } ///< returns total number of years to simulate |
||
161 | werner | 22 | // dynamic outputs (variable fields) |
23 | void setupDynamicOutput(QString fieldList); |
||
24 | QString dynamicOutput(); |
||
222 | werner | 25 | signals: |
26 | void finished(QString errorMessage); |
||
27 | void year(int year); |
||
128 | Werner | 28 | public slots: |
29 | void setFileName(QString initFileName); ///< set project file name |
||
30 | void create(); ///< create the model |
||
31 | void destroy(); ///< delete the model |
||
222 | werner | 32 | void run(int years); ///< run the model |
223 | werner | 33 | bool runYear(); ///< runs a single time step |
222 | werner | 34 | bool pause(); ///< pause execution, and if paused, continue to run. returns state *after* change, i.e. true=now in paused mode |
35 | void cancel(); ///< cancel execution of the model |
||
223 | werner | 36 | private slots: |
37 | void runloop(); |
||
128 | Werner | 38 | private: |
161 | werner | 39 | void fetchDynamicOutput(); |
128 | Werner | 40 | Model *mModel; |
223 | werner | 41 | bool mPaused; |
225 | werner | 42 | bool mRunning; |
43 | bool mFinished; |
||
44 | bool mCanceled; |
||
223 | werner | 45 | int mYearsToRun; |
128 | Werner | 46 | QString mInitFile; |
161 | werner | 47 | QStringList mDynFieldList; |
48 | QStringList mDynData; |
||
49 | |||
105 | Werner | 50 | }; |
51 | |||
52 | #endif // MODELCONTROLLER_H |