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$
00027 
00028 #ifndef CASA_HDF5GROUP_H
00029 #define CASA_HDF5GROUP_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/HDF5/HDF5Object.h>
00034 #include <vector>
00035 
00036 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00037 
00038   // <summary>
00039   // A class representing an HDF5 group.
00040   // </summary>
00041   // <use visibility=export>
00042   // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
00043   // </reviewed>
00044   // <synopsis>
00045   // This class wraps an HDF5 group hid (hdf5 id). It offers two benefits:
00046   // <ul>
00047   //  <li> The most important is resource management. In case of an exception,
00048   //       the hid will automatically be closed by the destructor.
00049   //  <li> A hid is a kind of pointer and should not be copied. These classes
00050   //       make it possible to use them in a shared pointer.
00051   // </ul>
00052   // </synopsis>
00053 
00054   class HDF5Group : public HDF5Object
00055   {
00056   public: 
00057     // Construct from given hid.
00058     HDF5Group()
00059     {}
00060 
00061     // Open or create a group at the given hid.
00062     // Default is that the group may exist; it is created if not existing.
00063     // <group>
00064     HDF5Group (const HDF5Object& parentHid,
00065                const String& name,
00066                bool mustExist=false, bool mustNotExist=false)
00067       { init (parentHid, parentHid.getName(), name, mustExist, mustNotExist); }
00068     HDF5Group (hid_t parentHid,
00069                const String& name,
00070                bool mustExist=false, bool mustNotExist=false)
00071       { init (parentHid, String(), name, mustExist, mustNotExist); }
00072     // </group>
00073 
00074     // The destructor closes the hid.
00075     virtual ~HDF5Group();
00076 
00077     // Close the hid if valid.
00078     virtual void close();
00079 
00080     // Get the names of all links at the given hid.
00081     static std::vector<String> linkNames (const HDF5Object& parentHid);
00082 
00083     // Test if the group at the given hid exists.
00084     static bool exists (const HDF5Object& parentHid, const String& name);
00085 
00086     // Delete group at the given hid if it exists.
00087     static void remove (const HDF5Object& parentHid, const String& name);
00088 
00089   private:
00090     // Copy constructor cannot be used.
00091     HDF5Group (const HDF5Group& that);
00092     // Assignment cannot be used.
00093     HDF5Group& operator= (const HDF5Group& that);
00094 
00095     // Initialize (execute the constructor).
00096     void init (hid_t parentHid, const String& parentName,
00097                const String& name,
00098                bool mustExist=false, bool mustNotExist=false);
00099   };
00100 
00101 }
00102 
00103 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1