XdmfVisitor.hpp 3.61 KB
Newer Older
1 2 3 4
#ifndef XDMFVISITOR_HPP_
#define XDMFVISITOR_HPP_

// Forward Declarations
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
5
class XdmfArray;
6
class XdmfAttribute;
Kenneth Leiter's avatar
Kenneth Leiter committed
7
class XdmfDomain;
8 9 10
class XdmfGeometry;
class XdmfGrid;
class XdmfTopology;
11 12

// Includes
13
#include <hdf5.h>
14
#include <libxml/tree.h>
15
#include <sstream>
16
#include <vector>
17 18
#include "XdmfObject.hpp"

19 20 21 22 23 24 25
/**
 * @brief Traverses the Xdmf graph and writes the data stored to disk.
 *
 * XdmfVisitor visits each node of an Xdmf graph structure and writes the data to disk.  Xdmf files are written to disk
 * by performing a visitor operation.  Writing begins by calling the write() operation on any XdmfItem and supplying an
 * XdmfVisitor as the parameter.  The XdmfItem as well as all children attached to the XdmfItem are written to disk.
 */
26 27 28 29 30
class XdmfVisitor : public XdmfObject {

public:

	XdmfNewMacro(XdmfVisitor);
31

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
	/**
	 * Get the number of values that this visitor writes to light data (XML) before switching to a heavy data format.
	 *
	 * @return an unsigned int containing the number of values.
	 */
	unsigned int getLightDataLimit() const;

	virtual std::string printSelf() const;

	/**
	 * Set the number of values that this visitor writes to light data (XML) before switching to a heavy data format.
	 *
	 * @param numValues an unsigned int containing the number of values.
	 */
	void setLightDataLimit(unsigned int numValues);

	/**
	 * Write an XdmfArray to disk
	 *
	 * @param array a pointer to an XdmfArray to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
	 */
54
	virtual void visit(const XdmfArray * const array, boost::shared_ptr<XdmfVisitor> visitor);
55

56 57 58 59 60 61
	/**
	 * Write an XdmfAttribute to disk
	 *
	 * @param attribute a pointer to an XdmfAttribute to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
	 */
62
	virtual void visit(const XdmfAttribute * const attribute, boost::shared_ptr<XdmfVisitor> visitor);
63

64 65 66 67 68 69
	/**
	 * Write an XdmfDomain to disk
	 *
	 * @param domain a pointer to an XdmfDomain to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
	 */
70
	virtual void visit(const XdmfDomain * const domain, boost::shared_ptr<XdmfVisitor> visitor);
Kenneth Leiter's avatar
Kenneth Leiter committed
71

72 73 74 75 76 77
	/**
	 * Write an XdmfGeometry to disk
	 *
	 * @param geometry a pointer to an XdmfGeometry to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
	 */
78
	virtual void visit(const XdmfGeometry * const geometry, boost::shared_ptr<XdmfVisitor> visitor);
79

80
	/**
81
	 * Write an XdmfGrid to disk
82
	 *
83 84
	 * @param grid a pointer to an XdmfGrid to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
85
	 */
86
	virtual void visit(const XdmfGrid * const grid, boost::shared_ptr<XdmfVisitor> visitor);
87 88

	/**
89
	 * Write an XdmfTopology to disk
90
	 *
91 92
	 * @param topology a pointer to an XdmfTopology to write to disk.
	 * @param visitor a smart pointer to this XdmfVisitor --- aids in grid traversal.
93
	 */
94
	virtual void visit(const XdmfTopology * const topology, boost::shared_ptr<XdmfVisitor> visitor);
95

96 97 98 99 100 101 102
protected:

	XdmfVisitor();
	virtual ~XdmfVisitor();

private:

103 104
	XdmfVisitor(const XdmfVisitor & visitor);  // Not implemented.
	void operator=(const XdmfVisitor & visitor);  // Not implemented.
105

106 107 108 109 110
	/**
	 * Uses the dataHierarchy to construct an appropriate hdf5 group name at the current point in writing.
	 *
	 * @return a string containing the hdf5 group name.
	 */
111 112 113
	std::string getHDF5GroupName();

	std::vector<std::string> dataHierarchy;
114
	hid_t hdf5Handle;
115
	std::string mHeavyFileName;
116
	unsigned int mLightDataLimit;
117 118
	xmlDocPtr xmlDocument;
	xmlNodePtr xmlCurrentNode;
119 120 121
};

#endif /* XDMFVISITOR_HPP_ */