Skip to content

app: add app::root() shorthand for per-app state root - #39

Merged
transfix merged 1 commit into
masterfrom
cvc-singleton/app-root-shorthand
May 4, 2026
Merged

transfix merged 1 commit into
masterfrom
cvc-singleton/app-root-shorthand

Conversation

@transfix

@transfix transfix commented May 4, 2026

Copy link
Copy Markdown
Owner

Returning the per-app state root through cvc::state::instance(*this) is awkward at call sites. Add a member shorthand:

cvc::state& root = app.root();

Exactly equivalent to cvc::state::instance(app) — both spellings remain so callers pick whichever reads better. state.h keeps driving the per-app caching machinery; app.h gains only a forward declaration of cvc::state and a member declaration, with the definition in state.cpp where the full state class is in scope.

New StateTest.AppRootShorthand confirms:

  • identity with state::instance(app) for the same app,
  • independent roots across distinct apps,
  • value round-trip through the shorthand.

Docs touched: STATE_API.md (overview + Construction and Access reference now show app.root() first), GRAPHICS_DATA_DRIVEN_UPDATES.md (example uses shorthand).

Local: 591/591 with -DCVC_USING_XMLRPC=ON and OFF.

Returning the per-app state root through cvc::state::instance(*this)
is awkward at call sites. Add a member function shorthand:

  cvc::state& root = app.root();

It is exactly equivalent to cvc::state::instance(app); both spellings
are kept so callers can pick whichever reads better. The state.h
header still drives the per-app caching machinery; app.h gains only
a forward declaration of cvc::state and a member declaration, with
the definition living in state.cpp where the full state class is
in scope.

A new StateTest.AppRootShorthand confirms identity with
state::instance(app), independence across apps, and value
round-trip through the shorthand.

591/591 locally with CVC_USING_XMLRPC=OFF.
@transfix
transfix merged commit 01776d7 into master May 4, 2026
19 checks passed
@transfix
transfix deleted the cvc-singleton/app-root-shorthand branch May 4, 2026 23:31
transfix added a commit that referenced this pull request May 5, 2026
3.1.0 is the singleton-less API release:

  - Removed cvcapp / cvcstate macros and the zero-arg
    app::instance() / state::instance() singletons (PRs #36, #37).
  - All callers now reach the application context and state tree
    through an explicit cvc::app& argument.
  - Added cvc::app::root() member shorthand equivalent to
    cvc::state::instance(app) (PR #39).
  - Per-app state caching keyed on the owning cvc::app instance.
  - Documentation refresh across README, APP_API, STATE_API,
    TESTING, THREAD_POOL{,_API}, IMAGE_PROCESSING_ALGORITHMS,
    GRAPHICS_DATA_DRIVEN_UPDATES (PR #38).

CMakeLists.txt project version 3.0.0 -> 3.1.0; README Version
History gains a 3.1.0 entry; USAGE.md tarball/path examples
updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant