casacore
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: 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_IMAGEATTRHANDLER_H
29 #define IMAGES_IMAGEATTRHANDLER_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/images/Images/ImageAttrGroup.h>
35 #include <casacore/casa/Containers/ValueHolder.h>
36 #include <casacore/casa/Arrays/Vector.h>
37 
38 namespace 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 // An ImageAttrHandler object handles those attributes in an image. Specific
65 // handler classes exist for images stored in casacore and in HDF5 format.
66 // The attributes are divided into group which are handled by ImageAttrGroup.
67 // A group (e.g. LOFAR_SOURCES) maps to a subtable in casacore format and a
68 // group in HDF5 format.
69 // </synopsis>
70 
71 // <example>
72 // This example shows how to get attributes from an image.
73 // <srcblock>
74 // // Open the image (done as read/write when having write access).
75 // PagedImage<Float> myimage ("image.name");
76 // // Get access to the attibute handler.
77 // ImageAttrHandler& attrHandler = myimage.attrHandler();
78 // // Get the names of all attribute groups.
79 // Vector<String> groupNames = attrHandler.groupNames();
80 // // Create a new group and define an attribute defining Freq in Hz.
81 // ImageAttrGroup& newGroup = attrHandler.createGroup ("NEW_GROUP");
82 // newGroup.putAttr ("Freq", ValueHolder(Vector<Double>(1, 1e7)),
83 // Vector<String>(1,"Hz"));
84 // </srcblock>
85 // </example>
86 //
87 // <motivation>
88 // LOFAR needed functionality to store arbitrary attributes.
89 // </motivation>
90 
92 {
93 public:
94  // Default constructor.
96  {}
97 
98  virtual ~ImageAttrHandler();
99 
100  // Flush the attibrutes if needed.
101  // The default implementation does nothing.
102  virtual void flush();
103 
104  // Test if the given attribute group is present.
105  // The default implementation returns False.
106  virtual Bool hasGroup (const String& name);
107 
108  // Get all attribute group names.
109  // The default implementation returns an empty vector.
110  virtual Vector<String> groupNames() const;
111 
112  // Get access to a group.
113  // The default implementation throws an exception.
114  virtual ImageAttrGroup& openGroup (const String& groupName);
115 
116  // Create an attribute group with the given name.
117  // The default implementation throws an exception.
118  virtual ImageAttrGroup& createGroup (const String& groupName);
119 
120  // Close the group with the given name.
121  // The default implementation does nothing.
122  virtual void closeGroup (const String& groupName);
123 };
124 
125 } //# NAMESPACE CASACORE - END
126 
127 #endif
virtual ImageAttrGroup & createGroup(const String &groupName)
Create an attribute group with the given name.
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 Vector< String > groupNames() const
Get all attribute group names.
virtual void flush()
Flush the attibrutes if needed.
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
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42