Updates will be applied today, at 4 pm EDT (UTC-0400). No interruption, and site should remain available.

XdmfHDF5Controller.hpp 2.32 KB
Newer Older
1 2 3
#ifndef XDMFHDF5CONTROLLER_HPP_
#define XDMFHDF5CONTROLLER_HPP_

4 5 6
// Forward Declarations
class XdmfArray;

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// Includes
#include "XdmfObject.hpp"

/**
 * @brief Couples an XdmfArray with HDF5 data stored on disk.
 *
 * Serves as an interface between data stored in XdmfArrays and data stored on disk.  When an Xdmf file is read from or
 * written to disk an XdmfHDF5Controller is attached to XdmfArrays.  This allows data to be released
 * from memory but still be accessible or have its location written to light data.
 */
class XdmfHDF5Controller : public XdmfObject {

public:

	template <typename T> friend void boost::checked_delete(T * x);

	/**
	 * Create a new controller for an hdf5 data set on disk.
	 */
26
	static boost::shared_ptr<XdmfHDF5Controller> New(const std::string & hdf5DataSetPath, const int precision, const int size, const std::string & type)
27
	{
28
		boost::shared_ptr<XdmfHDF5Controller> p(new XdmfHDF5Controller(hdf5DataSetPath, precision, size, type));
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		return p;
	}

	/**
	 * Get the path to the hdf5 data set on disk owned by this controller.
	 *
	 * @return a std::string to the hdf5 data set location on disk.
	 */
	std::string getDataSetPath() const;

	/**
	 * Get the precision of the hdf5 data set owned by this controller.
	 *
	 * @return a int containing the precision of the hdf5 data set.
	 */
	int getPrecision() const;

	/**
	 * Get the size of the hdf5 data set owned by this controller.
	 *
	 * @return a int containing the size of the hdf5 data set.
	 */
	int getSize() const;

	/**
	 * Get the data type of the hdf5 data set owned by this controller.
	 *
	 * @return a std::string containing the name of the data type of the hdf5 data set.
	 */
	std::string getType() const;

60 61 62 63 64 65 66
	/**
	 * Read data owned by this controller on disk into the passed XdmfArray.
	 *
	 * @param array and XdmfArray to read data into.
	 */
	void read(XdmfArray * const array);

67 68
protected:

69
	XdmfHDF5Controller(const std::string & hdf5DataSetPath, const int precision, const int size, const std::string & type);
70 71 72 73 74 75 76
	virtual ~XdmfHDF5Controller();

private:

	XdmfHDF5Controller(const XdmfHDF5Controller & hdf5Controller);  // Not implemented.
	void operator=(const XdmfHDF5Controller & hdf5Controller);  // Not implemented.

77 78
	std::string mDataSetName;
	std::string mHDF5FilePath;
79 80 81 82 83 84
	int mPrecision;
	int mSize;
	std::string mType;
};

#endif /* XDMFHDF5CONTROLLER_HPP_ */