state_pattern::Context

class Context

Public Functions

explicit Context(std::unique_ptr<State> initialState)

Constructor that initializes the context with an initial state.

Parameters:

initialState – Initial state of the context.

void setState(std::unique_ptr<State> newState)

Sets the state of the context.

Parameters:

newState – New state to transition to.

void request()

Triggers the handle method of the current state.

std::string getStateName() const

Gets the name of the current state (for testing/logging purposes).

Returns:

Name of the current state.