The Nebula Device 3: FSM::StateMachine Class Reference

The Nebula Device 3

FSM::StateMachine Class Reference

#include <statemachine.h>

Inheritance diagram for FSM::StateMachine:

Core::RefCounted

Detailed Description

Implements the state machine for the FSM subsystem.

Note: On first start the state "Start" will be started if available, otherwise the first in row.

(C) 2006 Radon Labs GmbH

Public Member Functions

 StateMachine ()
 constructor
virtual ~StateMachine ()
 destructor
void SetName (const Util::String &n)
 set the name of the state machine
const Util::StringGetName () const
 get name of state machine
void SetEntity (const Ptr< Game::Entity > &e)
 set pointer to entity which owns the state machine
const Ptr< Game::Entity > & GetEntity () const
 get pointer to entity
void AddState (const Ptr< State > &s)
 add a state to the state machine
Ptr< StateFindStateByName (const Util::String &n)
 find a state by name
void Open ()
 called when the state machine is initially opened
void Close ()
 called when the state machine is closed
bool IsOpen () const
 return true if currently open
bool Update ()
 update the state machine while open (called per-frame)
const Ptr< State > & GetCurrentState () const
 get current state
void Notify (const Ptr< Messaging::Message > &msg)
 notify state machine about a message
Util::String GetDebugTxt () const
 get current debug txt
Math::float4 GetDebugColor () const
 get debug color
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Member Function Documentation

void FSM::StateMachine::AddState ( const Ptr< State > &  s  ) 

add a state to the state machine

Add a state to the state machine.

Ptr< State > FSM::StateMachine::FindStateByName ( const Util::String n  ) 

find a state by name

Find a state by its name. Returns 0 if not found.

void FSM::StateMachine::Open (  ) 

called when the state machine is initially opened

Open the state machine. This will set the first state in the state array as active state.

void FSM::StateMachine::Close (  ) 

called when the state machine is closed

Close the state machine. This will unset the current state, so that it may cleanup itself properly.

bool FSM::StateMachine::Update (  ) 

update the state machine while open (called per-frame)

This updates the state machine, must be called frequently while the state machine is open.

const Ptr< State > & FSM::StateMachine::GetCurrentState (  )  const

get current state

Returns the current state.

void FSM::StateMachine::Notify ( const Ptr< Messaging::Message > &  msg  ) 

notify state machine about a message

This notifies the current state about a message.

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.