StateMachine.h#
The StateMachine controlling the PowerVR Shell.
Includes#
PVRShell/OS/ShellOS.h
Included By#
Namespaces#
Classes#
Functions#
Source Code#
#pragma once
#include "PVRShell/OS/ShellOS.h"
namespace pvr {
namespace platform {
class Shell;
class StateMachine : public ShellOS
{
public:
enum NewState
{
StateUninitialised, // Initial State
//--v Init --^ Exit
StateInitialised, // Initialised. Need to initalise App.
//--v InitApplication --^ QuitApplication
StateAppInitialised, // Initialised. Need to initalise App.
//--v InitWindow --^ ReleaseWindow
StateWindowInitialised,
//--v InitView --^ ReleaseView
StateReady,
};
public:
StateMachine(OSApplication instance, platform::CommandLineParser& commandLine, OSDATA osdata);
~StateMachine();
Result init();
Result execute();
Result executeNext();
Result executeTo(NewState state);
Result executeUpTo(NewState state);
Result executeDownTo(NewState state);
NewState getState() const { return _currentState; }
bool isPaused() const { return _pause; }
void pause() { _pause = true; }
void resume() { _pause = false; }
private:
Result executeInitApplication();
Result executeQuitApplication();
Result executeInitWindow();
Result executeReleaseWindow();
Result executeInitView();
Result executeReleaseView();
Result executeFrame();
Result executeUp();
Result executeDown();
void preExit();
void applyCommandLine();
void readApiFromCommandLine();
NewState _currentState;
bool _pause;
};
inline std::string to_string(StateMachine::NewState state)
{
static const std::string STATE_MACHINE_UNINITIALISED("STATE_MACHINE_UNINITIALISED");
static const std::string STATE_MACHINE_INITIALISED("STATE_MACHINE_INITIALISED");
static const std::string APP_INITIALISED("APP_INITIALISED");
static const std::string WINDOW_INITIALISED("WINDOW_INITIALISED");
static const std::string READY("READY");
static const std::string UNKNOWN("UNKNOWN");
switch (state)
{
case StateMachine::StateUninitialised: return STATE_MACHINE_UNINITIALISED;
case StateMachine::StateInitialised: return STATE_MACHINE_INITIALISED;
case StateMachine::StateAppInitialised: return APP_INITIALISED;
case StateMachine::StateWindowInitialised: return WINDOW_INITIALISED;
case StateMachine::StateReady: return READY;
default: return UNKNOWN;
}
}
} // namespace platform
} // namespace pvr