Terminus
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
terminus::AbstractCommand Class Referenceabstract

The AbstractCommand class defines the interface that every command has to implement. More...

#include <abstractcommand.h>

Inheritance diagram for terminus::AbstractCommand:
terminus::ClientReadyCommand terminus::GameEndedCommand terminus::PauseCommand terminus::PrepareNewGameCommand terminus::ProjectileFiredCommand terminus::ProjectileHitCommand terminus::SyncCommand

Public Member Functions

 AbstractCommand (Timer::TimerMSec timeStamp)
 
virtual ~AbstractCommand ()
 
void setGame (Game *game)
 set the game instance this command should operate on More...
 
Timer::TimerMSec timeStamp () const
 get the time as counted by the sending game that this command was created and sent More...
 
virtual Commands commandType () const =0
 Every Command must specify its type. More...
 
virtual QJsonObject toJson () const =0
 Every command must define how its members can be serialized. More...
 
virtual void doWork ()=0
 Every Commands must define its effects on the receiving game. More...
 

Static Protected Member Functions

static QJsonObject VectorToJsonObject (QVector3D vector)
 
static QVector3D VectorFromJsonObject (QJsonObject jsonObject)
 

Protected Attributes

Gamem_game
 
Timer::TimerMSec m_timeStamp
 

Detailed Description

The AbstractCommand class defines the interface that every command has to implement.

It also provides some convenience methods for JSON conversion and members commonly used by all commands.

Constructor & Destructor Documentation

terminus::AbstractCommand::AbstractCommand ( Timer::TimerMSec  timeStamp)
terminus::AbstractCommand::~AbstractCommand ( )
virtual

Member Function Documentation

virtual Commands terminus::AbstractCommand::commandType ( ) const
pure virtual
virtual void terminus::AbstractCommand::doWork ( )
pure virtual

Every Commands must define its effects on the receiving game.

This Method is guaranteed to be executed in the receiving game's frame update context with a valid Game instance in m_game

Implemented in terminus::ProjectileFiredCommand, terminus::SyncCommand, terminus::ProjectileHitCommand, terminus::ClientReadyCommand, terminus::GameEndedCommand, terminus::PrepareNewGameCommand, and terminus::PauseCommand.

void terminus::AbstractCommand::setGame ( Game game)

set the game instance this command should operate on

Parameters
game- ownership not taken
Timer::TimerMSec terminus::AbstractCommand::timeStamp ( ) const

get the time as counted by the sending game that this command was created and sent

Returns
timestamp in milliseconds
virtual QJsonObject terminus::AbstractCommand::toJson ( ) const
pure virtual

Every command must define how its members can be serialized.

Returns
A QJsonObject containing the parameters / members

Implemented in terminus::ProjectileFiredCommand, terminus::SyncCommand, terminus::ProjectileHitCommand, terminus::ClientReadyCommand, terminus::GameEndedCommand, terminus::PrepareNewGameCommand, and terminus::PauseCommand.

QVector3D terminus::AbstractCommand::VectorFromJsonObject ( QJsonObject  jsonObject)
staticprotected
QJsonObject terminus::AbstractCommand::VectorToJsonObject ( QVector3D  vector)
staticprotected

Member Data Documentation

Game* terminus::AbstractCommand::m_game
protected
Timer::TimerMSec terminus::AbstractCommand::m_timeStamp
protected

The documentation for this class was generated from the following files: