BaseAccess

Provides read/write access to Data-derived classes.  The BaseAccess class allows for derived classes to access the internal data fields of the main data classes that make up a game and board: Game, PlayerGame, and TileObject.  By using a common base class that abstracts the access, it is possible to totally encapsulate the data from the View, so that the View has not even the slightest possibility of write-access to the main game data.  Only classes derived from BaseAccess (such as Rule, AIRule, Logic, and AILogic) are able to alter the game data.

Project

RulesCore

Include

BaseAccess.h

Summary
Provides read/write access to Data-derived classes.
The BaseAccess destructor.
Returns the number of players in the Game.
Returns the number of tiles on the board in the Game.
Returns the index in the Game’s array of PlayerGames of the current player.
Returns the PlayerGame data of the player at the given player index.
Returns the std::vector of PlayerGames data of all players in the game.
Returns the data field at the given key within the Data of the Game.
Returns the data field at the given key within the Data of the PlayerGame for the given player index.
Returns the data field for the given key within the Data of the TileObject at the given tile index.
Returns the TileObject at the given index.
Erases the given key from the Game data.
Returns the current Game object the BaseAccess is using.

Protected

Summary
The BaseAccess destructor.
Returns the number of players in the Game.
Returns the number of tiles on the board in the Game.
Returns the index in the Game’s array of PlayerGames of the current player.
Returns the PlayerGame data of the player at the given player index.
Returns the std::vector of PlayerGames data of all players in the game.
Returns the data field at the given key within the Data of the Game.
Returns the data field at the given key within the Data of the PlayerGame for the given player index.
Returns the data field for the given key within the Data of the TileObject at the given tile index.
Returns the TileObject at the given index.
Erases the given key from the Game data.
Returns the current Game object the BaseAccess is using.

Destructor

BaseAccess

virtual ~BaseAccess()=0

The BaseAccess destructor.  It is pure virtual because this class must be derived from to be used.

Functions

numPlayers

wxInt32 numPlayers() const

Returns the number of players in the Game.

Returns

The number of players in the Game.

numTiles

wxInt32 numTiles() const

Returns the number of tiles on the board in the Game.

Returns

The number of tiles on the board in the Game.

current

wxInt32 current() const

Returns the index in the Game’s array of PlayerGames of the current player.

Returns

The index of the current player.

playerGame

PlayerGame &playerGame(wxInt32 player = -1)

Returns the PlayerGame data of the player at the given player index.  If the index is -1, the data for the current player is returned.

Parameters

playerThe index of the player to retrieve.  If -1, the current player index is used.

Returns

A reference to the PlayerGame data for the player at that index.

playerGames

Game::PlayerGameArray &playerGames()

Returns the std::vector of PlayerGames data of all players in the game.

Returns

A reference to the std::vector of PlayerGame data stored in the Game.

game

template <typename T> T& game(const wxString &key)

Returns the data field at the given key within the Data of the Game.  Because it is returned as a reference, the data can be read from or written to.

NOTE: The function calls the data<> member function of the Data class with no safety, meaning that if the given key does not exist, it will be created by this call to it.

Parameters

keyThe hash key of the field in the Data class.

Returns

A reference to the data itself.  It may be read to or written from.

player

template <typename T> T& player(const wxString &key, 
wxInt32 player = -1)

Returns the data field at the given key within the Data of the PlayerGame for the given player index.  If the index is -1, the data for the current player is used.  Because it is returned as a reference, the data can be read from or written to.  The player function is a shortcut for direct access to a player’s data within the Game.

NOTE: The function calls the data<> member function of the Data class with no safety, meaning that if the given key does not exist, it will be created by this call to it.

Parameters

keyThe hash key of the field in the Data class.
playerThe index of the player to retrieve.  If -1, the current player index is used.

Returns

A reference to the data itself.  It may be read to or written from.

tile

template <typename T> T& tile(const wxString &key,
const wxInt32 tile)

Returns the data field for the given key within the Data of the TileObject at the given tile index.  Because it is returned as a reference, the data can be read from or written to.  The tile function is a shortcut for direct access to a TileObject’s data within the Game.

Parameters

keyThe hash key of the field in the Data class.
tileThe index of the tile to retrieve.

Returns

A reference to the data itself.  It may be read to or written from.

tile

TileObjectPtr &tile(const wxInt32 tile)

Returns the TileObject at the given index.

Parameters

tileThe index of the tile to retrieve.

Returns

A reference to the TileObject.

erase

template <typename T> void erase(const wxString &key)

Erases the given key from the Game data.

Parameters

keyThe key to erase.

Pure Virtual Functions

GetGame

virtual GamePtr &GetGame() const=0

Returns the current Game object the BaseAccess is using.

Stores data of many different kinds in string-based hash maps.
virtual ~BaseAccess()=0
The BaseAccess destructor.
wxInt32 numPlayers() const
Returns the number of players in the Game.
Still volatile.
wxInt32 numTiles() const
Returns the number of tiles on the board in the Game.
wxInt32 current() const
Returns the index in the Game’s array of PlayerGames of the current player.
Still volatile.
PlayerGame &playerGame(wxInt32 player = -1)
Returns the PlayerGame data of the player at the given player index.
Game::PlayerGameArray &playerGames()
Returns the std::vector of PlayerGames data of all players in the game.
template <typename T> T& game(const wxString &key)
Returns the data field at the given key within the Data of the Game.
template <typename T> T& player(const wxString &key, 
wxInt32 player = -1)
Returns the data field at the given key within the Data of the PlayerGame for the given player index.
template <typename T> T& tile(const wxString &key,
const wxInt32 tile)
Returns the data field for the given key within the Data of the TileObject at the given tile index.
Represents one hexagonally-shaped tile on the board.
template <typename T> void erase(const wxString &key)
Erases the given key from the Game data.
virtual GamePtr &GetGame() const=0
Returns the current Game object the BaseAccess is using.
The default implementation of IRule for normal Game actions.
Still volatile.
The default implementation of ILogic for normal Game actions.
Still volatile.
RulesCore is the HOSS of Cities3D.