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