ImageAttrHandlerCasa.h

Go to the documentation of this file.
00001 //# ImageAttrHandlerCasa.h: Attributes handler for CASA images
00002 //# Copyright (C) 2012
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef IMAGES_IMAGEATTRHANDLERCASA_H
00029 #define IMAGES_IMAGEATTRHANDLERCASA_H
00030 
00031 
00032 //# Includes
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/images/Images/ImageAttrHandler.h>
00035 #include <casacore/images/Images/ImageAttrGroupCasa.h>
00036 #include <map>
00037 
00038 namespace casacore {
00039 
00040 // <summary>
00041 // Abstract base class for an image attributes handler.
00042 // </summary>
00043 
00044 // <use visibility=export>
00045 
00046 // <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> <linkto class=ImageInterface>ImageInterface</linkto>
00051 // </prerequisite>
00052 
00053 // <etymology>
00054 // This class makes it possible to store extra attributes with an image to
00055 // describe atrbitrary meta information.
00056 // </etymology>
00057 
00058 // <synopsis> 
00059 // For LOFAR it was needed to store extra meta information and to be able to
00060 // convert it from casacore table format to HDF5 format and vice-versa.
00061 // Furthermore, it must be possible to access the information in a way that
00062 // arbitrary info can be stored and retrieved.
00063 //
00064 // The attributes are divided into handlers. Each handler can reside in a subtable
00065 // of the image or in a handler in HDF5. All attributes in a handler have the
00066 // same number of values, where each value can be a scalar or (small) array.
00067 // It is possible to define units and measure info for an attribute.
00068 // </synopsis> 
00069 
00070 // <example>
00071 // This example shows how to get attributes from an image.
00072 // make it known to the image.
00073 // <srcblock>
00074 //   // Open the image (as readonly for the moment).
00075 //   PagedImage<Float> myimage ("image.name");
00076 //   // Get access to attibute handler LOFAR_SOURCE.
00077 //   ImageExtrAttr& = myimage.attrHandler ("LOFAR_SOURCE");
00078 //   // Get the data for some field.
00079 //   Vector<String> names = ImageExtrAttr->getString("NAME");
00080 // </srcblock>
00081 // </example>
00082 //
00083 // <motivation>
00084 // LOFAR needed functionality to store arbitrary attributes.
00085 // </motivation>
00086 
00087 class ImageAttrHandlerCasa : public ImageAttrHandler
00088 {
00089 public: 
00090   // Default construct from the image table.
00091   ImageAttrHandlerCasa();
00092 
00093   // Attach the table and return this object.
00094   // It looks for the table keyword ATTRGROUPS which contains the subtables
00095   // defining the attribute groups.
00096   // If the keyword does not exist, it will be added if <src>createHandler</src>
00097   // is set.
00098   // Otherwise the handler is an empty one and no groups can be added to it.
00099   ImageAttrHandlerCasa& attachTable (const Table& image,
00100                                      Bool createHandler = False);
00101 
00102   virtual ~ImageAttrHandlerCasa();
00103 
00104   // Flush the attibrutes if needed.
00105   virtual void flush();
00106 
00107   // Test if the given attribute group is present.
00108   virtual Bool hasGroup (const String& name);
00109 
00110   // Get all attribute group names.
00111   virtual Vector<String> groupNames() const;
00112 
00113   // Get access to a group.
00114   virtual ImageAttrGroup& openGroup (const String& groupName);
00115 
00116   // Create an attribute group with the given name.
00117   virtual ImageAttrGroup& createGroup (const String& groupName);
00118 
00119   // Close the group with the given name. It will flush its attributes.
00120   // Nothing is done if it is not open.
00121   virtual void closeGroup (const String& groupName);
00122 
00123 private:
00124   Bool                                itsCanAdd;      //# can groups be added?
00125   Table                               itsImageTable;  //# Table object of image
00126   std::map<String,ImageAttrGroupCasa> itsGroupMap;    //# attribute groups
00127 };
00128 
00129 } //# NAMESPACE CASACORE - END
00130 
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1