Remove cvcapp singleton: thread cvc::app& through libcvc (Phase A, part 1)#11
Merged
Conversation
Drop the last call site of the parameterless VolMagick::readVolumeFile shim. Construct a local cvc::app at main() entry and invoke CVC_NAMESPACE::readVolumeFile(ctx, vol, input_file) directly. This unblocks deleting the ctx-less free-function overloads in src/cvc/volume_file_io.cpp and the corresponding cvcapp singleton references in upcoming Phase 5 commits.
Each virtual already takes app& ctx as a parameter (currently unnamed because unused). Use it for the thread_info construction instead of falling back to the legacy delegating ctor that calls app::instance(). Pure mechanical change in 4 sites; no behavior change. Removes 4 of the singleton-using call sites and unblocks deletion of the cvc::thread_info(string) legacy ctor at app.h:384.
Change command_func signature from
void(const std::vector<std::string>&)
to
void(cvc::app&, const std::vector<std::string>&)
and construct one cvc::app at the top of main(), passing it into
each dispatched handler. Each command (copy/info/sdf/iso/server/client)
now uses ctx-aware overloads for thread_info, geometry/volume ctors,
volume_file_info::read, and the iso/sdf/save/load free functions.
cvcstate(...) and cvcapp.wait() are kept inside server() for now;
they will become ctx.state()(...) once the state singleton merge
(PR 11) lands. cvcapp.wait() in server() becomes ctx.wait().
This unblocks deletion of the ctx-less free-function bridges in
volume_file_io.cpp and utility.cpp, since libcvc.cpp:47 was the
last caller of the parameterless save/load overloads.
The mesher CLI commit eliminated the last external caller of the
parameterless VolMagick::readVolumeFile shim, and libcvc.cpp's command
handlers (PR 4) were the last libcvc-internal callers of save(load(...)).
All other call sites already pass cvc::app& explicitly, so the ctx-less
bridges in volume_file_io.{h,cpp} and utility.{h,cpp} are unreachable.
Deleted ctx-less overloads:
volume_file_io.h/.cpp:
readVolumeFile (5 forms), writeVolumeFile (3 forms),
createVolumeFile, readBoundingBox, writeBoundingBox.
utility.h/.cpp:
calcGradient, sub, volconvert, load, save, plus the inline
createVolumeFile(volume_file_info)/(volume,filename) shims.
Also fixed an internal save() that constructed a ctx-less geometry
during dispatch -- now uses the supplied app& context.
Full Linux Debug build (158 targets) and ctest (590/590 passing)
verified.
Part of the cvc::app singleton removal effort tracked in
cvc-singleton-removal-plan.md (PR 7).
…dies Several volume_file_io subclasses had `app & /*ctx*/` parameters and constructed `thread_info ti(BOOST_CURRENT_FUNCTION)` -- which silently fell back on app::instance(). Restore the parameter name and pass the provided ctx into thread_info so progress/info routing follows the caller's app instance. Files updated (mechanical s/app & \/\*ctx\*\//app \&ctx/ + s/thread_info ti(BOOST_CURRENT_FUNCTION)/thread_info ti(ctx, ...)/): src/cvc/hdf5_io.cpp src/cvc/mrc_io.cpp src/cvc/rawiv_io.cpp src/cvc/spider_io.cpp src/cvc/vtk_io.cpp src/cvc/volume_file_info.cpp Full Linux Debug build (158 targets) and ctest (590/590) green. Part of cvc-singleton-removal-plan.md (PR 5, revised scope -- legacy ctor deletion deferred until after algorithm.cpp / volrover3 callers are migrated).
Lines 1338-1436 of inc/cvc/hdf5_utils.h were a block of inline overloads that injected app::instance() and forwarded to the ctx-aware primary versions. The only caller in the codebase is src/cvc/tests/hdf5_test.cpp (8 objectExists calls); migrate that to the test fixture's local cvc::app and delete the ctx-less forwarders entirely. Build (158 targets) + ctest (590/590) green. Part of cvc-singleton-removal-plan.md (PR 6).
Apply clang-format-18 to files touched in this branch so the clang-format (changed lines) CI check passes.
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First batch of work toward removing the
cvcappsingleton (cvc::app::instance()) from libcvc, per cvc-singleton-removal-plan.md.This PR contains 6 small, independent commits — each individually builds and passes
ctest(590/590) on Linux Debug. They're stacked on one branch for CI efficiency; happy to split into separate PRs if reviewers prefer.Commits (oldest → newest)
dac67edcvc-mesher: thread cvc::app through Mesher main() — eliminates the last external caller of the parameterlessVolMagick::readVolumeFileshim.fab6789rawv_io: pass app& through thread_info ctor — 4 virtual method bodies now forward the suppliedctxinstead of falling back on the singleton.fe32a76libcvc CLI: thread cvc::app& through dispatch table — dispatch nowvoid(cvc::app&, args); main() owns oneapp cvc_ctx.4c0c026volume_file_io/utility: delete ctx-less free-function bridges — all callers in libcvc + downstream now passapp&explicitly.f325f71volume_file_io subclasses: thread cvc::app& through virtual method bodies — mrc_io / rawiv_io / spider_io / hdf5_io / vtk_io / volume_file_info hadapp & /*ctx*/parameters but constructedthread_info ti(BOOST_CURRENT_FUNCTION), silently falling back on the singleton. Restore the parameter name and pass it through.5f65657hdf5_utils: delete ctx-less inline overloads — block of ~100 lines ofapp::instance()-injecting forwarders. Sole caller (hdf5_test.cpp) migrated to fixture-localcvc::app.What still uses
app::instance()after this PRalgorithm.cpp(~30 free functions) — large mechanical signature change, separate PRxmlrpc_server.cpp/xmlrpc_client.cpp— bundled withstateworkMainWindow,GeometryDialog,SDFDialog, etc.) — separate PRapp.h:384/421/493— deferred until after the aboveapp_test.cpp,state_test.cpp,geometry_test.cpp,voxels_test.cpp) — large fixture rewrite, separate PRapp::instance()itself +cvcappmacro — gated on all of the aboveSee cvc-singleton-removal-plan.md for the full 17-PR sequencing plan.
Validation
cmake --build .clean (158/158 targets) on Linux Debug at every commitctest -j8100% passed (590/590) at every commitgrep -n 'app::instance' libcvc/src/cvc/{volume_file_io,utility}.cppreturns 0 hits after PR