casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: 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 IMAGES_IMAGEATTRGROUPHDF5_H
29 #define IMAGES_IMAGEATTRGROUPHDF5_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 
37 namespace casacore {
38 
39 // <summary>
40 // Attribute group for a HDF5 image.
41 // </summary>
42 //
43 // <use visibility=export>
44 //
45 // <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc">
46 // </reviewed>
47 //
48 // <prerequisite>
49 // <li> <linkto class=ImageAttrGroup>ImageAttrGroup</linkto>
50 // </prerequisite>
51 //
52 // <synopsis>
53 // This is the implementation of base class class ImageAttrGroup for an image
54 // stored in the HDF5 format.
55 // See the base class for more information.
56 // </synopsis>
57 
59 {
60 public:
61  // The default constructor creates a null object.
62  explicit ImageAttrGroupHDF5 (Bool isWritable=False)
63  : itsChanged (False),
64  itsCanWrite (isWritable)
65  {}
66 
67  // Construct the object for an attribute group in the image.
68  // If present, it reads all attributes.
69  ImageAttrGroupHDF5 (const HDF5Group& image, const String& attrGroupName,
70  Bool writable);
71 
72  virtual ~ImageAttrGroupHDF5();
73 
74  // Test if it is a null object.
75  Bool isNull() const
76  { return itsRecord.empty(); }
77 
78  // Flush the attibrutes if needed.
79  void flush (HDF5Group& image, const String& attrGroupName);
80 
81  // Get the number of rows in the group.
82  virtual uInt nrows() const;
83 
84  // Test if an attribute exists.
85  virtual Bool hasAttr (const String& attrName) const;
86 
87  // Get all attribute names.
88  virtual Vector<String> attrNames() const;
89 
90  // Get the datatype of a attribute.
91  // It returns TpOther if the attribute is not defined.
92  virtual DataType dataType (const String& attrName) const;
93 
94  // Get the data of the given attribute in the given row.
95  virtual ValueHolder getData (const String& attrName, uInt rownr);
96 
97  // Get the data of all attributes in a rows.
98  virtual Record getDataRow (uInt rownr);
99 
100  // Get the possible units of the values (stored as attrName_UNIT).
101  // An empty vector is returned if the attribute has no units.
102  virtual Vector<String> getUnit (const String& attrName);
103 
104  // Get the possible measure info as type,Ref (stored as attrName_MEASINFO).
105  // An empty vector is returned if the attribute has no MEASINFO.
106  virtual Vector<String> getMeasInfo (const String& attrName);
107 
108  // Put the data of the given attribute.
109  // If the table does not contain data yet, it will be sized to the size
110  // of the vector. Otherwise the vector size has to match the table size.
111  // <br>If not empty, the units and MEASINFO will be put as column keywords.
112  // The MEASINFO vector must be given as type,Ref.
113  virtual void putData (const String& attrName, uInt rownr,
114  const ValueHolder& data,
115  const Vector<String>& units = Vector<String>(),
116  const Vector<String>& measInfo = Vector<String>());
117 
118 private:
119  // Check the rownr and add a row if needed.
120  void checkRows (const String& attrName, uInt rownr);
121 
122  //# Data members.
123  Record itsRecord; //# Record containing all attributes (subrecord per row)
124  Bool itsChanged; //# Has the Record changed?
125  Bool itsCanWrite; //# Can attributes be written?
126 };
127 
128 } //# NAMESPACE CASACORE - END
129 
130 #endif
A 1-D Specialization of the Array class.
Definition: ArrayFwd.h:9
virtual Bool hasAttr(const String &attrName) const
Test if an attribute exists.
virtual ValueHolder getData(const String &attrName, uInt rownr)
Get the data of the given attribute in the given row.
A class representing an HDF5 group.
Definition: HDF5Group.h:54
Abstract base class for an image attributes group.
bool empty() const
Is the record empty?
Bool isNull() const
Test if it is a null object.
virtual Vector< String > getMeasInfo(const String &attrName)
Get the possible measure info as type,Ref (stored as attrName_MEASINFO).
A holder for a value of any basic Casacore data type.
Definition: ValueHolder.h:68
virtual Record getDataRow(uInt rownr)
Get the data of all attributes in a rows.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void checkRows(const String &attrName, uInt rownr)
Check the rownr and add a row 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.
const Bool False
Definition: aipstype.h:44
virtual uInt nrows() const
Get the number of rows in the group.
virtual Vector< String > attrNames() const
Get all attribute names.
virtual DataType dataType(const String &attrName) const
Get the datatype of a attribute.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Attribute group for a HDF5 image.
virtual Vector< String > getUnit(const String &attrName)
Get the possible units of the values (stored as attrName_UNIT).
ImageAttrGroupHDF5(Bool isWritable=False)
The default constructor creates a null object.
void flush(HDF5Group &image, const String &attrGroupName)
Flush the attibrutes if needed.
unsigned int uInt
Definition: aipstype.h:51