Terminus
abstractcommand.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QJsonObject>
4 #include <QObject>
5 
7 #include <util/timer.h>
8 
9 namespace terminus
10 {
11 
12 class Game;
13 class NetworkServer;
14 class NetworkConnection;
15 
24 {
25 protected:
26  static QJsonObject VectorToJsonObject(QVector3D vector);
27  static QVector3D VectorFromJsonObject(QJsonObject jsonObject);
28 
29 public:
31  virtual ~AbstractCommand();
32 
37  void setGame(Game * game);
38 
44 
51  virtual Commands commandType() const = 0;
52 
57  virtual QJsonObject toJson() const = 0;
58 
65  virtual void doWork() = 0;
66 
67 protected:
70 };
71 
72 }
Timer::TimerMSec m_timeStamp
Definition: abstractcommand.h:69
Game * m_game
Definition: abstractcommand.h:68
static QVector3D VectorFromJsonObject(QJsonObject jsonObject)
Definition: abstractcommand.cpp:24
void setGame(Game *game)
set the game instance this command should operate on
Definition: abstractcommand.cpp:48
AbstractCommand(Timer::TimerMSec timeStamp)
Definition: abstractcommand.cpp:38
The Game class is the main entry point. It subclasses QQuickItem and handles all communication betwee...
Definition: game.h:36
virtual Commands commandType() const =0
Every Command must specify its type.
Commands
The Commands enum stores all command types with corresponding ID.
Definition: commands.h:9
virtual void doWork()=0
Every Commands must define its effects on the receiving game.
virtual QJsonObject toJson() const =0
Every command must define how its members can be serialized.
signed int TimerMSec
Definition: timer.h:22
Definition: eventhandler.cpp:18
virtual ~AbstractCommand()
Definition: abstractcommand.cpp:44
Timer::TimerMSec timeStamp() const
get the time as counted by the sending game that this command was created and sent ...
Definition: abstractcommand.cpp:54
static QJsonObject VectorToJsonObject(QVector3D vector)
Definition: abstractcommand.cpp:14
The AbstractCommand class defines the interface that every command has to implement.
Definition: abstractcommand.h:23