casacore
HDF5DataType.h
Go to the documentation of this file.
1 //# HDF5DataType.h: An class representing an HDF5 data type
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_HDF5DATATYPE_H
29 #define CASA_HDF5DATATYPE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/HDF5/HDF5Object.h>
34 #include <casacore/casa/BasicSL/Complex.h>
35 #include <casacore/casa/BasicSL/String.h>
36 #include <casacore/casa/Utilities/DataType.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40  // <summary>
41  // A class representing an HDF5 data type.
42  // </summary>
43 
44  // <use visibility=local>
45 
46  // <reviewed reviewer="" date="" tests="tHDF5DataType.cc">
47  // </reviewed>
48 
49  // <prerequisite>
50  // <li> <a href="http://hdf.ncsa.uiuc.edu">HDF5 system</a>
51  // </prerequisite>
52 
53  // <synopsis>
54  // This class wraps the HDF5 functions to create a data type.
55  // It creates a data type for the datas in memory and for the file.
56  // </synopsis>
57 
58  // <motivation>
59  // It was overkill to use the HDF5 C++ interface. Instead little wrappers
60  // have been written. HDF5DataType can be embedded in a shared pointer making
61  // it possible to share an HDF5 data type amongst various HDF5Array objects
62  // and close (i.e. destruct) the HDF5 data type object when needed.
63  // </motivation>
64 
66  {
67  public:
68  // Create an HDF5 datatype object for the given fixed length type.
69  // It uses the corresponding native HDF5 data type. Only for Bool it
70  // uses a uchar, because the HDF5 bool type is a uint.
71  // For the complex types it makes a compound HDF5 data type.
72  // The String type is meant for an array of strings.
73  // <group>
74  HDF5DataType (const Bool*);
75  HDF5DataType (const uChar*);
76  HDF5DataType (const Short*);
77  HDF5DataType (const uShort*);
78  HDF5DataType (const Int*);
79  HDF5DataType (const uInt*);
80  HDF5DataType (const Int64*);
81  HDF5DataType (const Float*);
82  HDF5DataType (const Double*);
83  HDF5DataType (const Complex*);
84  HDF5DataType (const DComplex*);
85  HDF5DataType (const String*);
86  // </group>
87 
88  // Create an HDF5 datatype object for a scalar string.
89  // The length of the string is part of the type.
90  HDF5DataType (const String& value);
91 
92  // Create an HDF5 datatype object for an empty array.
93  HDF5DataType (Int, Int);
94 
95  // The destructor closes the HDF5 data type object.
96  ~HDF5DataType();
97 
98  // Get the Casacore data type for the given HDF5 data type.
99  static DataType getDataType (hid_t);
100 
101  // Get the HID for the data type in memory.
102  hid_t getHidMem() const
103  { return itsHidMem; }
104 
105  // Get the HID for the data type in the file.
106  hid_t getHidFile() const
107  { return itsHidFile; }
108 
109  // Get the size in bytes of the data type.
110  // Note that the size of a string is variable, thus 0.
111  uInt size() const
112  { return itsSize; }
113 
114  private:
115  // Copy constructor cannot be used.
116  HDF5DataType (const HDF5DataType& that);
117 
118  // Assignment cannot be used.
119  HDF5DataType& operator= (const HDF5DataType& that);
120 
121 
122  hid_t itsHidMem;
123  hid_t itsHidFile;
125  };
126 
127 }
128 
129 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:47
hid_t getHidMem() const
Get the HID for the data type in memory.
Definition: HDF5DataType.h:102
hid_t getHidFile() const
Get the HID for the data type in the file.
Definition: HDF5DataType.h:106
A class representing an HDF5 data type.
Definition: HDF5DataType.h:65
unsigned char uChar
Definition: aipstype.h:44
short Short
Definition: aipstype.h:45
~HDF5DataType()
The destructor closes the HDF5 data type object.
HDF5DataType & operator=(const HDF5DataType &that)
Assignment cannot be used.
double Double
Definition: aipstype.h:52
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
HDF5DataType(const Bool *)
Create an HDF5 datatype object for the given fixed length type.
static DataType getDataType(hid_t)
Get the Casacore data type for the given HDF5 data type.
float Float
Definition: aipstype.h:51
String: the storage and methods of handling collections of characters.
Definition: String.h:223
uInt size() const
Get the size in bytes of the data type.
Definition: HDF5DataType.h:111
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:48
unsigned short uShort
Definition: aipstype.h:46