Computer Assited Medical Intervention Tool Kit  version 4.0
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-2016 Univ. Grenoble Alpes, 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 
59  Q_OBJECT
60 
61 public:
63  ActionStateMachine(int &argc, char ** argv, QString inputFileName="", QString outputDirectory="") throw(camitk::AbortException);
64 
66  virtual ~ActionStateMachine();
67 
69  QString getSaveDirectory();
70 
71 protected:
72 
74  void initMainWindow();
75 
77  void checkSCXMLFile(QString filename) throw(camitk::AbortException);
78 
80  QString parseSCXMLTree() throw(camitk::AbortException);
81 
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 
116 
117 private:
120 
121  void createAllActionStates(QDomNodeList nodeList) throw(camitk::AbortException);
122 
123  void createTransitions(QDomNodeList nodeList) throw(camitk::AbortException);
124 
125  void setCamiTKAction(ActionState * actionState, QDomElement actionElement) throw(camitk::AbortException);
126 
127  void setCamiTKSaveAction(SaveActionState * actionState, QDomElement actionElement) throw(camitk::AbortException);
128 
129  QVector<camitk::Action::ApplyStatus> stringToStatus(QString listOfStatus);
131 
133  QString getDomNodeLocation(QDomNode);
134 };
135 
136 #endif // ACTIONSTATEMACHINE_H
The generic/default application.
Definition: Application.h:62
QFinalState * theEnd
Final State.
Definition: ActionStateMachine.h:101
Exception class to handle abortion in component instanciation.
Definition: AbortException.h:43
QVector< camitk::Action::ApplyStatus > stringToStatus(QString listOfStatus)
Definition: ActionStateMachine.cpp:370
int argc
argc given from command line
Definition: Application.h:392
virtual ~ActionStateMachine()
destructor
Definition: ActionStateMachine.cpp:119
This Class is the base class for your application.
Definition: MainWindow.h:62
void setCamiTKAction(ActionState *actionState, QDomElement actionElement)
Definition: ActionStateMachine.cpp:393
void checkSCXMLFile(QString filename)
check that the file is a SCXML file (simple checking, no XML Schema validation yet) ...
Definition: ActionStateMachine.cpp:150
void setCamiTKSaveAction(SaveActionState *actionState, QDomElement actionElement)
Definition: ActionStateMachine.cpp:482
QString getDomNodeLocation(QDomNode)
build a specific error message containing the line and column if available
Definition: ActionStateMachine.cpp:518
QString name
Application&#39;s name.
Definition: ActionStateMachine.h:86
The state (in a state machine point of view) corresponding to the current processed action...
Definition: ActionState.h:47
ActionStateMachine(int &argc, char **argv, QString inputFileName="", QString outputDirectory="")
construtor
Definition: ActionStateMachine.cpp:54
QDomDocument scxmlDoc
XML tree containing infos.
Definition: ActionStateMachine.h:95
void createTransitions(QDomNodeList nodeList)
Definition: ActionStateMachine.cpp:305
QMap< QString, ActionState * > * statesMap
Map of action state to build transitions.
Definition: ActionStateMachine.h:98
QString parseSCXMLTree()
parse the XML file (using Qt DOM API)
Definition: ActionStateMachine.cpp:185
void initMainWindow()
initialized main window
Definition: ActionStateMachine.cpp:129
This Class describes ActionStateMachine MainWindow extension.
Definition: ActionStateMachine.h:58
char ** argv
argv given from command line
Definition: Application.h:395
camitk::MainWindow * mainWindow
main window
Definition: ActionStateMachine.h:92
QStateMachine machine
Actual state machine.
Definition: ActionStateMachine.h:89
QTextStream * logStream
Log stream to write report on logFile.
Definition: ActionStateMachine.h:110
QFile * logFile
Log file.
Definition: ActionStateMachine.h:113
QTime * startTime
To get track of the Action State Machine the duration.
Definition: ActionStateMachine.h:107
The asm application uses a state machine.
Definition: SaveActionState.h:37
void createAllActionStates(QDomNodeList nodeList)
Definition: ActionStateMachine.cpp:223
QDir saveDirectory
Where to save all files.
Definition: ActionStateMachine.h:104
QString getSaveDirectory()
where to save the files
Definition: ActionStateMachine.cpp:513