Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ui::ControlContext Class Reference

Cheap owning immutable snapshot of named definitions and defaults. Const snapshot reads are concurrent-safe. Mutating the same handle requires external synchronization. Copies preserve the snapshot and sticky error; later fluent mutations publish a new version only. Construction/copy of caller arguments may throw; fluent operations catch internal allocation failures. No callback, resolver, factory, locale, runtime or mutable cache is retained or invoked. More...

#include <ui_control_context.hpp>

Public Member Functions

 ControlContext (ControlContextLimits limits={}) noexcept
ControlContext & registerType (std::string_view name, std::span< const std::string_view > properties) &noexcept
 Register a callback-free custom factory schema from canonical scalar property paths.
ControlContext && registerType (std::string_view name, std::span< const std::string_view > properties) &&noexcept
ControlContext & define (std::string_view name, std::string_view base, const ControlSettings &settings={}) &noexcept
 Add one unique named definition; base may be declared later.
ControlContext && define (std::string_view name, std::string_view base, const ControlSettings &settings={}) &&noexcept
ControlContext & defaults (std::string_view type, const ControlSettings &settings) &noexcept
 Register the sole defaults block for one builtin/named type.
ControlContext && defaults (std::string_view type, const ControlSettings &settings) &&noexcept
ControlContext & overlayDefaults (std::string_view type, const ControlSettings &settings) &noexcept
 Apply sparse defaults in a nested configuration scope without changing earlier snapshots.
ControlContext && overlayDefaults (std::string_view type, const ControlSettings &settings) &&noexcept
std::expected< void, ControlContextError > validate () const noexcept
 Validate every definition/default before any application effect.
std::expected< ControlContext, ControlContextError > prepared () const noexcept
 Validate once and return an immutable version with reusable graph qualification.
bool empty () const noexcept
bool hasRegisteredType (std::string_view name) const noexcept
bool matchesRegisteredType (std::string_view name, std::span< const std::string_view > properties) const noexcept
std::expected< ResolvedControl, ControlContextError > resolve (std::string_view name, const ControlSettings &instancePatch={}) const noexcept
 Validate the whole snapshot, then resolve builtin/defaults/definition/defaults/instance precedence.
ControlContextLimits limits () const noexcept

Friends

struct detail::ControlContextAccess

Detailed Description

Cheap owning immutable snapshot of named definitions and defaults. Const snapshot reads are concurrent-safe. Mutating the same handle requires external synchronization. Copies preserve the snapshot and sticky error; later fluent mutations publish a new version only. Construction/copy of caller arguments may throw; fluent operations catch internal allocation failures. No callback, resolver, factory, locale, runtime or mutable cache is retained or invoked.

Constructor & Destructor Documentation

◆ ControlContext()

portals::ui::ControlContext::ControlContext ( ControlContextLimits limits = {})
explicitnoexcept
Parameters
limitsPositive finite limits; invalid limits become a sticky configuration error.

Member Function Documentation

◆ defaults() [1/2]

ControlContext && portals::ui::ControlContext::defaults ( std::string_view type,
const ControlSettings & settings ) &&
inlinenoexcept
Parameters
typeDefaults target.
settingsSparse patch.
Returns
This temporary handle.

◆ defaults() [2/2]

ControlContext & portals::ui::ControlContext::defaults ( std::string_view type,
const ControlSettings & settings ) &
noexcept

Register the sole defaults block for one builtin/named type.

Parameters
typeCase-sensitive type identity; forward definitions are permitted.
settingsSparse patch; a second defaults block for this type is a typed duplicate.
Returns
This same handle; internal exceptions become a sticky typed error.

◆ define() [1/2]

ControlContext && portals::ui::ControlContext::define ( std::string_view name,
std::string_view base,
const ControlSettings & settings = {} ) &&
inlinenoexcept
Parameters
nameVariant name.
baseAncestor identity.
settingsSparse patch.
Returns
This temporary.

◆ define() [2/2]

ControlContext & portals::ui::ControlContext::define ( std::string_view name,
std::string_view base,
const ControlSettings & settings = {} ) &
noexcept

Add one unique named definition; base may be declared later.

Parameters
nameCase-sensitive ASCII identifier, excluding builtin names.
baseOne builtin or named definition; checked by validate/resolve.
settingsOwning sparse initial settings copied during this call.
Returns
This same handle. The first typed failure stops later fluent mutations.

◆ empty()

bool portals::ui::ControlContext::empty ( ) const
noexcept
Returns
Whether this is the unconfigured context with ordinary default budgets.

◆ hasRegisteredType()

bool portals::ui::ControlContext::hasRegisteredType ( std::string_view name) const
noexcept
Parameters
nameExact custom schema name, excluding builtins and named definitions.
Returns
Whether this snapshot contains the explicit callback-free schema.

◆ limits()

ControlContextLimits portals::ui::ControlContext::limits ( ) const
noexcept
Returns
Immutable bounds captured by this snapshot.

◆ matchesRegisteredType()

bool portals::ui::ControlContext::matchesRegisteredType ( std::string_view name,
std::span< const std::string_view > properties ) const
noexcept
Parameters
nameExact custom schema name.
propertiesCanonical allowed paths, compared as an unordered set without allocation.
Returns
Exact schema equality; false for missing types, unknown paths or duplicate paths.

◆ overlayDefaults() [1/2]

ControlContext && portals::ui::ControlContext::overlayDefaults ( std::string_view type,
const ControlSettings & settings ) &&
inlinenoexcept
Parameters
typeLocal defaults target.
settingsSparse patch.
Returns
This temporary handle.

◆ overlayDefaults() [2/2]

ControlContext & portals::ui::ControlContext::overlayDefaults ( std::string_view type,
const ControlSettings & settings ) &
noexcept

Apply sparse defaults in a nested configuration scope without changing earlier snapshots.

Parameters
typeExisting or forward-declared type receiving local defaults.
settingsPresent leaves override inherited defaults, including false, zero and their provenance.
Returns
This handle with a new immutable version; a resource loader separately rejects duplicate local blocks.

◆ prepared()

std::expected< ControlContext, ControlContextError > portals::ui::ControlContext::prepared ( ) const
noexcept

Validate once and return an immutable version with reusable graph qualification.

Returns
Checked snapshot; resolve still validates each instance patch. Later fluent mutation invalidates qualification only on the mutated handle, leaving earlier copies unchanged.

◆ registerType() [1/2]

ControlContext && portals::ui::ControlContext::registerType ( std::string_view name,
std::span< const std::string_view > properties ) &&
inlinenoexcept
Parameters
nameCustom schema name.
propertiesCopied canonical paths.
Returns
This temporary handle.

◆ registerType() [2/2]

ControlContext & portals::ui::ControlContext::registerType ( std::string_view name,
std::span< const std::string_view > properties ) &
noexcept

Register a callback-free custom factory schema from canonical scalar property paths.

Parameters
nameUnique non-builtin type identity, shared with the caller's explicit factory allowlist.
propertiesAllowed paths from the builtin descriptor vocabulary; copied now, no borrowed span survives.
Returns
This same handle; custom types and named definitions share maxDefinitions. Unknown paths fail.

◆ resolve()

std::expected< ResolvedControl, ControlContextError > portals::ui::ControlContext::resolve ( std::string_view name,
const ControlSettings & instancePatch = {} ) const
noexcept

Validate the whole snapshot, then resolve builtin/defaults/definition/defaults/instance precedence.

Parameters
nameRequested builtin or named type.
instancePatchFinal sparse overrides, copied without resolving TextValue expressions.
Returns
Owning effective sparse settings or a typed failure with original declaration provenance.

◆ validate()

std::expected< void, ControlContextError > portals::ui::ControlContext::validate ( ) const
noexcept

Validate every definition/default before any application effect.

Returns
First sticky, graph, schema or bounded-materialization failure, otherwise success.

The documentation for this class was generated from the following file: