Hdf4Dataset.h

Go to the documentation of this file.
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 HDF4DATASET_H
00011 #define HDF4DATASET_H
00012 
00013 #include "EnumWrapper.h"
00014 #include "Hdf4Element.h"
00015 #include "TypesFile.h"
00016 
00017 #include <string>
00018 
00019 class Hdf4Dataset : public Hdf4Element
00020 {
00021 public:
00022    /**
00023     * Types supported by HdfPlugInLib.
00024     */
00025    enum HdfTypeEnum
00026    {
00027       INT1SBYTE = 0,    /**< char */
00028       INT1UBYTE = 1,    /**< unsigned char */
00029       INT2SBYTES = 2,   /**< short */
00030       INT2UBYTES = 3,   /**< unsigned short */
00031       INT4SCOMPLEX = 4, /**< complex short */
00032       INT4SBYTES = 5,   /**< int */
00033       INT4UBYTES = 6,   /**< unsigned int */
00034       FLT4BYTES = 7,    /**< float */
00035       FLT8COMPLEX = 8,  /**< complex float */
00036       FLT8BYTES = 9,    /**< double */
00037       STRING = 10,      /**< std::string */
00038       COMPOUND = 11,    /**< Compund or VDATA dataset */
00039       UNSUPPORTED = 12  /**< Indicates a value unsupported by HdfPlugInLib */
00040    };
00041 
00042    /**
00043     * @EnumWrapper Hdf4Dataset::HdfTypeEnum.
00044     */
00045    typedef EnumWrapper<HdfTypeEnum> HdfType;
00046 
00047    /**
00048     * Gets whether the dataset is compound or not.
00049     *
00050     * Compound datasets have no data encoding , 0 per element, and 0 count.
00051     * If this function returns true, HdfPlugInLib will not have parsed the dataset because
00052     * the HdfPlugInLib does not support loading compound datasets.
00053     *
00054     * @return Returns whether the dataset is a compound dataset (ie. vdata) or not.
00055     */
00056    virtual bool isCompoundDataset() const;
00057 
00058    /**
00059     * Sets the data type for the HDF dataset.
00060     *
00061     * For non-native types or compound datasets, returns UNSUPPORTED.
00062     *
00063     * @param  dataType
00064     *         The HdfType that corresponds to dataset's type.
00065     *         For those types that do not correspond to an HdfType, UNSUPPORTED
00066     *         should be passed in.
00067     */
00068    virtual void setDataEncoding(HdfType dataType);
00069 
00070    /**
00071     * Gets the data encoding type for the HDF dataset.
00072     *
00073     * For non-native types or compound datasets, dataType will not be valid (dataType.isValid()).
00074     *
00075     * @param  encoding
00076     *         The data encoding type that corresponds to the member string.
00077     *         For those types that do not correspond to an EncodingType (ie. a compound dataset),
00078     *         the dataType will not be valid (dataType.isValid()).
00079     *
00080     */
00081    virtual void getDataEncoding(EncodingType& encoding) const;
00082 
00083    /**
00084     * Gets the HDF data type for the HDF dataset.
00085     *
00086     * For unsupported types or compound datasets, returns UNSUPPORTED.
00087     *
00088     * @param  type
00089     *         The data type that corresponds to the member string.
00090     *         For those types that do not correspond to an HdfType (ie. a compound dataset),
00091     *         UNSUPPORTED is returned.
00092     */
00093    virtual void getDataEncoding(HdfType& type) const;
00094 
00095    /*
00096     * Sets the number of bytes per element in the dataset.
00097     *
00098     * Typically is only used by HdfImporterShell::getFileData().
00099     *
00100     * @param  sz
00101     *         The number of bytes per element in the dataset.
00102     */
00103    virtual void setBytesPerElement(size_t sz);
00104 
00105    /**
00106     * Returns the number of bytes per element of the dataset.
00107     *
00108     * @return The total number of bytes per element of the dataset.
00109     */
00110    virtual size_t getBytesPerElement() const;
00111 
00112    /*
00113     * Sets the total number of elements in the dataset - even if it is multidimensional.
00114     *
00115     * Typically is only used by HdfImporterShell::getFileData().
00116     *
00117     * @param  count
00118     *         The total number of elements in the dataset.
00119     */
00120    virtual void setCount(size_t count);
00121 
00122    /**
00123     * Returns the total number of elements in the dataset - even if it is multi-dimensional.
00124     *
00125     * @return The total number of elements in the dataset.
00126     */
00127    virtual size_t getCount() const;
00128 
00129 protected:
00130    // The Hdf4Group must be a friend so the Hdf4Group can delete and create Hdf4Datasets
00131    friend class Hdf4Group;
00132 
00133    /**
00134     * Creates an Hdf4Dataset object that represents the data set object of an HDF file.
00135     *
00136     * To create a dataset, use Hdf4Group::addDataset().
00137     */
00138    explicit Hdf4Dataset(const std::string& name);
00139 
00140    /**
00141     * Destroys the Hdf4Dataset object.
00142     *
00143     * To destroy an Hdf4Dataset from a group, call Hdf4Group::removeDataset().
00144     */
00145    virtual ~Hdf4Dataset();
00146 
00147 private:
00148    HdfType mType;
00149    size_t mCount;
00150    size_t mBytesPerElement;
00151 };
00152 
00153 #endif

Software Development Kit - Opticks 4.9.0 Build 16218