casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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: HDF5DataType.h 20901 2010-06-09 07:23:37Z gervandiepen $
00027 
00028 #ifndef CASA_HDF5DATATYPE_H
00029 #define CASA_HDF5DATATYPE_H
00030 
00031 //# Includes
00032 #include <casa/HDF5/HDF5Object.h>
00033 #include <casa/BasicSL/Complex.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <casa/Utilities/DataType.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039   // <summary>
00040   // A class representing an HDF5 data type.
00041   // </summary>
00042 
00043   // <use visibility=local>
00044 
00045   // <reviewed reviewer="" date="" tests="tHDF5DataType.cc">
00046   // </reviewed>
00047 
00048   // <prerequisite>
00049   //   <li> <a href="http://hdf.ncsa.uiuc.edu">HDF5 system</a>
00050   // </prerequisite>
00051 
00052   // <synopsis>
00053   // This class wraps the HDF5 functions to create a data type.
00054   // It creates a data type for the datas in memory and for the file.
00055   // </synopsis> 
00056 
00057   // <motivation>
00058   // It was overkill to use the HDF5 C++ interface. Instead little wrappers
00059   // have been written. HDF5DataType can be embedded in a shared pointer making
00060   // it possible to share an HDF5 data type amongst various HDF5Array objects
00061   // and close (i.e. destruct) the HDF5 data type object when needed.
00062   // </motivation>
00063 
00064   class HDF5DataType
00065   {
00066   public: 
00067     // Create an HDF5 datatype object for the given fixed length type.
00068     // It uses the corresponding native HDF5 data type. Only for Bool it
00069     // uses a uchar, because the HDF5 bool type is a uint.
00070     // For the complex types it makes a compound HDF5 data type.
00071     // The String type is meant for an array of strings.
00072     // <group>
00073     HDF5DataType (const Bool*);
00074     HDF5DataType (const uChar*);
00075     HDF5DataType (const Short*);
00076     HDF5DataType (const uShort*);
00077     HDF5DataType (const Int*);
00078     HDF5DataType (const uInt*);
00079     HDF5DataType (const Int64*);
00080     HDF5DataType (const Float*);
00081     HDF5DataType (const Double*);
00082     HDF5DataType (const Complex*);
00083     HDF5DataType (const DComplex*);
00084     HDF5DataType (const String*);
00085     // </group>
00086 
00087     // Create an HDF5 datatype object for a scalar string.
00088     // The length of the string is part of the type.
00089     HDF5DataType (const String& value);
00090 
00091     // Create an HDF5 datatype object for an empty array.
00092     HDF5DataType (Int, Int);
00093 
00094     // The destructor closes the HDF5 data type object.
00095     ~HDF5DataType();
00096 
00097     // Get the AIPS++ data type for the given HDF5 data type.
00098     static DataType getDataType (hid_t);
00099 
00100     // Get the HID for the data type in memory.
00101     hid_t getHidMem() const
00102       { return itsHidMem; }
00103 
00104     // Get the HID for the data type in the file.
00105     hid_t getHidFile() const
00106       { return itsHidFile; }
00107 
00108     // Get the size in bytes of the data type.
00109     // Note that the size of a string is variable, thus 0.
00110     uInt size() const
00111       { return itsSize; }
00112 
00113   private:
00114     // Copy constructor cannot be used.
00115     HDF5DataType (const HDF5DataType& that);
00116 
00117     // Assignment cannot be used.
00118     HDF5DataType& operator= (const HDF5DataType& that);
00119 
00120 
00121     hid_t itsHidMem;
00122     hid_t itsHidFile;
00123     uInt  itsSize;
00124   };
00125 
00126 }
00127 
00128 #endif