Orxonox  0.0.5 Codename: Arcturus
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::Game Class Reference

Main class responsible for running the game. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/Game.h>

Inheritance diagram for orxonox::Game:
orxonox::Singleton< Game >

Classes

class  GameStateFactory
 
struct  StatisticsTickInfo
 
class  TemplateGameStateFactory
 

Public Member Functions

 Game (const std::string &cmdLine)
 
 ~Game ()=default
 Leave empty and use cleanup() instead. More...
 
void destroy ()
 Destructor that also executes when object fails to construct. More...
 
float getAvgFPS ()
 
float getAvgTickTime ()
 
const ClockgetGameClock ()
 
std::shared_ptr< GameStategetState (const std::string &name)
 
void popState ()
 
void requestState (const std::string &name)
 
void requestStates (const std::string &names)
 
void run ()
 Main loop of the orxonox game. More...
 
void setStateHierarchy (const std::string &str)
 
void stop ()
 
void subtractTickTime (int32_t length)
 

Static Public Member Functions

template<class T >
static bool declareGameState (const std::string &className, const std::string &stateName, bool bIgnoreTickTime, bool bConsoleMode)
 
static GamegetInstance ()
 
- Static Public Member Functions inherited from orxonox::Singleton< Game >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static GamegetInstance ()
 Returns a reference to the singleton instance. More...
 

Private Types

typedef std::map< std::string, std::shared_ptr< GameState > > GameStateMap
 
typedef std::shared_ptr< GameStateTreeNodeGameStateTreeNodePtr
 
typedef std::vector< std::shared_ptr< GameState > > GameStateVector
 

Private Member Functions

 Game (const Game &)=delete
 
bool checkState (const std::string &name) const
 
void loadGraphics ()
 
void loadState (const std::string &name)
 
Gameoperator= (const Game &)=delete
 
void parseStates (std::vector< std::pair< std::string, int >>::const_iterator &it, std::shared_ptr< GameStateTreeNode > currentNode)
 
void resetChangingState ()
 
void unloadGraphics (bool loadGraphicsManagerWithoutRenderer=true)
 
void unloadState (const std::string &name)
 
void updateFPSLimiter ()
 
void updateGameStates ()
 
void updateGameStateStack ()
 
void updateStatistics ()
 

Private Attributes

float avgFPS_
 
float avgTickTime_
 
bool bAbort_
 
bool bChangingState_
 
GameConfigconfig_
 Helper object that stores the config values. More...
 
GameStateMap constructedStates_
 
Corecore_
 
DestructionHelper< GamedestructionHelper_
 Helper object that executes the surrogate destructor destroy() More...
 
int excessSleepTime_
 
ClockgameClock_
 
GameStateVector loadedStates_
 
GameStateTreeNodePtr loadedTopStateNode_
 
unsigned int minimumSleepTime_
 
uint32_t periodTickTime_
 
uint32_t periodTime_
 
std::vector< GameStateTreeNodePtrrequestedStateNodes_
 
GameStateTreeNodePtr rootStateNode_
 
uint64_t statisticsStartTime_
 
std::list< StatisticsTickInfostatisticsTickTimes_
 

Static Private Attributes

static std::map< std::string, GameStateInfogameStateDeclarations_s
 
static GamesingletonPtr_s = nullptr
 Pointer to the Singleton. More...
 

Friends

class Singleton< Game >
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::Singleton< Game >
 Singleton ()
 Constructor sets the singleton instance pointer. More...
 
virtual ~Singleton ()
 Destructor resets the singleton instance pointer. More...
 

Detailed Description

Main class responsible for running the game.

Remarks
You should only create this singleton once because it owns the Core class! (see remark there)

Member Typedef Documentation

typedef std::map<std::string, std::shared_ptr<GameState> > orxonox::Game::GameStateMap
private
typedef std::shared_ptr<GameStateTreeNode> orxonox::Game::GameStateTreeNodePtr
private
typedef std::vector<std::shared_ptr<GameState> > orxonox::Game::GameStateVector
private

Constructor & Destructor Documentation

orxonox::Game::Game ( const std::string &  cmdLine)
orxonox::Game::~Game ( )
default

Leave empty and use cleanup() instead.

orxonox::Game::Game ( const Game )
privatedelete

Member Function Documentation

bool orxonox::Game::checkState ( const std::string &  name) const
private
template<class T >
bool orxonox::Game::declareGameState ( const std::string &  className,
const std::string &  stateName,
bool  bIgnoreTickTime,
bool  bConsoleMode 
)
static
void orxonox::Game::destroy ( )

Destructor that also executes when object fails to construct.

float orxonox::Game::getAvgFPS ( )
inline
float orxonox::Game::getAvgTickTime ( )
inline
const Clock& orxonox::Game::getGameClock ( )
inline
static Game& orxonox::Game::getInstance ( )
inlinestatic
std::shared_ptr< GameState > orxonox::Game::getState ( const std::string &  name)
void orxonox::Game::loadGraphics ( )
private
void orxonox::Game::loadState ( const std::string &  name)
private
Game& orxonox::Game::operator= ( const Game )
privatedelete
void orxonox::Game::parseStates ( std::vector< std::pair< std::string, int >>::const_iterator &  it,
std::shared_ptr< GameStateTreeNode currentNode 
)
private
void orxonox::Game::popState ( )
void orxonox::Game::requestState ( const std::string &  name)
void orxonox::Game::requestStates ( const std::string &  names)
void orxonox::Game::resetChangingState ( )
inlineprivate
void orxonox::Game::run ( )

Main loop of the orxonox game.

Note
We use the Ogre::Timer to measure time since it uses the most precise method an any platform (however the windows timer lacks time when under heavy kernel load!).
void orxonox::Game::setStateHierarchy ( const std::string &  str)
void orxonox::Game::stop ( )
void orxonox::Game::subtractTickTime ( int32_t  length)
void orxonox::Game::unloadGraphics ( bool  loadGraphicsManagerWithoutRenderer = true)
private
void orxonox::Game::unloadState ( const std::string &  name)
private
void orxonox::Game::updateFPSLimiter ( )
private
void orxonox::Game::updateGameStates ( )
private
void orxonox::Game::updateGameStateStack ( )
private
void orxonox::Game::updateStatistics ( )
private

Friends And Related Function Documentation

friend class Singleton< Game >
friend

Member Data Documentation

float orxonox::Game::avgFPS_
private
float orxonox::Game::avgTickTime_
private
bool orxonox::Game::bAbort_
private
bool orxonox::Game::bChangingState_
private
GameConfig* orxonox::Game::config_
private

Helper object that stores the config values.

GameStateMap orxonox::Game::constructedStates_
private
Core* orxonox::Game::core_
private
DestructionHelper<Game> orxonox::Game::destructionHelper_
private

Helper object that executes the surrogate destructor destroy()

int orxonox::Game::excessSleepTime_
private
Clock* orxonox::Game::gameClock_
private
std::map< std::string, GameStateInfo > orxonox::Game::gameStateDeclarations_s
staticprivate
GameStateVector orxonox::Game::loadedStates_
private
GameStateTreeNodePtr orxonox::Game::loadedTopStateNode_
private
unsigned int orxonox::Game::minimumSleepTime_
private
uint32_t orxonox::Game::periodTickTime_
private
uint32_t orxonox::Game::periodTime_
private
std::vector<GameStateTreeNodePtr> orxonox::Game::requestedStateNodes_
private
GameStateTreeNodePtr orxonox::Game::rootStateNode_
private
Game * orxonox::Game::singletonPtr_s = nullptr
staticprivate

Pointer to the Singleton.

uint64_t orxonox::Game::statisticsStartTime_
private
std::list<StatisticsTickInfo> orxonox::Game::statisticsTickTimes_
private

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