XdmfHDF5Writer.hpp 1.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef XDMFHDF5WRITER_HPP_
#define XDMFHDF5WRITER_HPP_

// Forward Declarations
class XdmfArray;

// Includes
#include "XdmfVisitor.hpp"

/**
 * @brief Traverse the Xdmf graph and write heavy data stored in XdmfArrays to HDF5 on disk.
 *
 * XdmfHDF5Writer traverses an Xdmf graph structure and writes data stored in XdmfArrays to HDF5.
 * Writing begins by calling the accept() operation on any XdmfItem and supplying this writer
 * as the parameter.
 */
class XdmfHDF5Writer : public XdmfVisitor,
18
	public Loki::Visitor<XdmfArray> {
19 20 21

public:

22
	template <typename T> friend void boost::checked_delete(T * x);
23 24 25 26 27 28 29

	/**
	 * Construct XdmfHDF5Writer
	 *
	 * @param hdf5FilePath the location of the hdf5 file to output to on disk.
	 */
	static boost::shared_ptr<XdmfHDF5Writer> New(const std::string & hdf5FilePath)
30 31 32 33
	{
		boost::shared_ptr<XdmfHDF5Writer> p(new XdmfHDF5Writer(hdf5FilePath));
		return p;
	}
34

35 36 37 38 39 40 41
	/**
	 * Get the path to the last written data set written by this writer.
	 *
	 * @return the path to the last written data set.
	 */
	std::string getLastWrittenDataSet() const;

42 43 44 45 46 47
	/**
	 * Write an XdmfArray to HDF5.
	 *
	 * @param array an XdmfArray to write to HDF5.
	 * @param visitor a smart pointer to this visitor --- aids in grid traversal.
	 */
48
	void visit(XdmfArray & array, boost::shared_ptr<Loki::BaseVisitor> visitor);
49 50 51

protected:

52
	XdmfHDF5Writer(const std::string & hdf5FilePath);
53 54 55 56
	virtual ~XdmfHDF5Writer();

private:

57 58 59 60 61
	/**
	 * PIMPL
	 */
	class XdmfHDF5WriterImpl;

62 63 64
	// Variant Visitor Operation
	class GetHDF5Type;

65 66 67
	XdmfHDF5Writer(const XdmfHDF5Writer & hdf5Writer);  // Not implemented.
	void operator=(const XdmfHDF5Writer & hdf5Writer);  // Not implemented.

68
	XdmfHDF5WriterImpl * mImpl;
69 70
};

71
#endif /* XDMFHDF5WRITER_HPP_ */