OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Hdf5ObjectCreation.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2
11
12#pragma once
13#include <hdf5.h>
14
15namespace openswmm::io {
16namespace detail {
17// Result images carry simulation time in their datasets. Wall-clock object
18// timestamps would make equal accepted states produce different checkpoints.
33template <class Create> inline hid_t createHdf5Object(hid_t kind, hid_t properties, Create create) {
34 const hid_t owned = properties == H5P_DEFAULT ? H5Pcreate(kind) : H5Pcopy(properties);
35 if (owned < 0)
36 return -1;
37 const hid_t result = H5Pset_obj_track_times(owned, 0) >= 0 ? create(owned) : -1;
38 H5Pclose(owned);
39 return result;
40}
41}
42
55inline hid_t createHdf5Dataset(hid_t location, const char* name, hid_t type, hid_t space,
56 hid_t links, hid_t creation, hid_t access) {
57 return detail::createHdf5Object(H5P_DATASET_CREATE, creation, [&](hid_t properties) {
58 return H5Dcreate2(location, name, type, space, links, properties, access);
59 });
60}
61
72inline hid_t createHdf5Group(hid_t location, const char* name, hid_t links, hid_t creation,
73 hid_t access) {
74 return detail::createHdf5Object(H5P_GROUP_CREATE, creation, [&](hid_t properties) {
75 return H5Gcreate2(location, name, links, properties, access);
76 });
77}
78
88inline hid_t createHdf5File(const char* path, unsigned flags, hid_t creation, hid_t access) {
89 return detail::createHdf5Object(H5P_FILE_CREATE, creation, [&](hid_t properties) {
90 return H5Fcreate(path, flags, properties, access);
91 });
92}
93}
Definition Hdf5ObjectCreation.hpp:16
hid_t createHdf5Object(hid_t kind, hid_t properties, Create create)
Create an HDF5 object with wall-clock object timestamps disabled.
Definition Hdf5ObjectCreation.hpp:33
Definition AtomicOutputFile.hpp:25
hid_t createHdf5Dataset(hid_t location, const char *name, hid_t type, hid_t space, hid_t links, hid_t creation, hid_t access)
Create a dataset without wall-clock object timestamps.
Definition Hdf5ObjectCreation.hpp:55
hid_t createHdf5Group(hid_t location, const char *name, hid_t links, hid_t creation, hid_t access)
Create a group without wall-clock object timestamps.
Definition Hdf5ObjectCreation.hpp:72
hid_t createHdf5File(const char *path, unsigned flags, hid_t creation, hid_t access)
Create an HDF5 file without wall-clock object timestamps.
Definition Hdf5ObjectCreation.hpp:88