casacore
Loading...
Searching...
No Matches
HDF5Group.h
Go to the documentation of this file.
1//# HDF5Group.h: An class representing an HDF5 group
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_HDF5GROUP_H
29#define CASA_HDF5GROUP_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/casa/HDF5/HDF5Object.h>
34#include <vector>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38 // <summary>
39 // A class representing an HDF5 group.
40 // </summary>
41 // <use visibility=export>
42 // <reviewed reviewer="" date="" tests="tHDF5Dataset.cc">
43 // </reviewed>
44 // <synopsis>
45 // This class wraps an HDF5 group hid (hdf5 id). It offers two benefits:
46 // <ul>
47 // <li> The most important is resource management. In case of an exception,
48 // the hid will automatically be closed by the destructor.
49 // <li> A hid is a kind of pointer and should not be copied. These classes
50 // make it possible to use them in a shared pointer.
51 // </ul>
52 // </synopsis>
53
54 class HDF5Group : public HDF5Object
55 {
56 public:
57 // Construct from given hid.
59 {}
60
61 // Open or create a group at the given hid.
62 // Default is that the group may exist; it is created if not existing.
63 // <group>
64 HDF5Group (const HDF5Object& parentHid,
65 const String& name,
66 bool mustExist=false, bool mustNotExist=false)
67 { init (parentHid, parentHid.getName(), name, mustExist, mustNotExist); }
68 HDF5Group (hid_t parentHid,
69 const String& name,
70 bool mustExist=false, bool mustNotExist=false)
71 { init (parentHid, String(), name, mustExist, mustNotExist); }
72 // </group>
73
74 // The destructor closes the hid.
75 virtual ~HDF5Group();
76
77 // Close the hid if valid.
78 virtual void close();
79
80 // Get the names of all links at the given hid.
81 static std::vector<String> linkNames (const HDF5Object& parentHid);
82
83 // Test if the group at the given hid exists.
84 static bool exists (const HDF5Object& parentHid, const String& name);
85
86 // Delete group at the given hid if it exists.
87 static void remove (const HDF5Object& parentHid, const String& name);
88
89 private:
90 // Copy constructor cannot be used.
91 HDF5Group (const HDF5Group& that);
92 // Assignment cannot be used.
94
95 // Initialize (execute the constructor).
96 void init (hid_t parentHid, const String& parentName,
97 const String& name,
98 bool mustExist=false, bool mustNotExist=false);
99 };
100
101}
102
103#endif
HDF5Group & operator=(const HDF5Group &that)
Assignment cannot be used.
static void remove(const HDF5Object &parentHid, const String &name)
Delete group at the given hid if it exists.
static bool exists(const HDF5Object &parentHid, const String &name)
Test if the group at the given hid exists.
HDF5Group(hid_t parentHid, const String &name, bool mustExist=false, bool mustNotExist=false)
Definition HDF5Group.h:68
HDF5Group()
Construct from given hid.
Definition HDF5Group.h:58
static std::vector< String > linkNames(const HDF5Object &parentHid)
Get the names of all links at the given hid.
HDF5Group(const HDF5Object &parentHid, const String &name, bool mustExist=false, bool mustNotExist=false)
Open or create a group at the given hid.
Definition HDF5Group.h:64
void init(hid_t parentHid, const String &parentName, const String &name, bool mustExist=false, bool mustNotExist=false)
Initialize (execute the constructor).
virtual ~HDF5Group()
The destructor closes the hid.
HDF5Group(const HDF5Group &that)
Copy constructor cannot be used.
virtual void close()
Close the hid if valid.
const String & getName() const
Definition HDF5Object.h:103
String: the storage and methods of handling collections of characters.
Definition String.h:225
this file contains all the compiler specific defines
Definition mainpage.dox:28