XdmfHDF5Writer.hpp 4.88 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfHDF5Writer.hpp                                                  */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/

24 25 26
#ifndef XDMFHDF5WRITER_HPP_
#define XDMFHDF5WRITER_HPP_

27 28 29 30
// Forward Declarations
class XdmfArrayType;
class XdmfHDF5Controller;

31
// Includes
32
#include "XdmfCore.hpp"
33
#include "XdmfHeavyDataWriter.hpp"
34 35

/**
36 37
 * @brief Traverse the Xdmf graph and write heavy data stored in
 * XdmfArrays to HDF5 on disk.
38
 *
39 40 41 42 43 44
 * 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. The writer will write all XdmfArrays under the XdmfItem
 * to an hdf5 file on disk. It will also attach an XdmfHDF5Controller
 * to all XdmfArrays that it writes to disk.
45
 *
46 47
 * This writer supports all heavy data writing modes listed in
 * XdmfHeavyDataWriter.
48
 */
49
class XDMFCORE_EXPORT XdmfHDF5Writer : public XdmfHeavyDataWriter {
50

51
public:
52

53
  /**
54
   * Construct XdmfHDF5Writer.
55 56
   *
   * @param filePath the location of the hdf5 file to output to on disk.
57
   * @param clobberFile whether to overwrite the previous file if it exists.
58 59 60
   *
   * @return new XdmfHDF5Writer.
   */
61 62
  static shared_ptr<XdmfHDF5Writer> New(const std::string & filePath,
                                        const bool clobberFile = false);
63

64
  virtual ~XdmfHDF5Writer();
65

66
  virtual void closeFile();
67

68
  virtual void openFile();
69

70
  virtual void visit(XdmfArray & array,
71
                     const shared_ptr<XdmfBaseVisitor> visitor);
72

73
protected:
74

75
  XdmfHDF5Writer(const std::string & filePath);
76

77
  /**
78 79
   * Create a new HDF5 Controller that is able to read in after being
   * written by this writer.
80 81 82 83
   *
   * @param hdf5FilePath the location of the hdf5 file the data set resides in.
   * @param dataSetPath the location of the dataset within the hdf5 file.
   * @param type the data type of the dataset to read.
84 85 86 87 88 89
   * @param start the offset of the starting element in each dimension in
   * the hdf5 data set.
   * @param stride the number of elements to move in each dimension from the
   * hdf5 data set.
   * @param count the number of elements to select in each dimension from the
   * hdf5 data set. (size in each dimension)
90 91 92
   *
   * @return new HDF5 Controller.
   */
93
  virtual shared_ptr<XdmfHDF5Controller>
94 95
  createHDF5Controller(const std::string & hdf5FilePath,
                       const std::string & dataSetPath,
96
                       const shared_ptr<const XdmfArrayType> type,
97 98 99
                       const std::vector<unsigned int> & start,
                       const std::vector<unsigned int> & stride,
                       const std::vector<unsigned int> & count);
100

101 102 103 104 105 106 107
  /**
   * Open hdf5 file with a fapl.
   *
   * @param fapl the file access property list for the hdf5 file.
   */
  void openFile(const int fapl);

108 109 110 111 112 113 114
  /**
   * Write the XdmfArray to a hdf5 file.
   *
   * @param array an XdmfArray to write to hdf5.
   * @param fapl the file access property list for the hdf5 file on disk.
   */
  void write(XdmfArray & array, const int fapl);
115

116
private:
117

118 119 120 121 122
  /**
   * PIMPL
   */
  class XdmfHDF5WriterImpl;

123 124
  XdmfHDF5Writer(const XdmfHDF5Writer &);  // Not implemented.
  void operator=(const XdmfHDF5Writer &);  // Not implemented.
125 126 127

  XdmfHDF5WriterImpl * mImpl;

128 129
};

130
#endif /* XDMFHDF5WRITER_HPP_ */