nomlib
Loading...
Searching...
No Matches
nom::IState Class Reference

Abstract interface for game states. More...

#include <IState.hpp>

Public Types

enum  Flags { BackUpdate = 0x2 , BackRender = 0x4 }
 Specialized control over state management. More...
enum  Type { Parent = 0 , Child }
 State type enumeration. More...
typedef std::unique_ptr< IStateunique_ptr

Public Member Functions

 IState (void)
 Default constructor; initializes class variables to zero.
virtual ~IState (void)
 Destructor; declared virtual for inheritance.
 IState (uint32 id)
 Constructor for user-defined initialization of the class variable fields.
 IState (uint32 id, uint32 flags, IState::Type type)
 Constructor for user-defined initialization of the class variable fields.
uint32 id (void) const
 Obtain the user-defined identifier of the state.
uint32 timestamp (void) const
 Obtain the recorded time stamp of the state.
uint32 flags (void) const
 Obtain the user-defined flags of the state.
IState::Type type (void) const
 Get the type of state.
virtual bool on_event (const nom::Event &ev)
 User-defined implementation of the state's event handling logic.
virtual void on_update (float)
 User-defined implementation of the state's update logic.
virtual void on_draw (RenderWindow &)
virtual void on_init (void_ptr)
 User-defined implementation of the state's initialization logic.
virtual void on_exit (void_ptr)
 User-defined implementation of the state's destruction logic.
virtual void on_pause (void_ptr)
 User-defined implementation of the state's paused state logic.
virtual void on_resume (void_ptr)
 User-defined implementation of the state's resume from pause state logic.

Private Attributes

uint32 id_
 Unique identifier for the state.
uint32 timestamp_
 Number of ticks recorded at the time of state's construction.
uint32 flags_
 Specialized state management.
Type type_
 The type of state.

Detailed Description

Abstract interface for game states.

Remarks
See also nom::StateMachine, nom::SDLApp

Definition at line 43 of file IState.hpp.

Member Typedef Documentation

◆ unique_ptr

typedef std::unique_ptr<IState> nom::IState::unique_ptr

Definition at line 46 of file IState.hpp.

Member Enumeration Documentation

◆ Flags

Specialized control over state management.

Remarks
Multiple flags can be combined via bit masks.
Enumerator
BackUpdate 

Request to nom::StateMachine to let previous state continue updating itself.

BackRender 

Request to nom::StateMachine to let previous state continue rendering itself.

Definition at line 51 of file IState.hpp.

◆ Type

State type enumeration.

Remarks
The type of state defines the placement of it on the stack.
Enumerator
Parent 

Top-level / top-most placement on the stack.

Definition at line 65 of file IState.hpp.

Constructor & Destructor Documentation

◆ IState() [1/2]

nom::IState::IState ( uint32 id)

Constructor for user-defined initialization of the class variable fields.

Parameters
idUnique identifier of the state

◆ IState() [2/2]

nom::IState::IState ( uint32 id,
uint32 flags,
IState::Type type )

Constructor for user-defined initialization of the class variable fields.

Parameters
idUnique identifier of the state
flagsOne or more of the nom::IState::StateFlags enumerations.
typeThe type of state; one of the IState::Type enumeration values.

Member Function Documentation

◆ flags()

uint32 nom::IState::flags ( void ) const

Obtain the user-defined flags of the state.

Returns
Bit masked enumeration of nom::IState::StateFlags.
Remarks
It is not required that the state has any flags set.

◆ id()

uint32 nom::IState::id ( void ) const

Obtain the user-defined identifier of the state.

Returns
ID of the state
Remarks
It is not required that the state has an identifier set.

◆ on_draw()

virtual void nom::IState::on_draw ( RenderWindow & )
virtual

User-defined implementation of the state's rendering logic

Parameters
IDrawable::RenderTargetRendering target (nom::RenderWindow).
Remarks
When not defined, a do-nothing implementation is provided.
Todo
Consider removing RenderTarget argument; I think we can get away with this.

◆ on_event()

virtual bool nom::IState::on_event ( const nom::Event & ev)
virtual

User-defined implementation of the state's event handling logic.

Parameters
evThe passed nom::Event object.
Returns
This method should return Boolean TRUE when the nom::Event object has been processed (think: consumed) by the user-implemented method, and boolean FALSE when the nom::Event object has not been processed (think: consumed). The default implementation returns false.
See also
StateMachine::on_event

◆ on_exit()

virtual void nom::IState::on_exit ( void_ptr )
virtual

User-defined implementation of the state's destruction logic.

Parameters
void_ptrA void pointer to user-defined data
Remarks
When not defined, a do-nothing implementation is provided.

◆ on_init()

virtual void nom::IState::on_init ( void_ptr )
virtual

User-defined implementation of the state's initialization logic.

Parameters
void_ptrA void pointer to user-defined data
Remarks
When not defined, a do-nothing implementation is provided.

◆ on_pause()

virtual void nom::IState::on_pause ( void_ptr )
virtual

User-defined implementation of the state's paused state logic.

Parameters
void_ptrA void pointer to user-defined data
Remarks
When not defined, a do-nothing implementation is provided.

◆ on_resume()

virtual void nom::IState::on_resume ( void_ptr )
virtual

User-defined implementation of the state's resume from pause state logic.

Parameters
void_ptrA void pointer to user-defined data
Remarks
When not defined, a do-nothing implementation is provided.

◆ on_update()

virtual void nom::IState::on_update ( float )
virtual

User-defined implementation of the state's update logic.

Parameters
floatUser-defined; typically a delta time (change in time).
Remarks
When not defined, a do-nothing implementation is provided.

◆ timestamp()

uint32 nom::IState::timestamp ( void ) const

Obtain the recorded time stamp of the state.

Returns
Number of ticks recorded at the time of construction
Remarks
Value recorded is from the return value of nom::ticks

◆ type()

IState::Type nom::IState::type ( void ) const

Get the type of state.

Returns
One of the IState::Type enumeration values.

Member Data Documentation

◆ flags_

uint32 nom::IState::flags_
private

Specialized state management.

Definition at line 185 of file IState.hpp.

◆ id_

uint32 nom::IState::id_
private

Unique identifier for the state.

Definition at line 179 of file IState.hpp.

◆ timestamp_

uint32 nom::IState::timestamp_
private

Number of ticks recorded at the time of state's construction.

Definition at line 182 of file IState.hpp.

◆ type_

Type nom::IState::type_
private

The type of state.

Definition at line 188 of file IState.hpp.


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