casacore
Loading...
Searching...
No Matches
ImageAttrGroupHDF5.h
Go to the documentation of this file.
1// # ImageAttrGroupHDF5.h: Attribute group for a HDF5 image
2// # Copyright (C) 2012
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 IMAGES_IMAGEATTRGROUPHDF5_H
27#define IMAGES_IMAGEATTRGROUPHDF5_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageAttrGroup.h>
32#include <casacore/tables/Tables/TableProxy.h>
33#include <casacore/casa/HDF5/HDF5Group.h>
34
35namespace casacore {
36
37// <summary>
38// Attribute group for a HDF5 image.
39// </summary>
40//
41// <use visibility=export>
42//
43// <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc">
44// </reviewed>
45//
46// <prerequisite>
47// <li> <linkto class=ImageAttrGroup>ImageAttrGroup</linkto>
48// </prerequisite>
49//
50// <synopsis>
51// This is the implementation of base class class ImageAttrGroup for an image
52// stored in the HDF5 format.
53// See the base class for more information.
54// </synopsis>
55
57 public:
58 // The default constructor creates a null object.
59 explicit ImageAttrGroupHDF5(Bool isWritable = False)
60 : itsChanged(False), itsCanWrite(isWritable) {}
61
62 // Construct the object for an attribute group in the image.
63 // If present, it reads all attributes.
64 ImageAttrGroupHDF5(const HDF5Group& image, const String& attrGroupName, Bool writable);
65
67
68 // Test if it is a null object.
69 Bool isNull() const { return itsRecord.empty(); }
70
71 // Flush the attibrutes if needed.
72 void flush(HDF5Group& image, const String& attrGroupName);
73
74 // Get the number of rows in the group.
75 virtual uInt nrows() const;
76
77 // Test if an attribute exists.
78 virtual Bool hasAttr(const String& attrName) const;
79
80 // Get all attribute names.
81 virtual Vector<String> attrNames() const;
82
83 // Get the datatype of a attribute.
84 // It returns TpOther if the attribute is not defined.
85 virtual DataType dataType(const String& attrName) const;
86
87 // Get the data of the given attribute in the given row.
88 virtual ValueHolder getData(const String& attrName, uInt rownr);
89
90 // Get the data of all attributes in a rows.
91 virtual Record getDataRow(uInt rownr);
92
93 // Get the possible units of the values (stored as attrName_UNIT).
94 // An empty vector is returned if the attribute has no units.
95 virtual Vector<String> getUnit(const String& attrName);
96
97 // Get the possible measure info as type,Ref (stored as attrName_MEASINFO).
98 // An empty vector is returned if the attribute has no MEASINFO.
99 virtual Vector<String> getMeasInfo(const String& attrName);
100
101 // Put the data of the given attribute.
102 // If the table does not contain data yet, it will be sized to the size
103 // of the vector. Otherwise the vector size has to match the table size.
104 // <br>If not empty, the units and MEASINFO will be put as column keywords.
105 // The MEASINFO vector must be given as type,Ref.
106 virtual void putData(const String& attrName, uInt rownr, const ValueHolder& data,
107 const Vector<String>& units = Vector<String>(),
108 const Vector<String>& measInfo = Vector<String>());
109
110 private:
111 // Check the rownr and add a row if needed.
112 void checkRows(const std::string& attrName, uInt rownr);
113
114 // # Data members.
115 Record itsRecord; // # Record containing all attributes (subrecord per row)
116 Bool itsChanged; // # Has the Record changed?
117 Bool itsCanWrite; // # Can attributes be written?
118};
119
120} // namespace casacore
121
122#endif
virtual uInt nrows() const
Get the number of rows in the group.
virtual Bool hasAttr(const String &attrName) const
Test if an attribute exists.
ImageAttrGroupHDF5(const HDF5Group &image, const String &attrGroupName, Bool writable)
Construct the object for an attribute group in the image.
void flush(HDF5Group &image, const String &attrGroupName)
Flush the attibrutes if needed.
virtual void putData(const String &attrName, uInt rownr, const ValueHolder &data, const Vector< String > &units=Vector< String >(), const Vector< String > &measInfo=Vector< String >())
Put the data of the given attribute.
virtual Vector< String > getMeasInfo(const String &attrName)
Get the possible measure info as type,Ref (stored as attrName_MEASINFO).
virtual Vector< String > attrNames() const
Get all attribute names.
void checkRows(const std::string &attrName, uInt rownr)
Check the rownr and add a row if needed.
ImageAttrGroupHDF5(Bool isWritable=False)
The default constructor creates a null object.
virtual DataType dataType(const String &attrName) const
Get the datatype of a attribute.
Bool isNull() const
Test if it is a null object.
virtual Record getDataRow(uInt rownr)
Get the data of all attributes in a rows.
virtual ValueHolder getData(const String &attrName, uInt rownr)
Get the data of the given attribute in the given row.
virtual Vector< String > getUnit(const String &attrName)
Get the possible units of the values (stored as attrName_UNIT).
ImageAttrGroup()
Default constructor.
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
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40