Skip to content

AppStateManager

#include <app_state_manager.hpp>

Inherits from std::enable_shared_from_this< AppStateManager >, IComponent

Inherited by sgns::application::AppStateManagerImpl

Public Types

Name
enum class State
using std::function< bool()> OnPrepare
using std::function< bool()> OnLaunch
using std::function< void()> OnShutdown

Public Functions

Name
~AppStateManager() override =default
virtual void atPrepare(OnPrepare && cb) =0
Execute a callback at the prepare stage.
virtual void atLaunch(OnLaunch && cb) =0
Execute a callback immediately before application start.
virtual void atShutdown(OnShutdown && cb) =0
Execute a callback during shutdown.
void registerHandlers(OnPrepare && prepare_cb, OnLaunch && launch_cb, OnShutdown && shutdown_cb)
Registration of all stages' handlers at the same time.
template <typename Controlled >
void
takeControl(Controlled & entity)
Registration special methods of object as handlers for stages of application life-cycle.
virtual void run() =0
Start application life cycle.
virtual void shutdown() =0
Initiate shutting down (at any time).
virtual State state() const =0
Get current stage.

Protected Functions

Name
virtual void doPrepare() =0
virtual void doLaunch() =0
virtual void doShutdown() =0

Additional inherited members

Public Functions inherited from IComponent

Name
virtual ~IComponent() =default
virtual std::string GetName() =0

Public Types Documentation

enum State

Enumerator Value Description
Init
Prepare
ReadyToStart
Starting
Works
ShuttingDown
ReadyToStop

using OnPrepare

using sgns::application::AppStateManager::OnPrepare = std::function<bool()>;

using OnLaunch

using sgns::application::AppStateManager::OnLaunch = std::function<bool()>;

using OnShutdown

using sgns::application::AppStateManager::OnShutdown = std::function<void()>;

Public Functions Documentation

function ~AppStateManager

~AppStateManager() override =default

function atPrepare

virtual void atPrepare(
    OnPrepare && cb
) =0

Execute a callback at the prepare stage.

Parameters:

  • cb Callback to execute.

function atLaunch

virtual void atLaunch(
    OnLaunch && cb
) =0

Execute a callback immediately before application start.

Parameters:

  • cb Callback to execute.

function atShutdown

virtual void atShutdown(
    OnShutdown && cb
) =0

Execute a callback during shutdown.

Parameters:

  • cb Callback to execute.

function registerHandlers

inline void registerHandlers(
    OnPrepare && prepare_cb,
    OnLaunch && launch_cb,
    OnShutdown && shutdown_cb
)

Registration of all stages' handlers at the same time.

Parameters:

  • prepare_cb - handler for stage of prepare
  • launch_cb - handler for doing immediately before start application
  • shutdown_cb - handler for stage of shutting down application

function takeControl

template <typename Controlled >
inline void takeControl(
    Controlled & entity
)

Registration special methods of object as handlers for stages of application life-cycle.

Parameters:

  • entity is registered entity

function run

virtual void run() =0

Start application life cycle.

function shutdown

virtual void shutdown() =0

Initiate shutting down (at any time).

function state

virtual State state() const =0

Get current stage.

Protected Functions Documentation

function doPrepare

virtual void doPrepare() =0

function doLaunch

virtual void doLaunch() =0

function doShutdown

virtual void doShutdown() =0

Updated on 2026-03-04 at 13:10:44 -0800