arcsprocess.h
1 /*
2  name: include/arcs/arcsprocess.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 __ARCSPROCESS_H__
30 #define __ARCSPROCESS_H__
31 
32 #include <arcs/arcsdll.h>
33 #include <arcs/arcssheet.h>
34 #include <arcs/arcs.h>
35 #include <arcs/arcscontrollercomponent.h>
36 
37 
38 #include <QMutex>
39 #include <QWaitCondition>
40 
41 class ARCSContext;
43 class ARCSAppMode;
44 
46 
52 class DLL_POINT ARCSProcess : public QObject
53 {
54  Q_OBJECT
55 
56 public:
57  ARCSProcess();
58  ~ARCSProcess();
59 
61  void setContext(ARCSContext* ctx) { context = ctx; }
63  bool setController(QString s=QString::null);
64 
69  void addSheet(QString s, ARCSSheet sh);
73  void removeSheet(QString s);
74 
80  void renameSheet(QString oldName, QString newName);
81 
86  ARCSSheet& getSheet(QString s)
87  {
88  if (sheets.contains(s))
89  return sheets[s];
90  return ARCSSheet::null ;
91  }
92 
94  QStringList getSheetNames() { return sheets.keys(); }
96  QString getControllerId()
97  {
98  if (controller)
99  return controller->getProperty("id").toString();
100  return QString::null;
101  }
102 
109  void setApplicationMode(ARCS::ARCSAppFlag flag) { currentMode = flag; setProcessMode();}
116  void setReferenceApplicationMode(ARCS::ARCSAppFlag flag);
117 
119  bool startProcess();
121  bool stopProcess();
122 
127  virtual bool event(QEvent* event);
128 
132  void waitForFirstSheet();
133 
135  ARCSControllerComponent* getController() { return controller;}
136 
138  ARCSContext* getContext() { return context; }
139 
141  bool hasFinished() { return processFinished; }
142 
144  void setupNextSheet();
145 
147  void wait();
148 
149 
150 public slots:
156  void changeSheet(QString s);
158  void finish();
159 
160 signals:
162  void finished();
163 
164 
165 private:
166  void setProcessMode();
167  ARCSContext* context;
168  QHash<QString,ARCSSheet> sheets;
169  ARCSControllerComponent* controller;
170  ARCSAppMode* applicationMode;
171 
172  bool processFinished;
173  bool firstTime;
174  ARCS::ARCSAppFlag currentMode;
175  QString currentSheetId;
176  QMutex mutex;
177  QWaitCondition cond;
178 };
179 
180 
181 #endif // __ARCSPROCESS_H__
QStringList getSheetNames()
Definition: arcsprocess.h:94
ARCSAppFlag
Flags to specify in which mode applications should start.
Definition: arcs.h:41
This class is representing a process under ARCS.
Definition: arcsprocess.h:52
void setContext(ARCSContext *ctx)
Definition: arcsprocess.h:61
void setApplicationMode(ARCS::ARCSAppFlag flag)
Definition: arcsprocess.h:109
Defines a controller component.
ARCSContext * getContext()
Definition: arcsprocess.h:138
Base class for launching and handling ARCS applications.
Definition: arcsappmode.h:45
This class manages components and constants in a given context.
Definition: arcscontext.h:45
ARCSControllerComponent * getController()
Definition: arcsprocess.h:135
bool hasFinished()
Definition: arcsprocess.h:141
ARCSSheet & getSheet(QString s)
Definition: arcsprocess.h:86
Maintains connections between objects.
Definition: arcssheet.h:48
QString getControllerId()
Definition: arcsprocess.h:96