VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtPlayerStationStateManager Class Reference

Detailed Description

DtPlayerStationStateManager provides a robust state management system for VR-Engage. It maintains a stack of states and handles transitions between them in a controlled manner. State operations are queued and processed during the tick cycle to ensure proper ordering and prevent state inconsistencies.

#include <playerStationStateManager.h>

Public Types

enum  DtStackOp {
  NO_OP , OP_PUSH , OP_TRANSITION , OP_POP ,
  OP_POP_UNTIL
}
 
using DtStateList = std::list<DtPlayerStationState*>
 
using DtRegisteredStates = std::map<std::string, DtPlayerStationState*>
 
using DtQueuedOp = std::tuple<DtStackOp, std::string, std::shared_ptr<DtPlayerStationStateArgs>>
 
using DtStackOpQueue = std::deque<DtQueuedOp>
 

Public Member Functions

 DtPlayerStationStateManager (const DtPlayerStationStateManager &)=delete
 
DtPlayerStationStateManageroperator= (const DtPlayerStationStateManager &)=delete
 
virtual void registerState (DtPlayerStationState *state)
 
virtual void tick (double dt)
 
virtual void push (const std::string &state, DtPlayerStationStateArgs *args=NULL)
 
virtual void transition (const std::string &state, DtPlayerStationStateArgs *args=NULL)
 
virtual void pop ()
 
virtual void popUntil (const std::string &state, DtPlayerStationStateArgs *args=NULL)
 
DtPlayerStationStategetState (const std::string &state)
 
virtual DtPlayerStationStatecurrentState ()
 
virtual bool containsStateType (const std::string &state)
 
int findStackPos (const std::string &state)
 
const void debugDumpDeque ()
 
virtual void debugCallback ()
 

Protected Member Functions

 DtPlayerStationStateManager (DtPlayerStationApp &app)
 
virtual ~DtPlayerStationStateManager ()
 
void doTransition (const std::string &toState, const DtPlayerStationStateArgs *args)
 
void doPop (const DtPlayerStationStateArgs *args=NULL)
 
void doPush (const std::string &newState, const DtPlayerStationStateArgs *args)
 
void doPopUntil (const std::string &exposeState, const DtPlayerStationStateArgs *args)
 
bool isRegistered (const std::string &state)
 

Protected Attributes

DtStateList myStateStack
 
DtRegisteredStates myRegisteredStates
 
DtPlayerStationAppmyApp
 
DtStackOpQueue myStackOpQueue
 

Friends

class DtPlayerStationApp
 
class DtVreDebugManager
 

Member Typedef Documentation

◆ DtStateList

Type definition for the state stack.

◆ DtRegisteredStates

Type definition for the map of registered states.

◆ DtQueuedOp

using makVre::DtPlayerStationStateManager::DtQueuedOp = std::tuple<DtStackOp, std::string, std::shared_ptr<DtPlayerStationStateArgs>>

Type definition for a queued state operation Contains operation type, state name, and arguments.

◆ DtStackOpQueue

Type definition for the queue of state operations.

Member Enumeration Documentation

◆ DtStackOp

Enumeration of possible stack operations.

Enumerator
NO_OP 

No operation.

OP_PUSH 

Push a new state onto the stack.

OP_TRANSITION 

Replace the current state.

OP_POP 

Pop the top state from the stack.

OP_POP_UNTIL 

Pop states until a specific state is at the top.

Constructor & Destructor Documentation

◆ DtPlayerStationStateManager() [1/2]

makVre::DtPlayerStationStateManager::DtPlayerStationStateManager ( const DtPlayerStationStateManager & )
delete

Deleted copy constructor.

Prevents copying of the state manager instance

References DtPlayerStationStateManager().

Referenced by DtPlayerStationStateManager(), and operator=().

◆ DtPlayerStationStateManager() [2/2]

makVre::DtPlayerStationStateManager::DtPlayerStationStateManager ( DtPlayerStationApp & app)
protected

Constructor.

Parameters
appReference to the player station application

Initializes the state manager with a reference to the app. Constructor is protected to ensure only DtPlayerStationApp can create instances.

References DtPlayerStationApp.

◆ ~DtPlayerStationStateManager()

virtual makVre::DtPlayerStationStateManager::~DtPlayerStationStateManager ( )
protectedvirtual

Virtual destructor.

Cleans up any remaining states and resources

Member Function Documentation

◆ operator=()

DtPlayerStationStateManager & makVre::DtPlayerStationStateManager::operator= ( const DtPlayerStationStateManager & )
delete

Deleted assignment operator.

Prevents assignment of the state manager instance

References DtPlayerStationStateManager().

◆ registerState()

virtual void makVre::DtPlayerStationStateManager::registerState ( DtPlayerStationState * state)
virtual

Registers a new state with the manager.

Parameters
statePointer to the state to register

Adds a state to the internal map of registered states, making it available for transitions. The state name is used as the key.

◆ tick()

virtual void makVre::DtPlayerStationStateManager::tick ( double dt)
virtual

Main tick function called from the player station tick.

Parameters
dtDelta time since the last tick in seconds

Processes any queued state operations and calls the tick method of the current active state. State operations are processed in the order they were queued.

◆ push()

virtual void makVre::DtPlayerStationStateManager::push ( const std::string & state,
DtPlayerStationStateArgs * args = NULL )
virtual

Queues a state to push onto the stack.

Parameters
stateName of the state to push
argsOptional arguments to pass to the state

The pushed state becomes the new active state, but the previous state remains on the stack. When the new state is later popped, the previous state will become active again.

◆ transition()

virtual void makVre::DtPlayerStationStateManager::transition ( const std::string & state,
DtPlayerStationStateArgs * args = NULL )
virtual

Queues a state to transition from the current active state.

Parameters
stateName of the state to transition to
argsOptional arguments to pass to the new state

Replaces the current active state with the new state. The previous state is removed from the stack and its exit method is called.

◆ pop()

virtual void makVre::DtPlayerStationStateManager::pop ( )
virtual

Queues an operation to pop the active state off the stack.

Removes the current active state from the stack and makes the state below it the new active state. If there is no state below, the stack will be empty after this operation.

◆ popUntil()

virtual void makVre::DtPlayerStationStateManager::popUntil ( const std::string & state,
DtPlayerStationStateArgs * args = NULL )
virtual

Queues an operation to pop states until a specific state is exposed.

Parameters
stateName of the state to expose
argsOptional arguments to pass to the exposed state

Pops states from the stack until the specified state becomes the active state. If the state is not in the stack, this will result in an empty stack.

◆ getState()

DtPlayerStationState * makVre::DtPlayerStationStateManager::getState ( const std::string & state)

Gets a state by its name.

Parameters
stateName of the state to retrieve
Returns
Pointer to the state, or NULL if not found

Looks up a registered state by its name and returns a pointer to it. Returns NULL if the state is not registered.

◆ currentState()

virtual DtPlayerStationState * makVre::DtPlayerStationStateManager::currentState ( )
virtual

Gets the currently active state.

Returns
Pointer to the current active state, or NULL if no state is active

Returns the state at the top of the stack, which is the currently active state. Returns NULL if the stack is empty.

◆ containsStateType()

virtual bool makVre::DtPlayerStationStateManager::containsStateType ( const std::string & state)
virtual

Checks if a specific state type is in the stack.

Parameters
stateName of the state to check for
Returns
True if the state is in the stack, false otherwise

Searches the state stack for a state with the specified name. Returns true if found, false otherwise.

◆ findStackPos()

int makVre::DtPlayerStationStateManager::findStackPos ( const std::string & state)

Finds the position of a state in the stack.

Parameters
stateName of the state to find
Returns
Zero-based position in the stack, or -1 if not found

Searches for a state in the stack and returns its position. Position 0 is the bottom of the stack, with higher indices moving toward the top. Returns -1 if the state is not in the stack.

◆ debugDumpDeque()

const void makVre::DtPlayerStationStateManager::debugDumpDeque ( )

Dumps the contents of the operation queue for debugging.

Outputs the current contents of the operation queue to the debug log, showing each pending operation and its associated state and arguments.

◆ debugCallback()

virtual void makVre::DtPlayerStationStateManager::debugCallback ( )
virtual

Debug callback function.

Called during debugging to allow inspection of the state manager

◆ doTransition()

void makVre::DtPlayerStationStateManager::doTransition ( const std::string & toState,
const DtPlayerStationStateArgs * args )
protected

Performs a state transition operation.

Parameters
toStateName of the state to transition to
argsPointer to arguments for the new state

Internal implementation for transitioning from the current state to a new state. Calls exit on the old state and enter on the new state.

◆ doPop()

void makVre::DtPlayerStationStateManager::doPop ( const DtPlayerStationStateArgs * args = NULL)
protected

Performs a pop operation on the state stack.

Parameters
argsOptional arguments to pass to the newly exposed state

Internal implementation for popping the top state off the stack. Calls exit on the popped state and resume on the newly exposed state.

◆ doPush()

void makVre::DtPlayerStationStateManager::doPush ( const std::string & newState,
const DtPlayerStationStateArgs * args )
protected

Performs a push operation on the state stack.

Parameters
newStateName of the state to push
argsPointer to arguments for the new state

Internal implementation for pushing a new state onto the stack. Calls pause on the current state and enter on the new state.

◆ doPopUntil()

void makVre::DtPlayerStationStateManager::doPopUntil ( const std::string & exposeState,
const DtPlayerStationStateArgs * args )
protected

Performs a popUntil operation on the state stack.

Parameters
exposeStateName of the state to expose
argsPointer to arguments for the exposed state

Internal implementation for popping states until a specific state is exposed. Calls exit on all popped states and resume on the newly exposed state.

◆ isRegistered()

bool makVre::DtPlayerStationStateManager::isRegistered ( const std::string & state)
protected

Checks if a state is registered.

Parameters
stateName of the state to check
Returns
True if the state is registered, false otherwise

Internal function that verifies if a state with the given name is registered in the state manager.

Friends And Related Symbol Documentation

◆ DtPlayerStationApp

friend class DtPlayerStationApp
friend

◆ DtVreDebugManager

friend class DtVreDebugManager
friend

References DtVreDebugManager.

Referenced by DtVreDebugManager.

Member Data Documentation

◆ myStateStack

DtStateList makVre::DtPlayerStationStateManager::myStateStack
protected

The state stack.

Contains the currently active states with the most recent at the front

◆ myRegisteredStates

DtRegisteredStates makVre::DtPlayerStationStateManager::myRegisteredStates
protected

Map of all registered states.

Maps state names to their corresponding state objects

◆ myApp

DtPlayerStationApp& makVre::DtPlayerStationStateManager::myApp
protected

Reference to the player station application.

Provides access to the application for states that need it

◆ myStackOpQueue

DtStackOpQueue makVre::DtPlayerStationStateManager::myStackOpQueue
protected

Queue of pending state operations.

Contains operations to be processed during the next tick, each with an operation type, state name, and arguments


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