HDF5DataType.h

Go to the documentation of this file.
00001 //# HDF5DataType.h: An class representing an HDF5 data type
00002 //# Copyright (C) 2008
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef CASA_HDF5DATATYPE_H
00029 #define CASA_HDF5DATATYPE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/HDF5/HDF5Object.h>
00034 #include <casacore/casa/BasicSL/Complex.h>
00035 #include <casacore/casa/BasicSL/String.h>
00036 #include <casacore/casa/Utilities/DataType.h>
00037 
00038 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00039 
00040   // <summary>
00041   // A class representing an HDF5 data type.
00042   // </summary>
00043 
00044   // <use visibility=local>
00045 
00046   // <reviewed reviewer="" date="" tests="tHDF5DataType.cc">
00047   // </reviewed>
00048 
00049   // <prerequisite>
00050   //   <li> <a href="http://hdf.ncsa.uiuc.edu">HDF5 system</a>
00051   // </prerequisite>
00052 
00053   // <synopsis>
00054   // This class wraps the HDF5 functions to create a data type.
00055   // It creates a data type for the datas in memory and for the file.
00056   // </synopsis> 
00057 
00058   // <motivation>
00059   // It was overkill to use the HDF5 C++ interface. Instead little wrappers
00060   // have been written. HDF5DataType can be embedded in a shared pointer making
00061   // it possible to share an HDF5 data type amongst various HDF5Array objects
00062   // and close (i.e. destruct) the HDF5 data type object when needed.
00063   // </motivation>
00064 
00065   class HDF5DataType
00066   {
00067   public: 
00068     // Create an HDF5 datatype object for the given fixed length type.
00069     // It uses the corresponding native HDF5 data type. Only for Bool it
00070     // uses a uchar, because the HDF5 bool type is a uint.
00071     // For the complex types it makes a compound HDF5 data type.
00072     // The String type is meant for an array of strings.
00073     // <group>
00074     HDF5DataType (const Bool*);
00075     HDF5DataType (const uChar*);
00076     HDF5DataType (const Short*);
00077     HDF5DataType (const uShort*);
00078     HDF5DataType (const Int*);
00079     HDF5DataType (const uInt*);
00080     HDF5DataType (const Int64*);
00081     HDF5DataType (const Float*);
00082     HDF5DataType (const Double*);
00083     HDF5DataType (const Complex*);
00084     HDF5DataType (const DComplex*);
00085     HDF5DataType (const String*);
00086     // </group>
00087 
00088     // Create an HDF5 datatype object for a scalar string.
00089     // The length of the string is part of the type.
00090     HDF5DataType (const String& value);
00091 
00092     // Create an HDF5 datatype object for an empty array.
00093     HDF5DataType (Int, Int);
00094 
00095     // The destructor closes the HDF5 data type object.
00096     ~HDF5DataType();
00097 
00098     // Get the Casacore data type for the given HDF5 data type.
00099     static DataType getDataType (hid_t);
00100 
00101     // Get the HID for the data type in memory.
00102     hid_t getHidMem() const
00103       { return itsHidMem; }
00104 
00105     // Get the HID for the data type in the file.
00106     hid_t getHidFile() const
00107       { return itsHidFile; }
00108 
00109     // Get the size in bytes of the data type.
00110     // Note that the size of a string is variable, thus 0.
00111     uInt size() const
00112       { return itsSize; }
00113 
00114   private:
00115     // Copy constructor cannot be used.
00116     HDF5DataType (const HDF5DataType& that);
00117 
00118     // Assignment cannot be used.
00119     HDF5DataType& operator= (const HDF5DataType& that);
00120 
00121 
00122     hid_t itsHidMem;
00123     hid_t itsHidFile;
00124     uInt  itsSize;
00125   };
00126 
00127 }
00128 
00129 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1