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 HDF4GROUP_H 00011 #define HDF4GROUP_H 00012 00013 #include <string> 00014 #include <vector> 00015 00016 #include "Hdf4Element.h" 00017 #include "TypesFile.h" 00018 00019 /** 00020 * The Hdf4Group class is a composite object to hierarchically store groups and datasets. 00021 */ 00022 class Hdf4Group : public Hdf4Element 00023 { 00024 public: 00025 /** 00026 * Adds a dataset to the HDF group. 00027 * 00028 * @param name 00029 * The name of the dataset to add. 00030 * 00031 * @return A pointer to the newly added HDF dataset. Returns NULL if the operation failed. 00032 * 00033 * @see Hdf4Dataset::Hdf4Dataset() 00034 */ 00035 virtual Hdf4Dataset* addDataset(const std::string& name); 00036 00037 /* 00038 * Adds a group to the %Hdf4Group. 00039 * 00040 * @return A pointer to the newly added HDF group object. Returns NULL if the operation failed. 00041 */ 00042 virtual Hdf4Group* addGroup(const std::string& name); 00043 00044 /** 00045 * Returns a vector of the group's elements. 00046 * 00047 * @return A vector of the group's elements. 00048 */ 00049 virtual const std::vector<Hdf4Element*>& getElements() const; 00050 00051 /** 00052 * Non-recursively searches the group's element for a dataset matching the input name. 00053 * 00054 * @param name 00055 * The name of the Hdf4Element to search for. 00056 * 00057 * @return A pointer to the element with the given name; NULL if it does not exist. 00058 */ 00059 virtual const Hdf4Element* getElement(const std::string& name) const; 00060 00061 /** 00062 * Returns the number of Hdf4Elements in the group. 00063 * 00064 * @return Returns the number of elements in the group. Equivalent to getElements().size(). 00065 */ 00066 virtual size_t getNumElements() const; 00067 00068 /** 00069 * Removes an element from the group. 00070 * 00071 * @param pElement 00072 * A pointer to the dataset that will be removed. 00073 * 00074 * @return TRUE if the operation succeeded, otherwise FALSE. 00075 * 00076 * @see Hdf4Dataset::~Hdf4Dataset(), Hdf4Group::~Hdf4Group 00077 */ 00078 virtual bool removeElement(const Hdf4Element* pElement); 00079 00080 protected: 00081 /** 00082 * Creates an empty HDF group. 00083 */ 00084 explicit Hdf4Group(const std::string& name); 00085 00086 /** 00087 * Destroys the HDF group. 00088 */ 00089 virtual ~Hdf4Group(); 00090 00091 /* The Hdf4File is the only class that needs to create and destroy Hdf4Groups, so don't let anyone 00092 create or destroy them. 00093 */ 00094 friend class Hdf4File; 00095 00096 private: 00097 std::vector<Hdf4Element*> mElements; 00098 }; 00099 00100 #endif