#ifndef SERVERAPP_H #define SERVERAPP_H #include #include #include #include "../mainwindow/mainwindow.h" struct Room { Room(QMap cPos, QSize grid, QSize client, QString image, QString tutor) : clientPositions(cPos), gridSize(grid), clientSize(client), imagePath(image), tutorIP(tutor) {}; QMap 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(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; MainWindow* _mainWindow; QString _sessionName; QByteArray _sessionNameArray; QMap _rooms; QString _currentRoom; bool _managerOnly; bool _isExam; QString _iniPath; QStringList parseParameters(); void loadRooms(); public: ServerApp(int& argc, char** argv); virtual QStringList arguments(); /* getters */ const QString& sessionName() { return _sessionName; } const QByteArray& sessionNameArray() { return _sessionNameArray; } const QMap & rooms() { return _rooms; } const QString& getCurrentRoomName() { return _currentRoom; } const QMap& getRooms() { return _rooms; } bool isExam() { return _isExam; } bool isManagerOnly() { return _managerOnly; } const Room* getCurrentRoom(); QSharedPointer getSettings(); /* setters */ void setSessionName(const QString& name); void setSessionName(); void setIniPath(QString s) { _iniPath = s; }; void setCurrentRoom(const QString& room) { _currentRoom = room; } void setExam(bool exam) { _isExam = exam; } }; #endif