ess-dmsc / h5cpp

C++ wrapper for the HDF5 C-library
https://ess-dmsc.github.io/h5cpp/
GNU Lesser General Public License v2.1
116 stars 19 forks source link

How to add custom drivers non-intrusively? #650

Open FlyingSamson opened 3 months ago

FlyingSamson commented 3 months ago

For the project I'm currently working on, I need to write a custom driver.

Inheriting from hdf5::file::Driver works per se, but to overload the pure virtual function id() I need to return a hdf5::file::DriverID, which currently is limited to Posix, Direct, Memory, and MPI.

I could not find any reference to hdf5::file::DriverID other than the once in the existing drivers id() functions, so I'm not sure what the intended use id() is.

Would it be feasible to add another choice (e.g., Custom) to the hdf5::file::DriverID enum?

Alternatively, if the ID should remain unique even when multiple custom drivers are to be used, one might also consider some form of registration, that hands out unique integer ids for each driver. In any case I believe driver should be implemented as an open set, since hdf5 itself implements it that way. The implementation using the enum class makes this difficult, as it inherently makes it a closed set.

jkotan commented 3 months ago

Yes, it would be nice to support H5Pset_driver and H5Pget_driver . I would think about a solution which is backward compatible