From dac67ed39aa08614fdb46bdd57ea1c35d4e87a2d Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 12:45:34 -0500 Subject: [PATCH 1/7] cvc-mesher: thread cvc::app through Mesher main() 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. --- src/cvc/cvc-mesher/Mesher/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cvc/cvc-mesher/Mesher/main.cpp b/src/cvc/cvc-mesher/Mesher/main.cpp index e38592fb..7ff19eb0 100644 --- a/src/cvc/cvc-mesher/Mesher/main.cpp +++ b/src/cvc/cvc-mesher/Mesher/main.cpp @@ -2,12 +2,14 @@ #include #include #include +#include #include #include #include int main(int argc, char **argv) { + CVC_NAMESPACE::app cvc_ctx; using namespace std; namespace po = boost::program_options; @@ -79,7 +81,7 @@ int main(int argc, char **argv) if(operation == "mesh") { VolMagick::Volume vol; - VolMagick::readVolumeFile(vol,input_file); + CVC_NAMESPACE::readVolumeFile(cvc_ctx, vol, input_file); // Convert string arguments to enums LBIE::Mesher::ExtractionMethod extraction_method_enum; From fab678916c029449b78e20ffffc801376d173927 Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 15:36:29 -0500 Subject: [PATCH 2/7] rawv_io: pass app& through thread_info ctor 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. --- src/cvc/rawv_io.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cvc/rawv_io.cpp b/src/cvc/rawv_io.cpp index 1112001c..9127c0e4 100644 --- a/src/cvc/rawv_io.cpp +++ b/src/cvc/rawv_io.cpp @@ -117,9 +117,9 @@ struct rawv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &data, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &data, const std::string &filename) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; data_type rawv_type_conv[] = {UChar, UChar, UShort, UInt, Float, Double}; @@ -296,10 +296,10 @@ struct rawv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; data_type rawv_type_conv[] = {UChar, UChar, UShort, UInt, Float, Double}; @@ -554,11 +554,11 @@ struct rawv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void createVolumeFile(app & /*ctx*/, const std::string &filename, + virtual void createVolumeFile(app &ctx, const std::string &filename, const bounding_box &boundingBox, const dimension &dimension, const std::vector &voxelTypes, unsigned int numVariables, unsigned int numTimesteps, double min_time, double max_time) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; unsigned char rawv_inv_type_conv[] = {1, 2, 3, 4, 5}; @@ -676,7 +676,7 @@ struct rawv_io : public volume_file_io { virtual void writeVolumeFile(app &ctx, const volume &wvol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; unsigned char rawv_inv_type_conv[] = {1, 2, 3, 4, 5}; From fe32a76adf00b9a2885f0d1435a7b1105346547d Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 15:39:56 -0500 Subject: [PATCH 3/7] libcvc CLI: thread cvc::app& through dispatch table Change command_func signature from void(const std::vector&) to void(cvc::app&, const std::vector&) 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. --- src/cvc/libcvc.cpp | 47 ++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/cvc/libcvc.cpp b/src/cvc/libcvc.cpp index 0ff7ea4c..2d698524 100644 --- a/src/cvc/libcvc.cpp +++ b/src/cvc/libcvc.cpp @@ -20,12 +20,13 @@ namespace { * Commands */ -typedef boost::function &)> command_func; +typedef boost::function &)> + command_func; typedef boost::tuple command; typedef std::map command_map; command_map commands; -void help(const std::vector &args) { +void help(CVC_NAMESPACE::app & /*ctx*/, const std::vector &args) { using namespace std; cout << "Usage: libcvc " << endl << endl; for (command_map::iterator i = commands.begin(); i != commands.end(); ++i) { @@ -34,30 +35,30 @@ void help(const std::vector &args) { } } -void copy(const std::vector &args) { +void copy(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace boost; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (args.empty()) throw command_line_error("Missing input filename."); if (args.size() < 2) throw command_line_error("Missing output volume filename"); - save(load(args[0]), args[1]); + save(ctx, load(ctx, args[0]), args[1]); } -void info(const std::vector &args) { +void info(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace boost; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (args.empty()) throw command_line_error("Missing input filename."); if (is_geometry_filename(args[0])) { - geometry geo(args[0]); + geometry geo(ctx, args[0]); if (geo.num_points() > 0) cout << "Num vertices: " << geo.num_points() << endl; if (geo.num_lines() > 0) @@ -75,7 +76,7 @@ void info(const std::vector &args) { << endl; } else if (is_volume_filename(args[0])) { volume_file_info volinfo; - volinfo.read(args[0]); + volinfo.read(ctx, args[0]); cout << volinfo.filename() << ":" << endl; cout << "Num Variables: " << volinfo.numVariables() << endl; cout << "Num Timesteps: " << volinfo.numTimesteps() << endl; @@ -111,10 +112,10 @@ void info(const std::vector &args) { } // 01/11/2014 - Joe R. - moved bounding box to last argument and made optional. -void sdf(const std::vector &args) { +void sdf(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (args.empty()) throw command_line_error("Missing geometry filename"); if (args.size() < 2) @@ -122,47 +123,47 @@ void sdf(const std::vector &args) { if (args.size() < 3) throw command_line_error("Missing output volume filename"); - geometry geom(args[0]); + geometry geom(ctx, args[0]); bounding_box bbox = geom.extents(); if (args.size() >= 4) bbox = bounding_box(args[3]); - sdf(geom, dimension(args[1]), bbox).write(args[2]); + sdf(ctx, geom, dimension(args[1]), bbox).write(args[2]); } -void iso(const std::vector &args) { +void iso(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace boost; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (args.empty()) throw command_line_error("Missing volume filename"); if (args.size() < 2) throw command_line_error("Missing isovalue"); if (args.size() < 3) throw command_line_error("Missing output geometry filename"); - iso(volume(args[0]), lexical_cast(args[1])).write(args[2]); + iso(ctx, volume(ctx, args[0]), lexical_cast(args[1])).write(args[2]); } #ifdef USING_XMLRPC -void server(const std::vector &args) { +void server(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace boost; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); int port = XMLRPC_DEFAULT_PORT; if (!args.empty()) port = lexical_cast(args[0]); cvcstate("__system.xmlrpc.port").value(port); cvcstate("__system.xmlrpc").value(int(1)); // start the server - cvcapp.wait(); // wait for the server thread to quit + ctx.wait(); // wait for the server thread to quit } -void client(const std::vector &args) { +void client(CVC_NAMESPACE::app &ctx, const std::vector &args) { using namespace std; using namespace boost; using namespace CVC_NAMESPACE; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (args.empty()) throw command_line_error("Missing host:port"); if (args.size() < 2) @@ -224,6 +225,8 @@ int main(int argc, char **argv) { using namespace std; using namespace CVC_NAMESPACE; + app cvc_ctx; + vector args; for (int i = 0; i < argc; i++) args.push_back(argv[i]); @@ -238,7 +241,7 @@ int main(int argc, char **argv) { if (commands.find(cmd) == commands.end()) throw command_line_error("Invalid command."); - commands[cmd].get<0>()(args); + commands[cmd].get<0>()(cvc_ctx, args); } catch (command_line_error &e) { if (!e.what_str().empty()) cout << "Error: " << e.what_str() << endl; From 4c0c026e50364eece2c8a17bad42664bc172c430 Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 15:51:57 -0500 Subject: [PATCH 4/7] volume_file_io/utility: delete ctx-less free-function bridges 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). --- inc/cvc/utility.h | 30 ++---------------- inc/cvc/volume_file_io.h | 65 +++----------------------------------- src/cvc/utility.cpp | 23 ++------------ src/cvc/volume_file_io.cpp | 51 ++---------------------------- 4 files changed, 12 insertions(+), 157 deletions(-) diff --git a/inc/cvc/utility.h b/inc/cvc/utility.h index fe5a8197..8c830424 100644 --- a/inc/cvc/utility.h +++ b/inc/cvc/utility.h @@ -103,14 +103,9 @@ static inline double getTriVal(double val[8], double x, double y, double z, doub } /* - Shortcut for creating a volume file based on a volume file info object + Shortcut for creating a volume file based on a volume file info object. + All overloads require an explicit cvc::app context. */ -static inline void createVolumeFile(const std::string &filename, const volume_file_info &volinfo) { - createVolumeFile(filename, volinfo.boundingBox(), volinfo.voxel_dimensions(), - volinfo.voxelTypes(), volinfo.numVariables(), volinfo.numTimesteps(), - volinfo.TMin(), volinfo.TMax()); -} - static inline void createVolumeFile(app &ctx, const std::string &filename, const volume_file_info &volinfo) { createVolumeFile(ctx, filename, volinfo.boundingBox(), volinfo.voxel_dimensions(), @@ -126,12 +121,6 @@ static inline void createVolumeFile(app &ctx, const std::string &filename, // writes the volume data in the object to the specified file. // ---- Change History ---- // 01/04/2010 -- Joe R. -- Creation. -static inline void createVolumeFile(const volume &vol, const std::string &filename) { - createVolumeFile(filename, vol.boundingBox(), vol.voxel_dimensions(), - std::vector(1, vol.voxelType())); - writeVolumeFile(vol, filename); -} - static inline void createVolumeFile(app &ctx, const volume &vol, const std::string &filename) { createVolumeFile(ctx, filename, vol.boundingBox(), vol.voxel_dimensions(), std::vector(1, vol.voxelType())); @@ -146,10 +135,6 @@ static inline void createVolumeFile(app &ctx, const volume &vol, const std::stri // createVolumeFile call // ---- Change History ---- // 01/04/2010 -- Joe R. -- Creation. -static inline void createVolumeFile(const std::string &filename, const volume &vol) { - createVolumeFile(vol, filename); -} - static inline void createVolumeFile(app &ctx, const std::string &filename, const volume &vol) { createVolumeFile(ctx, vol, filename); } @@ -160,14 +145,7 @@ static inline void createVolumeFile(app &ctx, const std::string &filename, const (UChar, UShort, UInt), the first half of the set of integers maps to [-1.0,0) and the last half maps to (0,1.0]. */ -void calcGradient(std::vector &grad, const volume &vol, data_type vt = Float); - -void sub(volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z, - const dimension &subvoldim); - -void volconvert(const std::string &input_volume_file, const std::string &output_volume_file); - -// ---- Overloads accepting explicit app& context ---- +// ---- All free functions take an explicit cvc::app context. ---- void calcGradient(app &ctx, std::vector &grad, const volume &vol, data_type vt = Float); void sub(app &ctx, volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z, @@ -241,7 +219,5 @@ bool is_volume(const boost::any &data); bool is_volume_file_info(const boost::any &data); bool is_geometry_filename(const std::string &filename); bool is_volume_filename(const std::string &filename); -boost::any load(const std::string &filename); -void save(const boost::any &data, const std::string &filename); } // namespace CVC_NAMESPACE #endif diff --git a/inc/cvc/volume_file_io.h b/inc/cvc/volume_file_io.h index 5424fef0..d56b0f06 100644 --- a/inc/cvc/volume_file_io.h +++ b/inc/cvc/volume_file_io.h @@ -244,66 +244,11 @@ struct volume_file_io { }; // ------------------------- Volume I/O API - -/* - read the specified subvolume from the specified file and copy it to the object - vol. -*/ -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time, - uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim); - -/* - read the specified subvolume from the specified file and copy it to the object - vol. -*/ -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time, - const bounding_box &subvolbox); - -/* - read the entire volume from the specified file and copy it to the object vol. -*/ -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var = 0, - unsigned int time = 0); - -/* - Read multi-volume file and add each volume to the vector vols. -*/ -void readVolumeFile(std::vector &vols, const std::string &filename); - -/* - write the specified volume to the specified offset in file 'filename' -*/ -void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var = 0, - unsigned int time = 0, uint64 off_x = 0, uint64 off_y = 0, uint64 off_z = 0); - -/* - write the specified volume to the specified subvolume bounding box in file 'filename' -*/ -void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var, - unsigned int time, const bounding_box &subvolbox); - -/* - Writes the vector 'vols' to the specified file. Make sure that the file extension - specified is for a volume file type that supports multi-volumes. Assumes 1 timestep. -*/ -void writeVolumeFile(const std::vector &vols, const std::string &filename); - -/* - Creates a volume file using the specified information. -*/ -void createVolumeFile(const std::string &filename, const bounding_box &boundingBox, - const dimension &dimension, - const std::vector &voxelTypes = std::vector(1, UChar), - unsigned int numVariables = 1, unsigned int numTimesteps = 1, - double min_time = 0.0, double max_time = 0.0); - -// Functions for reading and writing volume bounding boxes -bounding_box readBoundingBox(const std::string &filename); -void writeBoundingBox(const bounding_box &bbox, const std::string &filename); - -// ---- Overloads accepting explicit app& context ---- -// These avoid the app::instance() singleton. Legacy overloads above -// delegate to app::instance() internally. +// +// All free-function I/O takes an explicit cvc::app context so each +// caller controls thread/property/data scoping. (The earlier +// parameterless overloads that delegated to app::instance() have been +// removed.) void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var = 0, unsigned int time = 0); diff --git a/src/cvc/utility.cpp b/src/cvc/utility.cpp index d13a5085..ed34a5c2 100644 --- a/src/cvc/utility.cpp +++ b/src/cvc/utility.cpp @@ -118,10 +118,6 @@ void calcGradient(app &ctx, std::vector &grad, const volume &vol, data_t ctx.threadProgress(1.0f); } -void calcGradient(std::vector &grad, const volume &vol, data_type vt) { - calcGradient(app::instance(), grad, vol, vt); -} - void sub(app &ctx, volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); @@ -146,11 +142,6 @@ void sub(app &ctx, volume &dest, const volume &vol, uint64 off_x, uint64 off_y, dest(i, j, k, vol(i + off_x, j + off_y, k + off_z)); } -void sub(volume &dest, const volume &vol, uint64 off_x, uint64 off_y, uint64 off_z, - const dimension &subvoldim) { - sub(app::instance(), dest, vol, off_x, off_y, off_z, subvoldim); -} - void volconvert(app &ctx, const std::string &input_volume_file, const std::string &output_volume_file) { using namespace boost; @@ -160,7 +151,7 @@ void volconvert(app &ctx, const std::string &input_volume_file, ctx.log(2, str(boost::format("%s :: out-of-core convert\n") % BOOST_CURRENT_FUNCTION)); volume_file_info volinfo; - volinfo.read(input_volume_file); + volinfo.read(ctx, input_volume_file); // createVolumeFile in Utlity.h createVolumeFile(ctx, output_volume_file, volinfo); @@ -180,10 +171,6 @@ void volconvert(app &ctx, const std::string &input_volume_file, } } -void volconvert(const std::string &input_volume_file, const std::string &output_volume_file) { - volconvert(app::instance(), input_volume_file, output_volume_file); -} - // ---- // json // ---- @@ -280,7 +267,7 @@ boost::any load(app &ctx, const std::string &filename) { boost::smatch what; if (is_geometry_filename(filename)) { - CVC_NAMESPACE::geometry geo(filename); + CVC_NAMESPACE::geometry geo(ctx, filename); return geo; } else if (is_volume_filename(filename)) { CVC_NAMESPACE::volume vol(ctx, filename); @@ -291,8 +278,6 @@ boost::any load(app &ctx, const std::string &filename) { return boost::any(); } -boost::any load(const std::string &filename) { return load(app::instance(), filename); } - void save(app &ctx, const boost::any &data, const std::string &filename) { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (is_geometry(data)) { @@ -304,8 +289,4 @@ void save(app &ctx, const boost::any &data, const std::string &filename) { } else throw CVC_NAMESPACE::write_error(BOOST_CURRENT_FUNCTION); } - -void save(const boost::any &data, const std::string &filename) { - save(app::instance(), data, filename); -} } // namespace CVC_NAMESPACE diff --git a/src/cvc/volume_file_io.cpp b/src/cvc/volume_file_io.cpp index 61fb01f0..e46b1da0 100644 --- a/src/cvc/volume_file_io.cpp +++ b/src/cvc/volume_file_io.cpp @@ -229,10 +229,6 @@ void volume_file_io::insertHandler(handler_map &hm, const ptr &vfio) { } } -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time) { - readVolumeFile(app::instance(), vol, filename, var, time); -} - // -------------- // readVolumeFile // -------------- @@ -245,11 +241,6 @@ void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, // 12/28/2009 -- Joe R. -- Collecting exception error strings // 09/05/2011 -- Joe R. -- Using splitRawFilename to extract real filename // if the provided filename is a file|obj tuple. -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time, - uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) { - readVolumeFile(app::instance(), vol, filename, var, time, off_x, off_y, off_z, subvoldim); -} - // -------------- // readVolumeFile (ctx-aware) // -------------- @@ -298,11 +289,6 @@ void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned // 01/03/2010 -- Joe R. -- Re-implemented using volume_file_io handler map. // 09/05/2011 -- Joe R. -- Using splitRawFilename to extract real filename // if the provided filename is a file|obj tuple. -void readVolumeFile(volume &vol, const std::string &filename, unsigned int var, unsigned int time, - const bounding_box &subvolbox) { - readVolumeFile(app::instance(), vol, filename, var, time, subvolbox); -} - // -------------- // readVolumeFile (ctx-aware, bbox) // -------------- @@ -339,10 +325,6 @@ void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned BOOST_CURRENT_FUNCTION % filename % errors)); } -void readVolumeFile(std::vector &vols, const std::string &filename) { - readVolumeFile(app::instance(), vols, filename); -} - // --------------- // writeVolumeFile // --------------- @@ -355,11 +337,6 @@ void readVolumeFile(std::vector &vols, const std::string &filename) { // 12/28/2009 -- Joe R. -- Collecting exception error strings // 09/05/2011 -- Joe R. -- Using splitRawFilename to extract real filename // if the provided filename is a file|obj tuple. -void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var, - unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z) { - writeVolumeFile(app::instance(), vol, filename, var, time, off_x, off_y, off_z); -} - // --------------- // writeVolumeFile (ctx-aware, offset) // --------------- @@ -457,11 +434,6 @@ void writeVolumeFile(app &ctx, const volume &vol, const std::string &filename, u writeVolumeFile(ctx, subvol, filename, var, time, off_x, off_y, off_z); } -void writeVolumeFile(const volume &vol, const std::string &filename, unsigned int var, - unsigned int time, const bounding_box &subvolbox) { - writeVolumeFile(app::instance(), vol, filename, var, time, subvolbox); -} - // --------------- // writeVolumeFile // --------------- @@ -470,9 +442,6 @@ void writeVolumeFile(const volume &vol, const std::string &filename, unsigned in // such an operation. // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. -void writeVolumeFile(const std::vector &vols, const std::string &filename) { - writeVolumeFile(app::instance(), vols, filename); -} // ---------------- // createVolumeFile @@ -486,13 +455,6 @@ void writeVolumeFile(const std::vector &vols, const std::string &filenam // 12/28/2009 -- Joe R. -- Collecting exception error strings // 09/05/2011 -- Joe R. -- Using splitRawFilename to extract real filename // if the provided filename is a file|obj tuple. -void createVolumeFile(const std::string &filename, const bounding_box &boundingBox, - const dimension &dimension, const std::vector &voxelTypes, - unsigned int numVariables, unsigned int numTimesteps, double min_time, - double max_time) { - createVolumeFile(app::instance(), filename, boundingBox, dimension, voxelTypes, numVariables, - numTimesteps, min_time, max_time); -} // --------------- // readBoundingBox @@ -501,10 +463,6 @@ void createVolumeFile(const std::string &filename, const bounding_box &boundingB // Returns a volume file's bounding box. // ---- Change History ---- // 04/06/2012 -- Joe R. -- Creation. -bounding_box readBoundingBox(const std::string &filename) { - return readBoundingBox(app::instance(), filename); -} - bounding_box readBoundingBox(app &ctx, const std::string &filename) { return volume_file_info(ctx, filename).boundingBox(); } @@ -516,10 +474,6 @@ bounding_box readBoundingBox(app &ctx, const std::string &filename) { // Changes a volume file's bounding box. // ---- Change History ---- // 04/06/2012 -- Joe R. -- Creation. -void writeBoundingBox(const bounding_box &bbox, const std::string &filename) { - writeBoundingBox(app::instance(), bbox, filename); -} - void writeBoundingBox(app &ctx, const bounding_box &bbox, const std::string &filename) { std::string errors; boost::smatch what; @@ -551,9 +505,8 @@ void writeBoundingBox(app &ctx, const bounding_box &bbox, const std::string &fil } // ---- app& overloads ---- -// These accept an explicit app context instead of using the singleton. -// The ctx-aware versions are primary; legacy overloads delegate to them -// via app::instance() for backward compatibility. +// Convenience overloads that fill in defaulted args / build composite +// behavior on top of the primary ctx-aware bridges defined above. void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time) { From f325f71de0249cc56c81fe146da4cdb673e842a2 Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 16:21:10 -0500 Subject: [PATCH 5/7] volume_file_io subclasses: thread cvc::app& through virtual method bodies 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). --- src/cvc/hdf5_io.cpp | 24 ++++++++++++------------ src/cvc/mrc_io.cpp | 24 ++++++++++++------------ src/cvc/rawiv_io.cpp | 16 ++++++++-------- src/cvc/spider_io.cpp | 14 +++++++------- src/cvc/volume_file_info.cpp | 2 +- src/cvc/vtk_io.cpp | 18 +++++++++--------- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/cvc/hdf5_io.cpp b/src/cvc/hdf5_io.cpp index 03050210..2e165d75 100644 --- a/src/cvc/hdf5_io.cpp +++ b/src/cvc/hdf5_io.cpp @@ -311,12 +311,12 @@ struct hdf5_io : public volume_file_io { // 09/02/2011 -- Joe R. -- Forgot to copy filename to data. // 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make // multi-res hierarchy thread code simpler. - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &d, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &d, const std::string &filename) const { using namespace hdf5_utils; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; @@ -456,14 +456,14 @@ struct hdf5_io : public volume_file_io { // 08/05/2011 -- Joe R. -- Using HDF5 Utilities now. // 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make // multi-res hierarchy thread code simpler. - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { using namespace H5; using namespace hdf5_utils; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; @@ -542,13 +542,13 @@ struct hdf5_io : public volume_file_io { // multi-res hierarchy thread code simpler. // 09/17/2011 -- Joe R. -- Picking out the closest dimension to the maxdim in // the hierarchy. - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, const bounding_box &subvolbox) const { using namespace hdf5_utils; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; @@ -666,7 +666,7 @@ struct hdf5_io : public volume_file_io { // 09/02/2011 -- Joe R. -- Calling new createHDF5File function. // 09/08/2011 -- Joe R. -- Only creating a file if none exists, else just re-using it. // 09/30/2011 -- Joe R. -- Added objectType attribute. - virtual void createVolumeFile(app & /*ctx*/, const std::string &filename, + virtual void createVolumeFile(app &ctx, const std::string &filename, const bounding_box &boundingBox, const dimension &dimension, const std::vector &voxelTypes, unsigned int numVariables, unsigned int numTimesteps, double min_time, double max_time) const { @@ -674,7 +674,7 @@ struct hdf5_io : public volume_file_io { namespace fs = boost::filesystem; using boost::filesystem::path; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; @@ -738,13 +738,13 @@ struct hdf5_io : public volume_file_io { // 08/28/2011 -- Joe R. -- Using HDF5 Utilities now. // 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make // multi-res hierarchy thread code simpler. - virtual void writeVolumeFile(app & /*ctx*/, const volume &wvol, const std::string &filename, + virtual void writeVolumeFile(app &ctx, const volume &wvol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z) const { using namespace hdf5_utils; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; @@ -825,12 +825,12 @@ struct hdf5_io : public volume_file_io { // Writes the specified bounding box to the file. // ---- Change History ---- // 04/06/2012 -- Joe R. -- Creation. - virtual void writeBoundingBox(app & /*ctx*/, const bounding_box &bbox, + virtual void writeBoundingBox(app &ctx, const bounding_box &bbox, const std::string &filename) const { using namespace hdf5_utils; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); std::string actualFileName; std::string objectName; diff --git a/src/cvc/mrc_io.cpp b/src/cvc/mrc_io.cpp index 50906c0a..44522740 100644 --- a/src/cvc/mrc_io.cpp +++ b/src/cvc/mrc_io.cpp @@ -313,9 +313,9 @@ struct mrc_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &d, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &d, const std::string &filename) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; FILE *input; @@ -468,10 +468,10 @@ struct mrc_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; @@ -661,12 +661,12 @@ struct mrc_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void createVolumeFile(app & /*ctx*/, const std::string &filename, + virtual void createVolumeFile(app &ctx, const std::string &filename, const bounding_box &boundingBox, const dimension &dimension, const std::vector &voxelTypes, unsigned int numVariables, unsigned int numTimesteps, double min_time, double max_time) const { using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); mrc_header mrcHeader; @@ -778,7 +778,7 @@ struct mrc_io : public volume_file_io { unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z) const { using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); volume_file_info volinfo; char buf[256]; @@ -1036,11 +1036,11 @@ struct imod_mrc_io : public mrc_io { // from a volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &data, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &data, const std::string &filename) const { using namespace std; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); data_type mrcTypes[] = {UChar, UShort, Float}; MrcHeader header; @@ -1112,12 +1112,12 @@ struct imod_mrc_io : public mrc_io { // Writes to a Volume object after reading from a volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { using namespace std; using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); if (var > 0) throw index_out_of_bounds("Variable index out of bounds."); @@ -1208,7 +1208,7 @@ struct imod_mrc_io : public mrc_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_mrc_io(app & /*ctx*/) { +void register_mrc_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new mrc_io)); } } // namespace CVC_NAMESPACE diff --git a/src/cvc/rawiv_io.cpp b/src/cvc/rawiv_io.cpp index 7c0a75b6..90e31dda 100644 --- a/src/cvc/rawiv_io.cpp +++ b/src/cvc/rawiv_io.cpp @@ -119,9 +119,9 @@ struct rawiv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/13/2009 -- Joe R. -- Converted to a volume_file_io class. - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &data, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &data, const std::string &filename) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; rawiv_header rawivHeader; @@ -292,10 +292,10 @@ struct rawiv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/13/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; rawiv_header rawivHeader; @@ -513,11 +513,11 @@ struct rawiv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/13/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void createVolumeFile(app & /*ctx*/, const std::string &filename, + virtual void createVolumeFile(app &ctx, const std::string &filename, const bounding_box &boundingBox, const dimension &dimension, const std::vector &voxelTypes, unsigned int numVariables, unsigned int numTimesteps, double min_time, double max_time) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; rawiv_header rawivHeader; @@ -638,7 +638,7 @@ struct rawiv_io : public volume_file_io { virtual void writeVolumeFile(app &ctx, const volume &wvol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); volume_file_info volinfo; char buf[256]; @@ -889,7 +889,7 @@ struct rawiv_io : public volume_file_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_rawiv_io(app & /*ctx*/) { +void register_rawiv_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new rawiv_io)); } } // namespace CVC_NAMESPACE diff --git a/src/cvc/spider_io.cpp b/src/cvc/spider_io.cpp index bf0ba995..07005613 100644 --- a/src/cvc/spider_io.cpp +++ b/src/cvc/spider_io.cpp @@ -553,9 +553,9 @@ struct spider_io : public volume_file_io { // ??/??/2008 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class. // 12/11/2009 -- Joe R. -- Freeing buf if read successful. - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data &d, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data &d, const std::string &filename) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); int dim[3]; float *buf = NULL; @@ -623,10 +623,10 @@ struct spider_io : public volume_file_io { // ??/??/2008 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class. // 12/11/2009 -- Joe R. -- Freeing data buffer. - virtual void readVolumeFile(app & /*ctx*/, volume &vol, const std::string &filename, + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, const dimension &subvoldim) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); int dim[3]; float *data = NULL; @@ -681,12 +681,12 @@ struct spider_io : public volume_file_io { // ---- Change History ---- // ??/??/2008 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class. - virtual void createVolumeFile(app & /*ctx*/, const std::string &filename, + virtual void createVolumeFile(app &ctx, const std::string &filename, const bounding_box &boundingBox, const dimension &dimension, const std::vector &voxelTypes, unsigned int numVariables, unsigned int numTimesteps, double min_time, double max_time) const { using namespace boost; - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); int dim[3] = {static_cast(dimension[0]), static_cast(dimension[1]), static_cast(dimension[2])}; @@ -772,7 +772,7 @@ struct spider_io : public volume_file_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_spider_io(app & /*ctx*/) { +void register_spider_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new spider_io)); } } // namespace CVC_NAMESPACE diff --git a/src/cvc/volume_file_info.cpp b/src/cvc/volume_file_info.cpp index 26b53021..014a00b1 100644 --- a/src/cvc/volume_file_info.cpp +++ b/src/cvc/volume_file_info.cpp @@ -81,7 +81,7 @@ void volume_file_info::read(app &ctx, const std::string &filename) { void volume_file_info::calcMinMax(unsigned int var, unsigned int time) const { app &ctx = _ctx ? *_ctx : app::instance(); - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); volume vol(ctx); const uint64 maxdim = 128; // read in 128^3 chunks diff --git a/src/cvc/vtk_io.cpp b/src/cvc/vtk_io.cpp index b5dce68b..d74d0781 100644 --- a/src/cvc/vtk_io.cpp +++ b/src/cvc/vtk_io.cpp @@ -353,9 +353,9 @@ struct vtk_io : public volume_file_io { // from a volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void getVolumeFileInfo(app & /*ctx*/, volume_file_info::data & /*d*/, + virtual void getVolumeFileInfo(app &ctx, volume_file_info::data & /*d*/, const std::string & /*filename*/) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); throw read_error("Reading VTK files doesn't work yet!"); } @@ -366,11 +366,11 @@ struct vtk_io : public volume_file_io { // Writes to a Volume object after reading from a volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void readVolumeFile(app & /*ctx*/, volume & /*vol*/, const std::string & /*filename*/, + virtual void readVolumeFile(app &ctx, volume & /*vol*/, const std::string & /*filename*/, unsigned int /*var*/, unsigned int /*time*/, uint64 /*off_x*/, uint64 /*off_y*/, uint64 /*off_z*/, const dimension & /*subvoldim*/) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); throw read_error("Reading VTK files doesn't work yet!"); } @@ -381,13 +381,13 @@ struct vtk_io : public volume_file_io { // Creates an empty volume file to be later filled in by writeVolumeFile // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void createVolumeFile(app & /*ctx*/, const std::string & /*filename*/, + virtual void createVolumeFile(app &ctx, const std::string & /*filename*/, const bounding_box & /*boundingBox*/, const dimension & /*dimension*/, const std::vector & /*voxelTypes*/, unsigned int /*numVariables*/, unsigned int /*numTimesteps*/, double /*min_time*/, double /*max_time*/) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); throw CVC_NAMESPACE::write_error("Writing VTK files doesn't work yet!"); } @@ -403,11 +403,11 @@ struct vtk_io : public volume_file_io { // createVolumeFile to replace the volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void writeVolumeFile(app & /*ctx*/, const volume & /*wvol*/, + virtual void writeVolumeFile(app &ctx, const volume & /*wvol*/, const std::string & /*filename*/, unsigned int /*var*/, unsigned int /*time*/, uint64 /*off_x*/, uint64 /*off_y*/, uint64 /*off_z*/) const { - thread_info ti(BOOST_CURRENT_FUNCTION); + thread_info ti(ctx, BOOST_CURRENT_FUNCTION); throw CVC_NAMESPACE::write_error("Writing VTK files doesn't work yet!"); } @@ -418,7 +418,7 @@ struct vtk_io : public volume_file_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_vtk_io(app & /*ctx*/) { +void register_vtk_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new vtk_io)); } } // namespace CVC_NAMESPACE From 5f65657d293aa11b9727469a675267b1ad4741f6 Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 16:28:44 -0500 Subject: [PATCH 6/7] hdf5_utils: delete ctx-less inline overloads 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). --- inc/cvc/hdf5_utils.h | 102 +----------------------------------- src/cvc/tests/hdf5_test.cpp | 18 ++++--- 2 files changed, 11 insertions(+), 109 deletions(-) diff --git a/inc/cvc/hdf5_utils.h b/inc/cvc/hdf5_utils.h index 80bfd855..77de3e30 100644 --- a/inc/cvc/hdf5_utils.h +++ b/inc/cvc/hdf5_utils.h @@ -1334,107 +1334,7 @@ inline void setAttribute(app &ctx, const std::string &hdf5_filename, setAttribute(ctx, hdf5_filename, hdf5_objname, attribname, std::string(value)); } -// ============================================================ -// Context-less convenience overloads (inject cvc::app::instance()) -// ============================================================ -inline bool isGroup(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return isGroup(app::instance(), hdf5_filename, hdf5_objname); -} - -inline bool isDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return isDataSet(app::instance(), hdf5_filename, hdf5_objname); -} - -inline bool objectExists(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return objectExists(app::instance(), hdf5_filename, hdf5_objname); -} - -inline void removeObject(const std::string &hdf5_filename, const std::string &hdf5_objname) { - removeObject(app::instance(), hdf5_filename, hdf5_objname); -} - -inline void createHDF5File(const std::string &hdf5_filename) { - createHDF5File(app::instance(), hdf5_filename); -} - -inline void createGroup(const std::string &hdf5_filename, const std::string &hdf5_objname, - bool replace = false) { - createGroup(app::instance(), hdf5_filename, hdf5_objname, replace); -} - -inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname, - const bounding_box &boundingBox, const dimension &dimension, - data_type dataType, const bool replace = false, - const bool createGroups = true) { - createDataSet(app::instance(), hdf5_filename, hdf5_objname, boundingBox, dimension, dataType, - replace, createGroups); -} - -inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname, - const dimension &dimension, data_type dataType, - const bool createGroups = true) { - createDataSet(app::instance(), hdf5_filename, hdf5_objname, dimension, dataType, createGroups); -} - -inline void createDataSet(const std::string &hdf5_filename, const std::string &hdf5_objname, - const std::string &value, bool createGroups = true) { - createDataSet(app::instance(), hdf5_filename, hdf5_objname, value, createGroups); -} - -inline dimension getObjectDimension(const std::string &hdf5_filename, - const std::string &hdf5_objname) { - return getObjectDimension(app::instance(), hdf5_filename, hdf5_objname); -} - -inline void setObjectDimension(const std::string &hdf5_filename, const std::string &hdf5_objname, - const dimension &dim) { - setObjectDimension(app::instance(), hdf5_filename, hdf5_objname, dim); -} - -inline dimension getDataSetDimensionForBoundingBox(const std::string &hdf5_filename, - const std::string &hdf5_objname, - const bounding_box &subvolbox) { - return getDataSetDimensionForBoundingBox(app::instance(), hdf5_filename, hdf5_objname, subvolbox); -} - -inline dimension getDataSetDimension(const std::string &hdf5_filename, - const std::string &hdf5_objname, const bounding_box &subvolbox, - const dimension &maxdim = dimension(256, 256, 256)) { - return getDataSetDimension(app::instance(), hdf5_filename, hdf5_objname, subvolbox, maxdim); -} - -inline bounding_box getObjectBoundingBox(const std::string &hdf5_filename, - const std::string &hdf5_objname) { - return getObjectBoundingBox(app::instance(), hdf5_filename, hdf5_objname); -} - -inline void setObjectBoundingBox(const std::string &hdf5_filename, const std::string &hdf5_objname, - const bounding_box &boundingBox) { - setObjectBoundingBox(app::instance(), hdf5_filename, hdf5_objname, boundingBox); -} - -inline double getDataSetMinimum(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return getDataSetMinimum(app::instance(), hdf5_filename, hdf5_objname); -} - -inline double getDataSetMaximum(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return getDataSetMaximum(app::instance(), hdf5_filename, hdf5_objname); -} - -inline std::string getDataSetInfo(const std::string &hdf5_filename, - const std::string &hdf5_objname) { - return getDataSetInfo(app::instance(), hdf5_filename, hdf5_objname); -} - -inline data_type getDataSetType(const std::string &hdf5_filename, const std::string &hdf5_objname) { - return getDataSetType(app::instance(), hdf5_filename, hdf5_objname); -} - -inline std::vector getChildObjects(const std::string &hdf5_filename, - const std::string &hdf5_objname = "/", - const std::string &filter = std::string()) { - return getChildObjects(app::instance(), hdf5_filename, hdf5_objname, filter); -} +// All hdf5_utils free functions require an explicit cvc::app context. } // namespace hdf5_utils } // namespace CVC_NAMESPACE diff --git a/src/cvc/tests/hdf5_test.cpp b/src/cvc/tests/hdf5_test.cpp index b5828f0b..3a9008a5 100644 --- a/src/cvc/tests/hdf5_test.cpp +++ b/src/cvc/tests/hdf5_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ using namespace CVC_NAMESPACE; class HDF5Test : public ::testing::Test { protected: std::string test_dir; + app ctx; virtual void SetUp() { // Create a unique directory for this test process. std::filesystem + @@ -248,11 +250,11 @@ TEST_F(HDF5Test, UnlinkDataSet) { hsize_t dims[1] = {10}; H5::DataSpace dataspace(1, dims); file->createDataSet("data_to_remove", H5::PredType::NATIVE_DOUBLE, dataspace); - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "data_to_remove")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "data_to_remove")); // Unlink it hdf5_utils::unlink(*file, "data_to_remove"); - EXPECT_FALSE(hdf5_utils::objectExists(filepath, "data_to_remove")); + EXPECT_FALSE(hdf5_utils::objectExists(ctx, filepath, "data_to_remove")); } } @@ -268,11 +270,11 @@ TEST_F(HDF5Test, UnlinkNestedObject) { hsize_t dims[1] = {10}; H5::DataSpace dataspace(1, dims); grp->createDataSet("data", H5::PredType::NATIVE_DOUBLE, dataspace); - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "group/subgroup/data")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "group/subgroup/data")); // Unlink it hdf5_utils::unlink(*file, "group/subgroup/data"); - EXPECT_FALSE(hdf5_utils::objectExists(filepath, "group/subgroup/data")); + EXPECT_FALSE(hdf5_utils::objectExists(ctx, filepath, "group/subgroup/data")); } } @@ -356,8 +358,8 @@ TEST_F(HDF5Test, MultipleGroupsAndDataSets) { } // Verify all groups were created - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "group0")); - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "group4")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "group0")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "group4")); } TEST_F(HDF5Test, MixedAttributes) { @@ -416,8 +418,8 @@ TEST_F(HDF5Test, CreateModifyRead) { { boost::shared_ptr file = hdf5_utils::getH5File(filepath, false); - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "data")); - EXPECT_TRUE(hdf5_utils::objectExists(filepath, "data/values")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "data")); + EXPECT_TRUE(hdf5_utils::objectExists(ctx, filepath, "data/values")); boost::shared_ptr dataset = hdf5_utils::getDataSet(*file, "data/values", false); From dcf64c5308cdb946ba06b8edbae48fef8ea405a8 Mon Sep 17 00:00:00 2001 From: Joe Rivera Date: Fri, 1 May 2026 16:50:48 -0500 Subject: [PATCH 7/7] clang-format: reformat changed lines per CI Apply clang-format-18 to files touched in this branch so the clang-format (changed lines) CI check passes. --- src/cvc/hdf5_io.cpp | 11 +++++------ src/cvc/libcvc.cpp | 3 +-- src/cvc/mrc_io.cpp | 16 +++++++--------- src/cvc/rawiv_io.cpp | 6 +++--- src/cvc/rawv_io.cpp | 6 +++--- src/cvc/spider_io.cpp | 6 +++--- src/cvc/vtk_io.cpp | 11 ++++------- 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/cvc/hdf5_io.cpp b/src/cvc/hdf5_io.cpp index 2e165d75..aad74c8b 100644 --- a/src/cvc/hdf5_io.cpp +++ b/src/cvc/hdf5_io.cpp @@ -456,9 +456,9 @@ struct hdf5_io : public volume_file_io { // 08/05/2011 -- Joe R. -- Using HDF5 Utilities now. // 09/09/2011 -- Joe R. -- Adding support for ungrouped, lone datasets to make // multi-res hierarchy thread code simpler. - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { using namespace H5; using namespace hdf5_utils; using namespace boost; @@ -542,9 +542,8 @@ struct hdf5_io : public volume_file_io { // multi-res hierarchy thread code simpler. // 09/17/2011 -- Joe R. -- Picking out the closest dimension to the maxdim in // the hierarchy. - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, - const bounding_box &subvolbox) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, const bounding_box &subvolbox) const { using namespace hdf5_utils; using namespace boost; diff --git a/src/cvc/libcvc.cpp b/src/cvc/libcvc.cpp index 2d698524..85d17283 100644 --- a/src/cvc/libcvc.cpp +++ b/src/cvc/libcvc.cpp @@ -20,8 +20,7 @@ namespace { * Commands */ -typedef boost::function &)> - command_func; +typedef boost::function &)> command_func; typedef boost::tuple command; typedef std::map command_map; command_map commands; diff --git a/src/cvc/mrc_io.cpp b/src/cvc/mrc_io.cpp index 44522740..e9e1a670 100644 --- a/src/cvc/mrc_io.cpp +++ b/src/cvc/mrc_io.cpp @@ -468,9 +468,9 @@ struct mrc_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; @@ -1112,9 +1112,9 @@ struct imod_mrc_io : public mrc_io { // Writes to a Volume object after reading from a volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { using namespace std; using namespace boost; thread_info ti(ctx, BOOST_CURRENT_FUNCTION); @@ -1208,7 +1208,5 @@ struct imod_mrc_io : public mrc_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_mrc_io(app &ctx) { - volume_file_io::insertHandler(volume_file_io::ptr(new mrc_io)); -} +void register_mrc_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new mrc_io)); } } // namespace CVC_NAMESPACE diff --git a/src/cvc/rawiv_io.cpp b/src/cvc/rawiv_io.cpp index 90e31dda..b853cb27 100644 --- a/src/cvc/rawiv_io.cpp +++ b/src/cvc/rawiv_io.cpp @@ -292,9 +292,9 @@ struct rawiv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/13/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; diff --git a/src/cvc/rawv_io.cpp b/src/cvc/rawv_io.cpp index 9127c0e4..953c416f 100644 --- a/src/cvc/rawv_io.cpp +++ b/src/cvc/rawv_io.cpp @@ -296,9 +296,9 @@ struct rawv_io : public volume_file_io { // ---- Change History ---- // ??/??/2007 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); char buf[256]; diff --git a/src/cvc/spider_io.cpp b/src/cvc/spider_io.cpp index 07005613..2bba7614 100644 --- a/src/cvc/spider_io.cpp +++ b/src/cvc/spider_io.cpp @@ -623,9 +623,9 @@ struct spider_io : public volume_file_io { // ??/??/2008 -- Joe R. -- Creation. // 11/20/2009 -- Joe R. -- Converted to a volume_file_io class. // 12/11/2009 -- Joe R. -- Freeing data buffer. - virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, - unsigned int var, unsigned int time, uint64 off_x, uint64 off_y, - uint64 off_z, const dimension &subvoldim) const { + virtual void readVolumeFile(app &ctx, volume &vol, const std::string &filename, unsigned int var, + unsigned int time, uint64 off_x, uint64 off_y, uint64 off_z, + const dimension &subvoldim) const { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); int dim[3]; diff --git a/src/cvc/vtk_io.cpp b/src/cvc/vtk_io.cpp index d74d0781..e306cc2a 100644 --- a/src/cvc/vtk_io.cpp +++ b/src/cvc/vtk_io.cpp @@ -403,10 +403,9 @@ struct vtk_io : public volume_file_io { // createVolumeFile to replace the volume file. // ---- Change History ---- // 11/20/2009 -- Joe R. -- Creation. - virtual void writeVolumeFile(app &ctx, const volume & /*wvol*/, - const std::string & /*filename*/, unsigned int /*var*/, - unsigned int /*time*/, uint64 /*off_x*/, uint64 /*off_y*/, - uint64 /*off_z*/) const { + virtual void writeVolumeFile(app &ctx, const volume & /*wvol*/, const std::string & /*filename*/, + unsigned int /*var*/, unsigned int /*time*/, uint64 /*off_x*/, + uint64 /*off_y*/, uint64 /*off_z*/) const { thread_info ti(ctx, BOOST_CURRENT_FUNCTION); throw CVC_NAMESPACE::write_error("Writing VTK files doesn't work yet!"); } @@ -418,7 +417,5 @@ struct vtk_io : public volume_file_io { } // namespace CVC_NAMESPACE namespace CVC_NAMESPACE { -void register_vtk_io(app &ctx) { - volume_file_io::insertHandler(volume_file_io::ptr(new vtk_io)); -} +void register_vtk_io(app &ctx) { volume_file_io::insertHandler(volume_file_io::ptr(new vtk_io)); } } // namespace CVC_NAMESPACE