casacore
Loading...
Searching...
No Matches
ImageAttrHandler.h
Go to the documentation of this file.
1// # ImageAttrHandler.h: Abstract base class for an image attributes handler
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_IMAGEATTRHANDLER_H
27#define IMAGES_IMAGEATTRHANDLER_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageAttrGroup.h>
32#include <casacore/casa/Containers/ValueHolder.h>
33#include <casacore/casa/Arrays/Vector.h>
34
35namespace casacore {
36
37// <summary>
38// Abstract base class for an image attributes handler.
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=ImageInterface>ImageInterface</linkto>
48// </prerequisite>
49
50// <etymology>
51// This class makes it possible to store extra attributes with an image to
52// describe atrbitrary meta information.
53// </etymology>
54
55// <synopsis>
56// For LOFAR it was needed to store extra meta information and to be able to
57// convert it from casacore table format to HDF5 format and vice-versa.
58// Furthermore, it must be possible to access the information in a way that
59// arbitrary info can be stored and retrieved.
60//
61// An ImageAttrHandler object handles those attributes in an image. Specific
62// handler classes exist for images stored in casacore and in HDF5 format.
63// The attributes are divided into group which are handled by ImageAttrGroup.
64// A group (e.g. LOFAR_SOURCES) maps to a subtable in casacore format and a
65// group in HDF5 format.
66// </synopsis>
67
68// <example>
69// This example shows how to get attributes from an image.
70// <srcblock>
71// // Open the image (done as read/write when having write access).
72// PagedImage<Float> myimage ("image.name");
73// // Get access to the attibute handler.
74// ImageAttrHandler& attrHandler = myimage.attrHandler();
75// // Get the names of all attribute groups.
76// Vector<String> groupNames = attrHandler.groupNames();
77// // Create a new group and define an attribute defining Freq in Hz.
78// ImageAttrGroup& newGroup = attrHandler.createGroup ("NEW_GROUP");
79// newGroup.putAttr ("Freq", ValueHolder(Vector<Double>(1, 1e7)),
80// Vector<String>(1,"Hz"));
81// </srcblock>
82// </example>
83//
84// <motivation>
85// LOFAR needed functionality to store arbitrary attributes.
86// </motivation>
87
89 public:
90 // Default constructor.
92
94
95 // Flush the attibrutes if needed.
96 // The default implementation does nothing.
97 virtual void flush();
98
99 // Test if the given attribute group is present.
100 // The default implementation returns False.
101 virtual Bool hasGroup(const String& name);
102
103 // Get all attribute group names.
104 // The default implementation returns an empty vector.
105 virtual Vector<String> groupNames() const;
106
107 // Get access to a group.
108 // The default implementation throws an exception.
109 virtual ImageAttrGroup& openGroup(const String& groupName);
110
111 // Create an attribute group with the given name.
112 // The default implementation throws an exception.
113 virtual ImageAttrGroup& createGroup(const String& groupName);
114
115 // Close the group with the given name.
116 // The default implementation does nothing.
117 virtual void closeGroup(const String& groupName);
118};
119
120} // namespace casacore
121
122#endif
virtual ImageAttrGroup & createGroup(const String &groupName)
Create an attribute group with the given name.
virtual Vector< String > groupNames() const
Get all attribute group names.
virtual ImageAttrGroup & openGroup(const String &groupName)
Get access to a group.
ImageAttrHandler()
Default constructor.
virtual void closeGroup(const String &groupName)
Close the group with the given name.
virtual Bool hasGroup(const String &name)
Test if the given attribute group is present.
virtual void flush()
Flush the attibrutes if needed.
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.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40