OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Hdf5Util.hpp File Reference

RAII handles and columnar table helpers over the raw HDF5 C API. More...

#include <hdf5.h>
#include <cstdint>
#include <string>
#include <vector>
Include dependency graph for Hdf5Util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  openswmm::h5io::Handle
 Owns an hid_t and closes it with the right H5*close on scope exit. More...
 

Namespaces

namespace  openswmm
 
namespace  openswmm::h5io
 

Functions

Handle openswmm::h5io::make_string_type ()
 A variable-length UTF-8 string type, for name columns.
 
Handle openswmm::h5io::open_file_readonly (const std::string &path)
 Open an existing HDF5 file for read-only access.
 
std::string openswmm::h5io::column_units (hid_t group, const std::string &column)
 A column's units attribute, or "" when it has none.
 
Handle openswmm::h5io::make_group (hid_t loc, const std::string &name)
 Create (or open) a group, creating intermediate groups as needed.
 
Handle openswmm::h5io::open_group (hid_t loc, const std::string &name)
 Open an existing HDF5 group.
 
bool openswmm::h5io::has_link (hid_t loc, const std::string &name)
 True when loc contains name.
 
bool openswmm::h5io::write_attr (hid_t loc, const std::string &name, const std::string &value)
 Create or replace a scalar std::string attribute.
 
bool openswmm::h5io::write_attr (hid_t loc, const std::string &name, double value)
 Create or replace a scalar double attribute.
 
bool openswmm::h5io::write_attr (hid_t loc, const std::string &name, int value)
 Create or replace a scalar int attribute.
 
bool openswmm::h5io::read_attr (hid_t loc, const std::string &name, std::string &out)
 Read a scalar attribute as std::string.
 
bool openswmm::h5io::read_attr (hid_t loc, const std::string &name, double &out)
 Read a scalar attribute as double.
 
bool openswmm::h5io::read_attr (hid_t loc, const std::string &name, int &out)
 Read a scalar attribute as int.
 
bool openswmm::h5io::write_column (hid_t group, const std::string &name, const std::vector< double > &values, const std::string &units="", const std::string &description="", int compression=4)
 Create a one-dimensional double column with optional metadata.
 
bool openswmm::h5io::write_column (hid_t group, const std::string &name, const std::vector< int > &values, const std::string &units="", const std::string &description="", int compression=4)
 Create a one-dimensional int column with optional metadata.
 
bool openswmm::h5io::write_column (hid_t group, const std::string &name, const std::vector< std::string > &values, const std::string &description="", int compression=4)
 Create a one-dimensional std::string column with optional metadata.
 
bool openswmm::h5io::read_column (hid_t group, const std::string &name, std::vector< double > &out)
 Read a one-dimensional column into a double vector.
 
bool openswmm::h5io::read_column (hid_t group, const std::string &name, std::vector< int > &out)
 Read a one-dimensional column into a int vector.
 
bool openswmm::h5io::read_column (hid_t group, const std::string &name, std::vector< std::string > &out)
 Read a one-dimensional column into a std::string vector.
 
std::size_t openswmm::h5io::column_length (hid_t group, const std::string &probe)
 Row count of a group's columns — the length of probe, or 0 if absent.
 

Detailed Description

RAII handles and columnar table helpers over the raw HDF5 C API.

The model format is columnar: one group per object class, one equal-length 1-D dataset per attribute (see STRATEGY.md §3). Nearly every write is therefore "here is a vector of doubles / ints / strings, call it `length`, and say its units are feet". These helpers reduce that to one line so the writer reads as a schema rather than as HDF5 boilerplate.

Raw C HDF5 (hdf5.h, hid_t) deliberately — it is what Default2DOutputPlugin uses, and HDF5 is PRIVATE-linked with hidden symbols because a consumer linking its own copy (the Qt GUI does) otherwise dies in H5_term_library on foreign global state.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License
Apache-2.0