casacore
Loading...
Searching...
No Matches
ImageAttrHandlerHDF5.h
Go to the documentation of this file.
1//# ImageAttrHandlerHDF5.h: Attributes handler for HDF5 images
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_IMAGEATTRHANDLERHDF5_H
27#define IMAGES_IMAGEATTRHANDLERHDF5_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/images/Images/ImageAttrHandler.h>
33#include <casacore/images/Images/ImageAttrGroupHDF5.h>
34#include <casacore/casa/HDF5/HDF5Group.h>
35#include <map>
36
37namespace casacore {
38
39// <summary>
40// Abstract base class for an image attributes handler.
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=ImageInterface>ImageInterface</linkto>
50// </prerequisite>
51
52// <etymology>
53// This class makes it possible to store extra attributes with an image to
54// describe atrbitrary meta information.
55// </etymology>
56
57// <synopsis>
58// For LOFAR it was needed to store extra meta information and to be able to
59// convert it from casacore table format to HDF5 format and vice-versa.
60// Furthermore, it must be possible to access the information in a way that
61// arbitrary info can be stored and retrieved.
62//
63// The attributes are divided into handlers. Each handler can reside in a subtable
64// of the image or in a handler in HDF5. All attributes in a handler have the
65// same number of values, where each value can be a scalar or (small) array.
66// It is possible to define units and measure info for an attribute.
67// </synopsis>
68
69// <example>
70// This example shows how to get attributes from an image.
71// make it known to the image.
72// <srcblock>
73// // Open the image (as readonly for the moment).
74// PagedImage<Float> myimage ("image.name");
75// // Get access to attibute handler LOFAR_SOURCE.
76// ImageExtrAttr& = myimage.attrHandler ("LOFAR_SOURCE");
77// // Get the data for some field.
78// Vector<String> names = ImageExtrAttr->getString("NAME");
79// </srcblock>
80// </example>
81//
82// <motivation>
83// LOFAR needed functionality to store arbitrary attributes.
84// </motivation>
85
87{
88public:
89 // Default construct from the image table.
91
92 // Attach the table and return this object.
93 // It looks for the table keyword ATTRGROUPS which contains the subtables
94 // defining the attribute groups.
95 // If the keyword does not exist, it will be added if <src>createHandler</src>
96 // is set.
97 // Otherwise the handler is an empty one and no groups can be added to it.
99 Bool createHandler = False);
100
102
103 // Attach the hid and return this object.
104 // It looks for the group ATTRGROUPS which contains groups
105 // defining the attribute groups.
106 // If the group does not exist, it will be added if <src>createHandler</src>
107 // is set.
108 // Otherwise the handler is an empty one and no groups can be added to it.
110 Bool createHandler,
111 Bool isWritable);
112
113 // Flush the attibrutes if needed.
114 virtual void flush();
115
116 // Test if the given attribute group is present.
117 virtual Bool hasGroup (const String& name);
118
119 // Get all attribute group names.
120 virtual Vector<String> groupNames() const;
121
122 // Get access to a group.
123 virtual ImageAttrGroup& openGroup (const String& groupName);
124
125 // Create an attribute group with the given name.
126 virtual ImageAttrGroup& createGroup (const String& groupName);
127
128 // Close the group with the given name. It will flush its attributes.
129 // Nothing is done if it is not open.
130 virtual void closeGroup (const String& groupName);
131
132private:
133 Bool itsCanWrite; //# writable?
134 std::shared_ptr<HDF5Group> itsGroup; //# HDF5 group to add to
135 std::map<String,ImageAttrGroupHDF5> itsGroupMap; //# attribute groups
136};
137
138} //# NAMESPACE CASACORE - END
139
140#endif
virtual ImageAttrGroup & openGroup(const String &groupName)
Get access to a group.
virtual void flush()
Flush the attibrutes if needed.
ImageAttrHandlerHDF5 & attachTable(const Table &image, Bool createHandler=False)
Attach the table and return this object.
ImageAttrHandlerHDF5()
Default construct from the image table.
virtual ImageAttrGroup & createGroup(const String &groupName)
Create an attribute group with the given name.
virtual Vector< String > groupNames() const
Get all attribute group names.
ImageAttrHandlerHDF5 & attachHid(const HDF5Object &hid, Bool createHandler, Bool isWritable)
Attach the hid and return this object.
virtual Bool hasGroup(const String &name)
Test if the given attribute group is present.
std::map< String, ImageAttrGroupHDF5 > itsGroupMap
std::shared_ptr< HDF5Group > itsGroup
virtual void closeGroup(const String &groupName)
Close the group with the given name.
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
const Bool False
Definition aipstype.h:42
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40