Skip to content

Engine → Modules → module_context.h

module_context

Syntax

class CONJURE_API module_context

Constructors

AccessSignatureDescription
publicmodule_context( module_id id, module_host_kind host, semantic_version engineVersion, const module_manifest &manifest, std::filesystem::path rootDirectory, const service_table &services);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~module_context();

Variables

AccessNameTypeDefaultDescription
privatemEngineVersionsemantic_version{}
privatemHostmodule_host_kindmodule_host_kind::RUNTIME
privatemIdmodule_id{}
privatemManifestconst module_manifest *nullptr
privatemRegistrarmodule_registrar *nullptr
privatemRootDirectorystd::filesystem::path{}
privatemServicesconst service_table *nullptr
privatemSubscriptionsstd::vector<core::event_subscription>{}

Functions

Public

begin_entry

void begin_entry(
    module_registrar &registrar) noexcept;

Binds the registrar for the duration of the entry. Called by the module manager.

end_entry

void end_entry() noexcept;

Unbinds the registrar once the entry returned. Called by the module manager.

engine_version

[[nodiscard]] semantic_version engine_version() const noexcept;

host

[[nodiscard]] module_host_kind host() const noexcept;

id

[[nodiscard]] module_id id() const noexcept;

is_entry_running

[[nodiscard]] bool is_entry_running() const noexcept;

True while the entry runs and registrar() may be called.

manifest

[[nodiscard]] const module_manifest &manifest() const noexcept;

registrar

[[nodiscard]] module_registrar &registrar() noexcept;

The registrar, available only while the entry runs; asserts (and returns a registrar over a scratch set) outside of it.

require_service

template <typename ServiceType> [[nodiscard]] core::result<ServiceType *> require_service() const;

The host service, or SERVICE_MISSING naming the interface.

retain

void retain(
    core::event_subscription &&subscription);

Owns an event subscription so its callback (module code) is released before the binary is unmapped. Module code never hands the host a callback any other way except through descriptors.

retained_subscription_count

[[nodiscard]] usize retained_subscription_count() const noexcept;

Number of retained subscriptions.

root_directory

[[nodiscard]] const std::filesystem::path &root_directory() const noexcept;

try_service

template <typename ServiceType> [[nodiscard]] ServiceType *try_service() const noexcept;

The host service, or nullptr when the host did not provide it.