00001 //# ImageAttrGroupHDF5.h: Attribute group for a HDF5 image 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_IMAGEATTRGROUPHDF5_H 00029 #define IMAGES_IMAGEATTRGROUPHDF5_H 00030 00031 //# Includes 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/images/Images/ImageAttrGroup.h> 00034 #include <casacore/tables/Tables/TableProxy.h> 00035 #include <casacore/casa/HDF5/HDF5Group.h> 00036 00037 namespace casacore { 00038 00039 // <summary> 00040 // Attribute group for a HDF5 image. 00041 // </summary> 00042 // 00043 // <use visibility=export> 00044 // 00045 // <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc"> 00046 // </reviewed> 00047 // 00048 // <prerequisite> 00049 // <li> <linkto class=ImageAttrGroup>ImageAttrGroup</linkto> 00050 // </prerequisite> 00051 // 00052 // <synopsis> 00053 // This is the implementation of base class class ImageAttrGroup for an image 00054 // stored in the HDF5 format. 00055 // See the base class for more information. 00056 // </synopsis> 00057 00058 class ImageAttrGroupHDF5 : public ImageAttrGroup 00059 { 00060 public: 00061 // The default constructor creates a null object. 00062 explicit ImageAttrGroupHDF5 (Bool isWritable=False) 00063 : itsChanged (False), 00064 itsCanWrite (isWritable) 00065 {} 00066 00067 // Construct the object for an attribute group in the image. 00068 // If present, it reads all attributes. 00069 ImageAttrGroupHDF5 (const HDF5Group& image, const String& attrGroupName, 00070 Bool writable); 00071 00072 virtual ~ImageAttrGroupHDF5(); 00073 00074 // Test if it is a null object. 00075 Bool isNull() const 00076 { return itsRecord.empty(); } 00077 00078 // Flush the attibrutes if needed. 00079 void flush (HDF5Group& image, const String& attrGroupName); 00080 00081 // Get the number of rows in the group. 00082 virtual uInt nrows() const; 00083 00084 // Test if an attribute exists. 00085 virtual Bool hasAttr (const String& attrName) const; 00086 00087 // Get all attribute names. 00088 virtual Vector<String> attrNames() const; 00089 00090 // Get the datatype of a attribute. 00091 // It returns TpOther if the attribute is not defined. 00092 virtual DataType dataType (const String& attrName) const; 00093 00094 // Get the data of the given attribute in the given row. 00095 virtual ValueHolder getData (const String& attrName, uInt rownr); 00096 00097 // Get the data of all attributes in a rows. 00098 virtual Record getDataRow (uInt rownr); 00099 00100 // Get the possible units of the values (stored as attrName_UNIT). 00101 // An empty vector is returned if the attribute has no units. 00102 virtual Vector<String> getUnit (const String& attrName); 00103 00104 // Get the possible measure info as type,Ref (stored as attrName_MEASINFO). 00105 // An empty vector is returned if the attribute has no MEASINFO. 00106 virtual Vector<String> getMeasInfo (const String& attrName); 00107 00108 // Put the data of the given attribute. 00109 // If the table does not contain data yet, it will be sized to the size 00110 // of the vector. Otherwise the vector size has to match the table size. 00111 // <br>If not empty, the units and MEASINFO will be put as column keywords. 00112 // The MEASINFO vector must be given as type,Ref. 00113 virtual void putData (const String& attrName, uInt rownr, 00114 const ValueHolder& data, 00115 const Vector<String>& units = Vector<String>(), 00116 const Vector<String>& measInfo = Vector<String>()); 00117 00118 private: 00119 // Check the rownr and add a row if needed. 00120 void checkRows (const String& attrName, uInt rownr); 00121 00122 //# Data members. 00123 Record itsRecord; //# Record containing all attributes (subrecord per row) 00124 Bool itsChanged; //# Has the Record changed? 00125 Bool itsCanWrite; //# Can attributes be written? 00126 }; 00127 00128 } //# NAMESPACE CASACORE - END 00129 00130 #endif