Eile Mit Weile
Loading...
Searching...
No Matches
FullStateResponse Class Reference

ServerResponse that communicates the full state of the game to all players after any update to the GameState. More...

#include <FullStateResponse.hpp>

Inheritance diagram for FullStateResponse:
ServerResponse Serializable

Public Member Functions

 FullStateResponse (std::string game_id, const GameState &state)
 
 ~FullStateResponse ()
 
rapidjson::ValueGetStateJson () const
 
void WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override
 
- Public Member Functions inherited from ServerResponse
ResponseType GetType () const
 
std::string GetGameId () const
 
void WriteIntoJson (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override
 
virtual void Process () const
 
- Public Member Functions inherited from Serializable
virtual rapidjson::DocumentToJson () const
 

Static Public Member Functions

static FullStateResponseFromJson (const rapidjson::Value &json)
 
- Static Public Member Functions inherited from ServerResponse
static ServerResponseFromJson (const rapidjson::Value &json)
 

Private Member Functions

 FullStateResponse (BaseClassProperties props, rapidjson::Value *state_json)
 

Private Attributes

rapidjson::Value_state_json {}
 

Additional Inherited Members

- Protected Member Functions inherited from ServerResponse
 ServerResponse (const BaseClassProperties &)
 
- Static Protected Member Functions inherited from ServerResponse
static BaseClassProperties CreateBaseClassProperties (ResponseType type, const std::string &game_id)
 
static BaseClassProperties ExtractBaseClassProperties (const rapidjson::Value &json)
 
- Protected Attributes inherited from ServerResponse
std::string _game_id
 
ResponseType _type
 

Detailed Description

ServerResponse that communicates the full state of the game to all players after any update to the GameState.

Note: This class design is taken from https://gitlab.ethz.ch/hraymond/cse-lama-example-project. FullStateResponse is a derivative of ServerResponse. Due to static allocation, ServerResponse can call FullStateResponse's FromJson method. We think this is very bad design, but changing it would require a lot of refactoring so we decided to leave it as it is. Furthermore, **Process is only declared/defined for the client executable**. This means that this class definition differs between the client and the server executable. Again, we think this is bad design, but we decided to leave it as it is as trying to change it would require a lot of refactoring.

Constructor & Destructor Documentation

◆ FullStateResponse() [1/2]

FullStateResponse::FullStateResponse ( ServerResponse::BaseClassProperties  props,
rapidjson::Value state_json 
)
private

Creates a FullStateResponse defining all member vars with args using BaseClassProperties

◆ FullStateResponse() [2/2]

FullStateResponse::FullStateResponse ( std::string  game_id,
const GameState state 
)

Creates a FullStateResponse defining all member vars with args but wihtout using BaseClassProperties

◆ ~FullStateResponse()

FullStateResponse::~FullStateResponse ( )

Deletes dynamically allocated _state_json (if it exists).

Member Function Documentation

◆ FromJson()

FullStateResponse * FullStateResponse::FromJson ( const rapidjson::Value json)
static

Deserializes a FullStateResponse from the given json.

◆ GetStateJson()

rapidjson::Value * FullStateResponse::GetStateJson ( ) const

Returns the state of the game as a serialized json value.

◆ WriteIntoJson()

void FullStateResponse::WriteIntoJson ( rapidjson::Value json,
rapidjson::Document::AllocatorType &  allocator 
) const
overridevirtual

Serializes this FullStateResponse into the given json.

Implements Serializable.

Member Data Documentation

◆ _state_json

rapidjson::Value* FullStateResponse::_state_json {}
private

The state of the game as a serialized json value.


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