XdmfGridCollection.hpp 2.68 KB
Newer Older
1 2 3
#ifndef XDMFGRIDCOLLECTION_HPP_
#define XDMFGRIDCOLLECTION_HPP_

4 5 6
// Forward Declarations
class XdmfGridCollectionType;

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

/**
 * @brief A spatial or temporal collection of XdmfGrids.
 *
 * A temporal collection is timestep data.  Each child grid represents the state at a single timestep.
 * A spatial collection consists of XdmfGrids that are arranged together in space.  E.g. a partitioned mesh.
 *
 * It is valid to nest collections.  A spatial collection within a temporal collection is commonly used.
 */
class XdmfGridCollection : public XdmfGrid {

public:

	XdmfNewMacro(XdmfGridCollection);
23 24
	virtual ~XdmfGridCollection();

25
	LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid)
26
	static const std::string ItemTag;
27 28 29 30 31 32 33

	/**
	 * Get a grid from this collection.
	 *
	 * @param index of grid to retrieve.
	 * @return the requested XdmfGrid.
	 */
34
	boost::shared_ptr<XdmfGrid> getGrid(const unsigned int index);
35 36 37 38 39 40 41

	/**
	 * Get a grid from this collection (const version).
	 *
	 * @param index of the grid to retrieve.
	 * @return the requested XdmfGrid.
	 */
42
	boost::shared_ptr<const XdmfGrid> getGrid(const unsigned int index) const;
43 44 45 46 47 48 49 50 51 52

	std::map<std::string, std::string> getItemProperties() const;

	/**
	 * Get the number of grids in this collection.
	 *
	 * @return unsigned int containing the number of XdmfGrids in this collection.
	 */
	unsigned int getNumberOfGrids() const;

53 54 55 56 57 58 59
	/**
	 * Get the XdmfGridCollectionType associated with this grid collection.
	 *
	 * @return XdmfGridCollectionType of this collection.
	 */
	boost::shared_ptr<const XdmfGridCollectionType> getType() const;

60 61 62 63 64
	/**
	 * Insert a grid into this collection.
	 *
	 * @param grid an XdmfGrid to insert into this collection.
	 */
65
	void insert(const boost::shared_ptr<XdmfGrid> grid);
66 67 68 69 70 71 72 73 74 75 76 77 78

	/**
	 * Remove a grid from this collection.
	 *
	 * @param index of the XdmfGrid to remove.
	 */
	void removeGrid(const unsigned int index);

	/**
	 * Set the XdmfGridCollectionType associated with this grid collection.
	 *
	 * @param collectionType the XdmfGridCollectionType to set.
	 */
79
	void setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
80

81
	virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
82 83 84 85 86 87 88 89 90 91 92

protected:

	XdmfGridCollection();
	virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);

private:

	XdmfGridCollection(const XdmfGridCollection & collection);  // Not implemented.
	void operator=(const XdmfGridCollection & collection);  // Not implemented.

93
	boost::shared_ptr<const XdmfGridCollectionType> mCollectionType;
94 95 96 97
	std::vector<boost::shared_ptr<XdmfGrid> > mGrids;
};

#endif /* XDMFGRID_HPP_ */