Class Context
Defined in File engine-context.h
Class Documentation
-
class Context
Declaration:
finalOwns a compatible set of platform, presentation, rendering, and resource adapters.
Input can be owned or explicitly borrowed. Owned input is destroyed before resources, renderer, surface, and display, so callbacks detach from a live window. GameRuntime coordinates their initialization and shutdown; this is not a game loop. One context supports one runtime session; stopped adapters are not restarted. Null adapters/owned input or a zero owned worker count throw on construction. Borrowed input must survive runtime cleanup/context lifetime and detach from the display’s live window before its destruction. Adapter use retains its affinity.
Public Functions
-
Context(std::unique_ptr<CE::Platform::DisplaySystem> display, std::unique_ptr<CE::Rendering::PresentationSurface> surface, std::unique_ptr<CE::Rendering::Renderer> renderer, std::unique_ptr<CE::Rendering::Resources::Provider> resources, CE::Input::System &input, ExecutionOptions execution = ExecutionOptions{})
Assemble owned compatible adapters and borrowed input without starting a runtime.
See also
- Parameters:
display – Display/window owner transferred to this context.
surface – Compatible presentation owner transferred to this context.
renderer – Compatible graphics renderer transferred to this context.
resources – Resource provider in the same backend domain.
input – Borrowed input that must remain alive through runtime cleanup and context destruction, detached while its window is still alive.
execution – Positive owned capacity, or an application-supplied shared pool.
- Throws:
CE::Exceptions::invalid_args – For a missing required adapter/input or zero owned worker count. Adapter compatibility and construction/current-context requirements belong to the selected backend. No automatic dispatch or native reinitialization is provided.
-
Context(std::unique_ptr<CE::Platform::DisplaySystem> display, std::unique_ptr<CE::Rendering::PresentationSurface> surface, std::unique_ptr<CE::Rendering::Renderer> renderer, std::unique_ptr<CE::Rendering::Resources::Provider> resources, std::unique_ptr<CE::Input::System> input, ExecutionOptions execution = ExecutionOptions{})
Assemble owned compatible adapters and owned input without starting a runtime.
See also
- Parameters:
display – Display/window owner transferred to this context.
surface – Compatible presentation owner transferred to this context.
renderer – Compatible graphics renderer transferred to this context.
resources – Resource provider in the same backend domain.
input – Non-null input owner transferred to this context; destroyed before the display.
execution – Positive owned capacity, or an application-supplied shared pool.
- Throws:
CE::Exceptions::invalid_args – For a missing required adapter/input or zero owned worker count. Adapter compatibility and construction/current-context requirements belong to the selected backend. No automatic dispatch or native reinitialization is provided.
-
~Context()
Close and settle context-tracked CPU work before destroying adapters.
The caller must first stop/join the runtime and external producers. This blocks for accepted work; do not destroy a context on one of its workers or with work awaiting unpumped platform requests. Failure to settle safely is terminal. An injected pool and its unrelated groups are not shut down.
See also
-
Context(const Context&) = delete
Copy construction is disabled; one context owns one adapter/session domain.
See also
-
Context &operator=(const Context&) = delete
Copy assignment is disabled; adapter ownership is not transferable through assignment.
See also
-
CE::Platform::DisplaySystem &display() const
Declaration:
[[nodiscard]]Borrow the selected display adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Platform-owner calls remain on their required owner. Do not use beyond its owner lifetime.
-
CE::Platform::Window &window() const
Declaration:
[[nodiscard]]Borrow the selected window adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Requires the display owner; throws failed_operation if no window is active. Do not use beyond its owner lifetime.
-
CE::Rendering::PresentationSurface &surface() const
Declaration:
[[nodiscard]]Borrow the selected surface adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Presentation operations retain their graphics/platform affinity. Do not use beyond its owner lifetime.
-
CE::Rendering::Renderer &renderer() const
Declaration:
[[nodiscard]]Borrow the selected renderer adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Graphics operations retain their owner/current-context requirements. Do not use beyond its owner lifetime.
-
CE::Rendering::Resources::Provider &resources() const
Declaration:
[[nodiscard]]Borrow the selected resources adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Uploads retain backend domain and owner-thread requirements. Do not use beyond its owner lifetime.
-
CE::Input::System &input() const
Declaration:
[[nodiscard]]Borrow the selected input adapter.
See also
- Returns:
Context-associated reference, with no ownership transfer or thread marshalling. Native polling and mutable binding operations retain their input-owner requirements. Do not use beyond its owner lifetime.
-
inline CE::Text::FontService &fonts() const noexcept
Declaration:
[[nodiscard]]Borrow this context’s CPU font catalogue.
See also
- Returns:
Mutable service retained until context destruction, even through a const Context. Configure at the service’s documented startup boundary; returned immutable Font handles have independent retained CPU lifetime.
-
inline PlatformDispatcher &platform_dispatcher()
Declaration:
[[nodiscard]]Borrow the context’s platform request queue; obtaining it does not open a runtime session.
See also
- Returns:
Dispatcher valid through context lifetime; retain submission() for independently owned producer endpoints.
-
inline ::CE::Events::EventBus &events() noexcept
Declaration:
[[nodiscard]]Borrow this context’s independent typed/named event bus.
The bus remains alive through runtime teardown and closes after context-owned adapters are destroyed. Immediate callbacks run on the publishing owner; deferred listeners require an explicit delivery adapter and owned error sink. Unregister and settle borrowed callback targets before destroying them. A service must not close this shared bus.
-
inline const WindowStateSource &window_state() const noexcept
Declaration:
[[nodiscard]]Borrow the platform selection source.
Copy the facade to retain synchronized snapshots after Context destruction. Required watch attachment needs the initialized platform owner; before selection initialized is false, and runtime closure preserves the final values with closed true.
See also
-
inline const SimulationViewSource &simulation_view() const noexcept
Declaration:
[[nodiscard]]Borrow simulation’s copied dimension source.
The baseline is established on the actual simulation owner before init_simulation()/Ready/first update. Attach watches during init_simulation() for required sizing; snapshots are readable from any thread and own no native Window. A focus-only window change does not advance the view revision.
-
inline const RuntimeServices &services() const noexcept
Declaration:
[[nodiscard]]Borrow platform-maintenance and simulation-step attachment access.
Copy the facade for retained coordination without retaining Context. Attach on each initialized owner; closure rejects new participants and invalidates old attachments without destructor callbacks.
See also
-
inline CE::Diagnostics::DomainId diagnostic_id() const noexcept
Declaration:
[[nodiscard]]Read this context’s process-local diagnostic identity; not a persistent or native-resource key.
See also
-
CE::Workers::Group make_worker_group(CE::Workers::GroupOptions options = CE::Workers::GroupOptions{})
Declaration:
[[nodiscard]]Create a workload in this context’s tracked shutdown domain.
See also
- Parameters:
options – Structural and CPU/locality policy for the new group.
- Returns:
Copyable group sharing either the lazily created owned pool or execution.shared_pool. Synchronized across producers while the context lives. Closed context/pool, invalid options or unavailable required policy reject. Shutdown closes/drains every group created here, including copies held by callers; unrelated shared-pool groups remain independent.
-
Context(std::unique_ptr<CE::Platform::DisplaySystem> display, std::unique_ptr<CE::Rendering::PresentationSurface> surface, std::unique_ptr<CE::Rendering::Renderer> renderer, std::unique_ptr<CE::Rendering::Resources::Provider> resources, CE::Input::System &input, ExecutionOptions execution = ExecutionOptions{})