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