#include "Hdf5Resource.h"Go to the source code of this file.
Classes | |
| class | Hdf5CustomWriter |
| This interface should be implemented to allow a custom type to be written by the HdfPlugInLib. More... | |
Functions | |
| template<typename T> | |
| Hdf5CustomWriter * | createHdf5CustomWriter () |
| Hdf5CustomWriter* createHdf5CustomWriter | ( | ) |
This function should be specialized for any custom types that need to be written using the HdfUtilities::writeAttribute() or HdfUtilities::writeDataset() functions.
An example is shown below:
struct mySampleType { int foo; int bar; }; class mySampleTypeWriter; //assume this is declared elsewhere as class mySampleTypeWriter : public Hdf5CustomWriter //Want to write mySampleType using Hdf5Utilities::writeAttribute() function. template<> Hdf5CustomWriter* createHdf5CustomWriter<mySampleType>() { return new mySampleTypeWriter(); } //now to write the data as an attribute. //assume groupId is a hid_t of the HDF5 group we want to write the attribute to. mySampleType sampleData; sampleData.foo = 3; sampleData.bar = 100; HdfUtilities::writeAttribute(groupId, "myAttribute", sampleData); //the writeAttribute call above will use your createHdf5CustomWriter specialization and your subclass //of Hdf5CustomWriter to perform the write of mySampleType to the Hdf5 file as an HDF5 attribute. //now to write the data to a dataset //assume fd is hid_t which is an open HDF5 file handle HdfUtilities::writeDataset(fd, "/Level1/Level2/MySampleDataset", sampleData); //the writeDataset call above will use your createHdf5CustomWriter specialization and your subclass //of Hdf5CustomWriter to perform the write of mySampleType to the Hdf5 file as an HDF5 dataset.