casacore
Loading...
Searching...
No Matches
ImageAttrHandlerCasa.h
Go to the documentation of this file.
1// # ImageAttrHandlerCasa.h: Attributes handler for CASA 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_IMAGEATTRHANDLERCASA_H
27#define IMAGES_IMAGEATTRHANDLERCASA_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageAttrHandler.h>
32#include <casacore/images/Images/ImageAttrGroupCasa.h>
33#include <map>
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// The attributes are divided into handlers. Each handler can reside in a subtable
62// of the image or in a handler in HDF5. All attributes in a handler have the
63// same number of values, where each value can be a scalar or (small) array.
64// It is possible to define units and measure info for an attribute.
65// </synopsis>
66
67// <example>
68// This example shows how to get attributes from an image.
69// make it known to the image.
70// <srcblock>
71// // Open the image (as readonly for the moment).
72// PagedImage<Float> myimage ("image.name");
73// // Get access to attibute handler LOFAR_SOURCE.
74// ImageExtrAttr& = myimage.attrHandler ("LOFAR_SOURCE");
75// // Get the data for some field.
76// Vector<String> names = ImageExtrAttr->getString("NAME");
77// </srcblock>
78// </example>
79//
80// <motivation>
81// LOFAR needed functionality to store arbitrary attributes.
82// </motivation>
83
85 public:
86 // Default construct from the image table.
88
89 // Attach the table and return this object.
90 // It looks for the table keyword ATTRGROUPS which contains the subtables
91 // defining the attribute groups.
92 // If the keyword does not exist, it will be added if <src>createHandler</src>
93 // is set.
94 // Otherwise the handler is an empty one and no groups can be added to it.
95 ImageAttrHandlerCasa& attachTable(const Table& image, Bool createHandler = False);
96
98
99 // Flush the attibrutes if needed.
100 virtual void flush();
101
102 // Test if the given attribute group is present.
103 virtual Bool hasGroup(const String& name);
104
105 // Get all attribute group names.
106 virtual Vector<String> groupNames() const;
107
108 // Get access to a group.
109 virtual ImageAttrGroup& openGroup(const String& groupName);
110
111 // Create an attribute group with the given name.
112 virtual ImageAttrGroup& createGroup(const String& groupName);
113
114 // Close the group with the given name. It will flush its attributes.
115 // Nothing is done if it is not open.
116 virtual void closeGroup(const String& groupName);
117
118 private:
119 Bool itsCanAdd; // # can groups be added?
120 Table itsImageTable; // # Table object of image
121 std::map<String, ImageAttrGroupCasa> itsGroupMap; // # attribute groups
122};
123
124} // namespace casacore
125
126#endif
ImageAttrHandlerCasa & attachTable(const Table &image, Bool createHandler=False)
Attach the table and return this object.
virtual ImageAttrGroup & openGroup(const String &groupName)
Get access to a group.
virtual Bool hasGroup(const String &name)
Test if the given attribute group is present.
virtual void flush()
Flush the attibrutes if needed.
ImageAttrHandlerCasa()
Default construct from the image table.
std::map< String, ImageAttrGroupCasa > itsGroupMap
virtual ImageAttrGroup & createGroup(const String &groupName)
Create an attribute group with the given name.
virtual void closeGroup(const String &groupName)
Close the group with the given name.
virtual Vector< String > groupNames() const
Get all attribute group names.
ImageAttrHandler()
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
String name() const
Return the name of the field.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40