Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ActionStateMachine.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef ACTIONSTATEMACHINE_H
28 #define ACTIONSTATEMACHINE_H
29 
30 
31 // -- Qt stuff
32 #include <QTextStream>
33 #include <QStateMachine>
34 #include <QState>
35 #include <QFinalState>
36 #include <QDir>
37 
38 // -- Qt XML stuff
39 #include <QtXml/QDomDocument>
40 #include <QtXml/QDomNodeList>
41 
42 // -- CamiTK Core stuff
43 #include <AbortException.h>
44 #include <Application.h>
45 
46 // -- CamiTK Local stuff
47 #include "ActionState.h"
48 #include "SaveActionState.h"
49 
50 
51 using namespace camitk;
52 
62 {
63  Q_OBJECT
64 
65 public:
67  ActionStateMachine(int &argc, char ** argv) throw(AbortException);
68 
70  virtual ~ActionStateMachine();
71 
73  QString getSaveDirectory();
74 
75 protected:
76 
77  void initMainWindow();
78 
79  void checkSCXMLFile(QString filename) throw (AbortException);
80 
81  QString parseSCXMLTree() throw (AbortException);
82 
84 
86  QString name;
87 
89  QStateMachine machine;
90 
93 
95  QDomDocument scxmlDoc;
96 
98  QMap<QString, ActionState *> * statesMap;
99 
101  QFinalState * theEnd;
102 
105 
107  QTime * startTime;
108 
110  QTextStream * logStream;
111 
113  QFile * logFile;
114 
115 
117 
118 private:
120 
121  void createAllActionStates(QDomNodeList nodeList) throw (AbortException);
122 
123  void createTransitions(QDomNodeList nodeList) throw(AbortException);
124 
125  void setCamiTKAction(ActionState * actionState, QDomElement actionElement) throw (AbortException);
126 
127  void setCamiTKSaveAction(SaveActionState * actionState, QDomElement actionElement) throw(AbortException);
128 
129  QVector<Action::ApplyStatus> stringToStatus(QString listOfStatus);
131 };
132 
133 #endif // ACTIONSTATEMACHINE_H