arcsstatemachine.h
1 /*
2  name: include/arcs/arcsstatemachine.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program 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 General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSSTATEMACHINE_H__
30 #define __ARCSSTATEMACHINE_H__
31 
32 #include <QObject>
33 #include <QHash>
34 #include <QStringList>
35 #include <arcs/arcsdll.h>
36 
37 
39 
43 class DLL_POINT ARCSStateMachine : public QObject
44 {
45 Q_OBJECT
46 
47 public:
49 
50 
52  void setFirstSheetName(QString s) { firstSheetName = s; }
54  void setLastSheetName(QString s) { lastSheetName = s; }
55 
57  QString getFirstSheetName() { return firstSheetName; }
59  QString getLastSheetName() { return lastSheetName; }
61  QString getCurrentSheetName() { return currentSheetName; }
63  void renameSheet(QString oldName,QString newName );
64 
65 
66  void clear();
67  void start();
68  bool hasError() { return error; }
69  void addTransition(QString bState, QString token, QString eState);
70  void getTransitions(QStringList & bState, QStringList & token, QStringList & eState);
71 
72  bool hasFinished() { return (currentSheetName == lastSheetName); }
73 
74 public slots:
78  void setToken(QString s);
79 
80 signals:
82  void sendSheet(QString s);
84  void finished();
85 
86 
87 private:
88  QHash<QString,QHash<QString,QString> > transitions;
89  QString firstSheetName;
90  QString lastSheetName;
91  QString currentSheetName;
92  bool error;
93 
94 
95 };
96 
97 
98 #endif //__ARCSSTATEMACHINE_H__
QString getCurrentSheetName()
Returns the name of the current activated sheet in the statemachine.
QString getFirstSheetName()
Returns the name of the first state activated in the statemachine.
QString getLastSheetName()
Returns the name of the last state activated in the statemachine.
void setFirstSheetName(QString s)
Sets the name of the first sheet i.e. the starting node of the statemachine.
Class describing a state machine in order to control an application.
void setLastSheetName(QString s)
Sets the name of the last sheet i.e. the node ending the statemachine.