HoverRace  2.0
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
HoverRace::Player::Player Class Referenceabstract

Base class for connected players. More...

#include <Player.h>

+ Inheritance diagram for HoverRace::Player::Player:

Public Types

enum  ConnectionState { ConnectionState::DISCONNECTED, ConnectionState::CONNECTING, ConnectionState::CONNECTED, ConnectionState::DISCONNECTING }
 
using connectionStateChanged_t = boost::signals2::signal< void()>
 
using nameChangedSignal_t = boost::signals2::signal< void()>
 

Public Member Functions

 Player ()=delete
 
 Player (std::shared_ptr< Profile > profile, bool local, bool human, bool competing)
 Constructor. More...
 
virtual ~Player ()
 
void AttachMainCharacter (MainCharacter::MainCharacter *mainCharacter)
 Attach the main character (when joining a game session). More...
 
void DetachMainCharacter ()
 Detach the main character (when leaving a game session). More...
 
ConnectionState GetConnectionState () const
 
connectionStateChanged_tGetConnectionStateChangedSignal ()
 
MainCharacter::MainCharacterGetMainCharacter () const
 Retrieve the main character, if attached. More...
 
const std::string & GetName () const
 Retrieve the display name of the player. More...
 
nameChangedSignal_tGetNameChangedSignal ()
 
ProfileGetProfile () const
 
bool IsCompeting () const
 
bool IsHuman () const
 
bool IsLocal () const
 
void SetNameSuffix (const std::string &suffix)
 Sets the suffix on the display name. More...
 
std::shared_ptr< ProfileShareProfile () const
 
virtual std::ostream & StreamOut (std::ostream &os) const
 

Protected Member Functions

virtual void Disconnect ()=0
 
void SetConnectionState (ConnectionState state)
 

Private Attributes

bool competing
 
ConnectionState connectionState
 
connectionStateChanged_t connectionStateChangedSignal
 
bool human
 
bool local
 
MainCharacter::MainCharactermainCharacter
 
std::string name
 
nameChangedSignal_t nameChangedSignal
 
std::shared_ptr< Profileprofile
 

Detailed Description

Base class for connected players.

Author
Michael Imamura

Member Typedef Documentation

using HoverRace::Player::Player::connectionStateChanged_t = boost::signals2::signal<void()>
using HoverRace::Player::Player::nameChangedSignal_t = boost::signals2::signal<void()>

Member Enumeration Documentation

Enumerator
DISCONNECTED 
CONNECTING 
CONNECTED 
DISCONNECTING 

Constructor & Destructor Documentation

HoverRace::Player::Player::Player ( )
delete
HoverRace::Player::Player::Player ( std::shared_ptr< Profile profile,
bool  local,
bool  human,
bool  competing 
)

Constructor.

Parameters
profileThe profile.
localtrue if the player is controlled by the local client.
humantrue if the player is controlled by a human.
competingtrue if the player can compete in game sessions or false if the player can only spectate.
virtual HoverRace::Player::Player::~Player ( )
inlinevirtual

Member Function Documentation

void HoverRace::Player::Player::AttachMainCharacter ( MainCharacter::MainCharacter mainCharacter)
inline

Attach the main character (when joining a game session).

Parameters
mainCharacterThe main character (may be nullptr to detach).
void HoverRace::Player::Player::DetachMainCharacter ( )
inline

Detach the main character (when leaving a game session).

virtual void HoverRace::Player::Player::Disconnect ( )
protectedpure virtual
ConnectionState HoverRace::Player::Player::GetConnectionState ( ) const
inline
connectionStateChanged_t& HoverRace::Player::Player::GetConnectionStateChangedSignal ( )
inline
MainCharacter::MainCharacter* HoverRace::Player::Player::GetMainCharacter ( ) const
inline

Retrieve the main character, if attached.

Returns
The main character (may be nullptr if detached).
const std::string& HoverRace::Player::Player::GetName ( ) const
inline

Retrieve the display name of the player.

This is not necessarily the same name as the profile, although it is based on the profile name. In the case of multiple players with the same name, a suffix may be added to disambiguate them.

Returns
The display name.
See also
SetNameSuffix(const std::string&)
nameChangedSignal_t& HoverRace::Player::Player::GetNameChangedSignal ( )
inline
Profile* HoverRace::Player::Player::GetProfile ( ) const
inline
bool HoverRace::Player::Player::IsCompeting ( ) const
inline
bool HoverRace::Player::Player::IsHuman ( ) const
inline
bool HoverRace::Player::Player::IsLocal ( ) const
inline
void HoverRace::Player::Player::SetConnectionState ( Player::ConnectionState  state)
protected
void HoverRace::Player::Player::SetNameSuffix ( const std::string &  suffix)

Sets the suffix on the display name.

The suffix is used to disambiguate the player name when multiple players have the same name (e.g. they are sharing the same profile).

Parameters
suffixThe suffix (may be empty for no suffix).
std::shared_ptr<Profile> HoverRace::Player::Player::ShareProfile ( ) const
inline
std::ostream & HoverRace::Player::Player::StreamOut ( std::ostream &  os) const
virtual

Member Data Documentation

bool HoverRace::Player::Player::competing
private
ConnectionState HoverRace::Player::Player::connectionState
private
connectionStateChanged_t HoverRace::Player::Player::connectionStateChangedSignal
private
bool HoverRace::Player::Player::human
private
bool HoverRace::Player::Player::local
private
MainCharacter::MainCharacter* HoverRace::Player::Player::mainCharacter
private
std::string HoverRace::Player::Player::name
private
nameChangedSignal_t HoverRace::Player::Player::nameChangedSignal
private
std::shared_ptr<Profile> HoverRace::Player::Player::profile
private

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