summaryrefslogtreecommitdiffstats
path: root/src/server/serverapp/serverapp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/serverapp/serverapp.h')
-rw-r--r--src/server/serverapp/serverapp.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/server/serverapp/serverapp.h b/src/server/serverapp/serverapp.h
new file mode 100644
index 0000000..be6b0ab
--- /dev/null
+++ b/src/server/serverapp/serverapp.h
@@ -0,0 +1,87 @@
+#ifndef SERVERAPP_H
+#define SERVERAPP_H
+
+#include <QApplication>
+#include <QStringList>
+#include <QMap>
+
+#include "../mainwindow/mainwindow.h"
+
+struct Room {
+ Room(QMap<QString, QPoint> cPos, QSize grid, QSize client, QString image, QString tutor) :
+ clientPositions(cPos),
+ gridSize(grid),
+ clientSize(client),
+ imagePath(image),
+ tutorIP(tutor) {};
+ QMap<QString, QPoint> clientPositions;
+ QSize gridSize;
+ QSize clientSize;
+ QString imagePath;
+ QString tutorIP;
+};
+
+
+/* define a macro `serverApp` that can be used anywhere in the program and
+ * returns a reference to the current ClientApp instance */
+
+#if defined(serverApp)
+#undef serverApp
+#endif
+#define serverApp (static_cast<ServerApp*>(QCoreApplication::instance()))
+
+/* this class is supposed to (after complete refactoring) to encapsulate all
+ * state of the application. At the moment, the state is distributed within
+ * several widgets. With this class information access will also be easier as
+ * it is possible to access the current ServerApp instance from anywhere with
+ * the serverApp macro (like qApp) */
+class ServerApp : public QApplication
+{
+
+ Q_OBJECT
+
+private:
+ QStringList _arguments;
+ QStringList parseParameters();
+ MainWindow* _mainWindow;
+
+ QString _sessionName;
+ QByteArray _sessionNameArray;
+ QMap<QString, Room*> _rooms;
+ QString _currentRoom;
+
+ bool _manager_only;
+ bool _isExam;
+ QString _iniPath;
+
+public:
+
+ ServerApp(int& argc, char** argv);
+
+ virtual QStringList arguments();
+
+
+ /* getters */
+ const QString& sessionName() { return _sessionName; }
+ const QByteArray& sessionNameArray() { return _sessionNameArray; }
+ const QMap<QString, Room*> & rooms() { return _rooms; }
+ const QString& getCurrentRoomName() { return _currentRoom; }
+ const QMap<QString, Room*>& getRooms() { return _rooms; }
+ bool isExam() { return _isExam; }
+ bool isManagerOnly() { return _manager_only; }
+ const Room* getCurrentRoom();
+
+ /* setters */
+ void setSessionName(const QString& name);
+ void setSessionName();
+ void setRooms(const QMap<QString, Room*> & roomList) { _rooms = roomList; }
+ void setIniPath(QString s) { _iniPath = s; };
+ void setCurrentRoom(const QString& room) { _currentRoom = room; }
+ void setExam(bool exam) { _isExam = exam; }
+
+ QSharedPointer<QSettings> getSettings();
+
+
+};
+
+#endif