diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2021-05-03 21:55:26 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2021-05-03 21:55:26 (GMT) |
commit | 0ab5dd5e8ea2342ef039f0f79bd76e4ab187dddf (patch) | |
tree | 6900490d46d768f991e7cc91d45d4f8dc17985a4 /doxygen/examples/H5Pset_object_flush_cb.c | |
parent | fca509b7d61b9dffae85be3406ca484c1bf28242 (diff) | |
download | hdf5-0ab5dd5e8ea2342ef039f0f79bd76e4ab187dddf.zip hdf5-0ab5dd5e8ea2342ef039f0f79bd76e4ab187dddf.tar.gz hdf5-0ab5dd5e8ea2342ef039f0f79bd76e4ab187dddf.tar.bz2 |
Brings more develop code over, especially Doxygen
Diffstat (limited to 'doxygen/examples/H5Pset_object_flush_cb.c')
-rw-r--r-- | doxygen/examples/H5Pset_object_flush_cb.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/doxygen/examples/H5Pset_object_flush_cb.c b/doxygen/examples/H5Pset_object_flush_cb.c new file mode 100644 index 0000000..1dfa90d --- /dev/null +++ b/doxygen/examples/H5Pset_object_flush_cb.c @@ -0,0 +1,41 @@ +hid_t file_id, fapl_id; +hid_t dataset_id, dapl_id; +unsigned counter; + +/* Create a copy of the file access property list */ +fapl_id = H5Pcreate(H5P_FILE_ACCESS); + +/* Set up the object flush property values */ +/* flush_cb: callback function to invoke when an object flushes (see below) */ +/* counter: user data to pass along to the callback function */ +H5Pset_object_flush_cb(fapl_id, flush_cb, &counter); + +/* Open the file */ +file_id = H5Fopen(FILE, H5F_ACC_RDWR, H5P_DEFAULT); + +/* Create a group */ +gid = H5Gcreate2(fid, “group”, H5P_DEFAULT, H5P_DEFAULT_H5P_DEFAULT); + +/* Open a dataset */ +dataset_id = H5Dopen2(file_id, DATASET, H5P_DEFAULT); + +/* The flush will invoke flush_cb() with counter */ +H5Dflush(dataset_id); +/* counter will be equal to 1 */ + +/* ... */ + +/* The flush will invoke flush_cb() with counter */ +H5Gflush(gid); +/* counter will be equal to 2 */ + +/* ... */ + +/* The callback function for object flush property */ +static herr_t +flush_cb(hid_t obj_id, void *_udata) +{ + unsigned *flush_ct = (unsigned *)_udata; + ++(*flush_ct); + return 0; +} |