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: aips2-request@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//# $Id$
27
28#ifndef IMAGES_IMAGEATTRHANDLERCASA_H
29#define IMAGES_IMAGEATTRHANDLERCASA_H
30
31
32//# Includes
33#include <casacore/casa/aips.h>
34#include <casacore/images/Images/ImageAttrHandler.h>
35#include <casacore/images/Images/ImageAttrGroupCasa.h>
36#include <map>
37
38namespace casacore {
39
40// <summary>
41// Abstract base class for an image attributes handler.
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc">
47// </reviewed>
48
49// <prerequisite>
50// <li> <linkto class=ImageInterface>ImageInterface</linkto>
51// </prerequisite>
52
53// <etymology>
54// This class makes it possible to store extra attributes with an image to
55// describe atrbitrary meta information.
56// </etymology>
57
58// <synopsis>
59// For LOFAR it was needed to store extra meta information and to be able to
60// convert it from casacore table format to HDF5 format and vice-versa.
61// Furthermore, it must be possible to access the information in a way that
62// arbitrary info can be stored and retrieved.
63//
64// The attributes are divided into handlers. Each handler can reside in a subtable
65// of the image or in a handler in HDF5. All attributes in a handler have the
66// same number of values, where each value can be a scalar or (small) array.
67// It is possible to define units and measure info for an attribute.
68// </synopsis>
69
70// <example>
71// This example shows how to get attributes from an image.
72// make it known to the image.
73// <srcblock>
74// // Open the image (as readonly for the moment).
75// PagedImage<Float> myimage ("image.name");
76// // Get access to attibute handler LOFAR_SOURCE.
77// ImageExtrAttr& = myimage.attrHandler ("LOFAR_SOURCE");
78// // Get the data for some field.
79// Vector<String> names = ImageExtrAttr->getString("NAME");
80// </srcblock>
81// </example>
82//
83// <motivation>
84// LOFAR needed functionality to store arbitrary attributes.
85// </motivation>
86
88{
89public:
90 // Default construct from the image table.
92
93 // Attach the table and return this object.
94 // It looks for the table keyword ATTRGROUPS which contains the subtables
95 // defining the attribute groups.
96 // If the keyword does not exist, it will be added if <src>createHandler</src>
97 // is set.
98 // Otherwise the handler is an empty one and no groups can be added to it.
100 Bool createHandler = False);
101
103
104 // Flush the attibrutes if needed.
105 virtual void flush();
106
107 // Test if the given attribute group is present.
108 virtual Bool hasGroup (const String& name);
109
110 // Get all attribute group names.
111 virtual Vector<String> groupNames() const;
112
113 // Get access to a group.
114 virtual ImageAttrGroup& openGroup (const String& groupName);
115
116 // Create an attribute group with the given name.
117 virtual ImageAttrGroup& createGroup (const String& groupName);
118
119 // Close the group with the given name. It will flush its attributes.
120 // Nothing is done if it is not open.
121 virtual void closeGroup (const String& groupName);
122
123private:
124 Bool itsCanAdd; //# can groups be added?
125 Table itsImageTable; //# Table object of image
126 std::map<String,ImageAttrGroupCasa> itsGroupMap; //# attribute groups
127};
128
129} //# NAMESPACE CASACORE - END
130
131#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:225
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:44
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42