00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef HDF5GROUP_H 00011 #define HDF5GROUP_H 00012 00013 #include <string> 00014 #include <vector> 00015 00016 #include "Hdf5Element.h" 00017 #include "TypesFile.h" 00018 00019 class Hdf5Dataset; 00020 class Hdf5Node; 00021 00022 /** 00023 * The %Hdf5Group class is a composite object to hierarchically store groups and datasets. 00024 */ 00025 class Hdf5Group : public Hdf5Element 00026 { 00027 public: 00028 /** 00029 * Adds a dataset to the HDF group. 00030 * 00031 * @param name 00032 * The name of the dataset to add. 00033 * 00034 * @return A pointer to the newly added HDF dataset. Returns NULL if the operation failed. 00035 * 00036 * @see Hdf5Dataset::Hdf5Dataset() 00037 */ 00038 virtual Hdf5Dataset* addDataset(const std::string& name); 00039 00040 /* 00041 * Adds a group to the %Hdf5Group. 00042 * 00043 * @return A pointer to the newly added HDF group object. Returns NULL if the operation failed. 00044 */ 00045 virtual Hdf5Group* addGroup(const std::string& name); 00046 00047 /** 00048 * Returns a vector of the group's elements. 00049 * 00050 * @return A vector of the group's elements. 00051 */ 00052 virtual const std::vector<Hdf5Element*>& getElements() const; 00053 00054 /** 00055 * Non-recursively searches the group's element for a dataset matching the input name. 00056 * 00057 * @param name 00058 * The name of the Hdf5Element to search for. 00059 * 00060 * @return A pointer to the element with the given name; NULL if it does not exist. 00061 */ 00062 virtual const Hdf5Element* getElement(const std::string& name) const; 00063 00064 /** 00065 * Locates the given element with the given path. 00066 * 00067 * @param path 00068 * The path to use to locate the element. The elements in the path 00069 * should be separted with "/". A leading slash may be present 00070 * and will be ignored. The element names cannot themselves contain 00071 * a slash, this should be enforced by the HDF5 library. 00072 * 00073 * @return A pointer to the element with the given name; NULL if it does not exist. 00074 */ 00075 virtual const Hdf5Element* getElementByPath(const std::string& path) const; 00076 00077 /** 00078 * Returns the number of Hdf5Elements in the group. 00079 * 00080 * @return Returns the number of elements in the group. Equivalent to getElements().size(). 00081 */ 00082 virtual size_t getNumElements() const; 00083 00084 /** 00085 * Removes an element from the group. 00086 * 00087 * @param pElement 00088 * A pointer to the dataset that will be removed. 00089 * 00090 * @return TRUE if the operation succeeded, otherwise FALSE. 00091 * 00092 * @see Hdf5Dataset::~Hdf5Dataset(), Hdf5Group::~Hdf5Group 00093 */ 00094 virtual bool removeElement(const Hdf5Element* pElement); 00095 00096 protected: 00097 /** 00098 * Creates an empty HDF group. 00099 */ 00100 explicit Hdf5Group(Hdf5Node* pParent, const std::string& name); 00101 00102 /** 00103 * Destroys the HDF group. 00104 */ 00105 virtual ~Hdf5Group(); 00106 00107 /* The Hdf5File is the only class that needs to create and destroy Hdf5Groups, so don't let anyone 00108 create or destroy them. 00109 */ 00110 friend class Hdf5File; 00111 00112 private: 00113 std::vector<Hdf5Element*> mElements; 00114 }; 00115 00116 #endif