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
52 class HDF5Group : public HDF5Object
53 {
54 public:
55 // Construct from given hid.
57 {}
58
59 // Open or create a group at the given hid.
60 // Default is that the group may exist; it is created if not existing.
61 // <group>
62 HDF5Group (const HDF5Object& parentHid,
63 const String& name,
64 bool mustExist=false, bool mustNotExist=false)
65 { init (parentHid, parentHid.getName(), name, mustExist, mustNotExist); }
66 HDF5Group (hid_t parentHid,
67 const String& name,
68 bool mustExist=false, bool mustNotExist=false)
69 { init (parentHid, String(), name, mustExist, mustNotExist); }
70 // </group>
71
72 // The destructor closes the hid.
73 virtual ~HDF5Group();
74
75 // Close the hid if valid.
76 virtual void close();
77
78 // Get the names of all links at the given hid.
79 static std::vector<String> linkNames (const HDF5Object& parentHid);
80
81 // Test if the group at the given hid exists.
82 static bool exists (const HDF5Object& parentHid, const String& name);
83
84 // Delete group at the given hid if it exists.
85 static void remove (const HDF5Object& parentHid, const String& name);
86
87 private:
88 // Copy constructor cannot be used.
89 HDF5Group (const HDF5Group& that);
90 // Assignment cannot be used.
92
93 // Initialize (execute the constructor).
94 void init (hid_t parentHid, const String& parentName,
95 const String& name,
96 bool mustExist=false, bool mustNotExist=false);
97 };
98
99}
100
101#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:66
HDF5Group()
Construct from given hid.
Definition HDF5Group.h:56
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:62
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:107
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28