casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
HDF5HidMeta.h
Go to the documentation of this file.
00001 //# HDF5HidMeta.h: Classes representing an HDF5 hid of meta objects
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: HDF5HidMeta.h 20615 2009-06-09 02:16:01Z Malte.Marquarding $
00027 
00028 #ifndef CASA_HDF5HIDMETA_H
00029 #define CASA_HDF5HIDMETA_H
00030 
00031 //# Includes
00032 #include <casa/HDF5/HDF5Object.h>
00033 
00034 namespace casa { //# NAMESPACE CASA - BEGIN
00035 
00036   // <summary>
00037   // A class representing an HDF5 property hid.
00038   // </summary>
00039   // <use visibility=local>
00040   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00041   // </reviewed>
00042   // <synopsis>
00043   // This class wraps an HDF5 property hid (hdf5 id). It offers two benefits:
00044   // <ul>
00045   //  <li> The most important is resource management. In case of an exception,
00046   //       the hid will automatically be closed by the destructor.
00047   //  <li> A hid is a kind of pointer and should not be copied. These classes
00048   //       forbid making a copy, but make it possible to use them in a
00049   //       shared pointer context.
00050   // </ul>
00051   // </synopsis>
00052   class HDF5HidProperty
00053   {
00054   public: 
00055     // Default constructor sets hid to invalid.
00056     HDF5HidProperty()
00057       : itsHid(-1) {}
00058     // Construct from given hid.
00059     HDF5HidProperty (hid_t hid)
00060       : itsHid(hid) {}
00061     // The destructor closes the hid.
00062     ~HDF5HidProperty()
00063       { close(); }
00064     // Close the hid if valid.
00065     void close();
00066     // Put hid in it. If it already contains a hid, it will be closed.
00067     void operator= (hid_t hid)
00068       { close(); itsHid = hid; }
00069     // Get the hid.
00070     hid_t getHid() const
00071       { return itsHid; }
00072     // Convert automatically to hid_t.
00073     operator hid_t() const
00074       { return itsHid; }
00075   private:
00076     // Copy constructor cannot be used.
00077     HDF5HidProperty (const HDF5HidProperty& that);
00078     // Assignment cannot be used.
00079     HDF5HidProperty& operator= (const HDF5HidProperty& that);
00080 
00081     hid_t itsHid;
00082   };
00083 
00084 
00085   // <summary>
00086   // A class representing an HDF5 datatype hid.
00087   // </summary>
00088   // <use visibility=local>
00089   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00090   // </reviewed>
00091   // <synopsis>
00092   // This class wraps an HDF5 datatype hid (hdf5 id). It offers two benefits:
00093   // <ul>
00094   //  <li> The most important is resource management. In case of an exception,
00095   //       the hid will automatically be closed by the destructor.
00096   //  <li> A hid is a kind of pointer and should not be copied. These classes
00097   //       forbid making a copy, but make it possible to use them in a
00098   //       shared pointer context.
00099   // </ul>
00100   // </synopsis>
00101   class HDF5HidDataType
00102   {
00103   public: 
00104     // Default constructor sets hid to invalid.
00105     HDF5HidDataType()
00106       : itsHid(-1) {}
00107     // Construct from given hid.
00108     HDF5HidDataType (hid_t hid)
00109       : itsHid(hid) {}
00110     // The destructor closes the hid.
00111     ~HDF5HidDataType()
00112       { close(); }
00113     // Close the hid if valid.
00114     void close();
00115     // Put hid in it. If it already contains a hid, it will be closed.
00116     void operator= (hid_t hid)
00117       { close(); itsHid = hid; }
00118     // Get the hid.
00119     hid_t getHid() const
00120       { return itsHid; }
00121     // Convert automatically to hid_t.
00122     operator hid_t() const
00123       { return itsHid; }
00124   private:
00125     // Copy constructor cannot be used.
00126     HDF5HidDataType (const HDF5HidDataType& that);
00127     // Assignment cannot be used.
00128     HDF5HidDataType& operator= (const HDF5HidDataType& that);
00129 
00130     hid_t itsHid;
00131   };
00132 
00133 
00134   // <summary>
00135   // A class representing an HDF5 dataspace hid.
00136   // </summary>
00137   // <use visibility=local>
00138   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00139   // </reviewed>
00140   // <synopsis>
00141   // This class wraps an HDF5 dataspace hid (hdf5 id). It offers two benefits:
00142   // <ul>
00143   //  <li> The most important is resource management. In case of an exception,
00144   //       the hid will automatically be closed by the destructor.
00145   //  <li> A hid is a kind of pointer and should not be copied. These classes
00146   //       forbid making a copy, but make it possible to use them in a
00147   //       shared pointer context.
00148   // </ul>
00149   // </synopsis>
00150   class HDF5HidDataSpace
00151   {
00152   public: 
00153     // Default constructor sets hid to invalid.
00154     HDF5HidDataSpace()
00155       : itsHid(-1) {}
00156     // Construct from given hid.
00157     HDF5HidDataSpace (hid_t hid)
00158       : itsHid(hid) {}
00159     // The destructor closes the hid.
00160     ~HDF5HidDataSpace()
00161       { close(); }
00162     // Close the hid if valid.
00163     void close();
00164     // Put hid in it. If it already contains a hid, it will be closed.
00165     void operator= (hid_t hid)
00166       { close(); itsHid = hid; }
00167     // Get the hid.
00168     hid_t getHid() const
00169       { return itsHid; }
00170     // Convert automatically to hid_t.
00171     operator hid_t() const
00172       { return itsHid; }
00173   private:
00174     // Copy constructor cannot be used.
00175     HDF5HidDataSpace (const HDF5HidDataSpace& that);
00176     // Assignment cannot be used.
00177     HDF5HidDataSpace& operator= (const HDF5HidDataSpace& that);
00178 
00179     hid_t itsHid;
00180   };
00181 
00182 
00183   // <summary>
00184   // A class representing an HDF5 attribute hid.
00185   // </summary>
00186   // <use visibility=local>
00187   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00188   // </reviewed>
00189   // <synopsis>
00190   // This class wraps an HDF5 attribute hid (hdf5 id). It offers two benefits:
00191   // <ul>
00192   //  <li> The most important is resource management. In case of an exception,
00193   //       the hid will automatically be closed by the destructor.
00194   //  <li> A hid is a kind of pointer and should not be copied. These classes
00195   //       forbid making a copy, but make it possible to use them in a
00196   //       shared pointer context.
00197   // </ul>
00198   // </synopsis>
00199   class HDF5HidAttribute
00200   {
00201   public: 
00202     // Default constructor sets hid to invalid.
00203     HDF5HidAttribute()
00204       : itsHid(-1) {}
00205     // Construct from given hid.
00206     HDF5HidAttribute (hid_t hid)
00207       : itsHid(hid) {}
00208     // The destructor closes the hid.
00209     ~HDF5HidAttribute()
00210       { close(); }
00211     // Close the hid if valid.
00212     void close();
00213     // Put hid in it. If it already contains a hid, it will be closed.
00214     void operator= (hid_t hid)
00215       { close(); itsHid = hid; }
00216     // Get the hid.
00217     hid_t getHid() const
00218       { return itsHid; }
00219     // Convert automatically to hid_t.
00220     operator hid_t() const
00221       { return itsHid; }
00222   private:
00223     // Copy constructor cannot be used.
00224     HDF5HidAttribute (const HDF5HidAttribute& that);
00225     // Assignment cannot be used.
00226     HDF5HidAttribute& operator= (const HDF5HidAttribute& that);
00227 
00228     hid_t itsHid;
00229   };
00230 
00231 
00232 }
00233 
00234 #endif