casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
HDF5Group.h
Go to the documentation of this file.
00001 //# HDF5Group.h: An class representing an HDF5 group
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: HDF5Group.h 20615 2009-06-09 02:16:01Z Malte.Marquarding $
00027 
00028 #ifndef CASA_HDF5GROUP_H
00029 #define CASA_HDF5GROUP_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 group.
00038   // </summary>
00039   // <use visibility=export>
00040   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00041   // </reviewed>
00042   // <synopsis>
00043   // This class wraps an HDF5 group 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   //       make it possible to use them in a shared pointer.
00049   // </ul>
00050   // </synopsis>
00051 
00052   class HDF5Group : public HDF5Object
00053   {
00054   public: 
00055     // Construct from given hid.
00056     HDF5Group()
00057     {}
00058 
00059     // Open or create a group at the given hid.
00060     // Default is that the group may exist; it is created if not existing.
00061     // <group>
00062     HDF5Group (const HDF5Object& parentHid,
00063                const String& name,
00064                bool mustExist=false, bool mustNotExist=false)
00065     { init (parentHid, parentHid.getName(), name, mustExist, mustNotExist); }
00066     HDF5Group (hid_t parentHid,
00067                const String& name,
00068                bool mustExist=false, bool mustNotExist=false)
00069     { init (parentHid, String(), name, mustExist, mustNotExist); }
00070     // </group>
00071 
00072     // The destructor closes the hid.
00073     virtual ~HDF5Group();
00074 
00075     // Close the hid if valid.
00076     virtual void close();
00077 
00078     // Delete group at the given hid if it exists.
00079     static void remove (const HDF5Object& parentHid, const String& name);
00080 
00081   private:
00082     // Copy constructor cannot be used.
00083     HDF5Group (const HDF5Group& that);
00084     // Assignment cannot be used.
00085     HDF5Group& operator= (const HDF5Group& that);
00086 
00087     // Initialize (execute the constructor).
00088     void init (hid_t parentHid, const String& parentName,
00089                const String& name,
00090                bool mustExist=false, bool mustNotExist=false);
00091   };
00092 
00093 }
00094 
00095 #endif