orxonox::GameState Class Reference

An implementation of a tree to manage game states. This leads to a certain hierarchy that is created at runtime. To actually use the structure, you will have to derive from it and implement 'enter', 'leave' and 'tick'. The latter corresponds to an update function. More...

#include <src/core/GameState.h>

Inheritance diagram for orxonox::GameState:

orxonox::GSClient orxonox::GSDedicated orxonox::GSGraphics orxonox::GSIOConsole orxonox::GSLevel orxonox::GSMainMenu orxonox::GSRoot orxonox::GSServer orxonox::GSStandalone

List of all members.

Public Member Functions

void addChild (GameState *state)
 Adds a child to the current tree. The Child can contain children of its own. But you cannot a state tree that already has an active state.
 GameState (const GameStateConstrParams &params)
 Constructor only initialises variables and sets the name permanently.
State getActivity () const
const std::stringgetName () const
GameStategetParent () const
bool ignoreTickTime () const
void removeChild (GameState *state)
 Removes a child by instance. This splits the tree in two parts, each of them functional on its own.
virtual ~GameState ()
 Destructor only checks that we don't delete an active state.

Protected Member Functions

virtual void activate ()
virtual void deactivate ()
virtual void update (const Clock &time)

Private Member Functions

void activateInternal ()
void deactivateInternal ()
void setActivity (State activity)
void setParent (GameState *state)
void updateInternal (const Clock &time)

Private Attributes

State activity_
const bool bIgnoreTickTime_
std::map< std::string,
GameState * > 
children_
const std::string name_
GameStateparent_

Friends

class Game

Classes

struct  State
 Gives information about what the GameState is currently doing. More...


Detailed Description

An implementation of a tree to manage game states. This leads to a certain hierarchy that is created at runtime. To actually use the structure, you will have to derive from it and implement 'enter', 'leave' and 'tick'. The latter corresponds to an update function.

Internally the tree is managed by two maps per node: One stores all its children, grandchildren, etc. by name of the state. The other maps these children states to the actual child of the node. An example: Foo is a grandchildren of Bar and Foofoo is the Foo's parent. Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.


Constructor & Destructor Documentation

orxonox::GameState::GameState ( const GameStateConstrParams params  ) 

orxonox::GameState::~GameState (  )  [virtual]

Destructor only checks that we don't delete an active state.

References orxonox::GameState::State::active, activity_, and OrxAssert.


Member Function Documentation

virtual void orxonox::GameState::activate (  )  [inline, protected, virtual]

void orxonox::GameState::activateInternal (  )  [private]

void orxonox::GameState::addChild ( GameState state  ) 

Adds a child to the current tree. The Child can contain children of its own. But you cannot a state tree that already has an active state.

Parameters:
state The state to be added.

References children_, getName(), setParent(), and ThrowException.

virtual void orxonox::GameState::deactivate (  )  [inline, protected, virtual]

void orxonox::GameState::deactivateInternal (  )  [private]

State orxonox::GameState::getActivity (  )  const [inline]

const std::string& orxonox::GameState::getName (  )  const [inline]

GameState* orxonox::GameState::getParent (  )  const [inline]

bool orxonox::GameState::ignoreTickTime (  )  const [inline]

void orxonox::GameState::removeChild ( GameState state  ) 

Removes a child by instance. This splits the tree in two parts, each of them functional on its own.

Parameters:
state GameState by instance pointer

References children_, getName(), name_, and ThrowException.

void orxonox::GameState::setActivity ( State  activity  )  [private]

void orxonox::GameState::setParent ( GameState state  )  [inline, private]

Referenced by addChild().

virtual void orxonox::GameState::update ( const Clock time  )  [inline, protected, virtual]

void orxonox::GameState::updateInternal ( const Clock time  )  [private]


Friends And Related Function Documentation

friend class Game [friend]


Member Data Documentation

Referenced by removeChild().


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

Generated on Tue Jul 28 16:22:31 2009 for Orxonox by  doxygen 1.5.6