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