Hdf5CustomReader.h File Reference

#include "Hdf5Resource.h"
#include <hdf5.h>
#include <vector>

Go to the source code of this file.

Classes

class  Hdf5CustomReader
 This interface should be implemented to allow a custom type to be read by the HdfPlugInLib. More...

Functions

template<typename T>
Hdf5CustomReadercreateHdf5CustomReader (hid_t dataType)


Function Documentation

template<typename T>
Hdf5CustomReader* createHdf5CustomReader ( hid_t  dataType  ) 

This function should be specialized for any custom types that need to be read using the Hdf5Data::readData() function which is provided for both Hdf5Dataset and Hdf5Attribute.

An example is shown below:

 struct mySampleType
 {
   int foo;
   int bar;
 };

 class mySampleTypeReader; //assume this is declared elsewhere as class mySampleTypeReader : public Hdf5CustomReader
 //Want to read mySampleType using Hdf5Data::readData function
 template<>
 Hdf5CustomReader* createHdf5CustomReader<mySampleType>(hid_t dataType)
 {
    return new mySampleTypeReader(dataType);  
 }

 //now to read the data, assume pData is a pointer of type Hdf5Data, ie. Hdf5Dataset or Hdf5Attribute
 mySampleType* pSampleData = pData->readData<mySampleType>();
 //the read call above will use your createHdf5CustomReader specialization and your subclass
 //of Hdf5CustomReader to perform the read from the Hdf5 file and conversion to mySampleType.

Parameters:
dataType This is the HDF5 datatype of the data that will be read.
Returns:
Returns an Hdf5CustomReader implementation that is suitable for reading the given type from a HDF5 file. If the given dataType is unsupported by the reader either NULL can be returned from this method or the Hdf5CustomReader instance returned from this method can return false from Hdf5CustomReader::isValid().


Software Development Kit - Opticks 4.9.0 Build 16218