casacore
ImageAttrGroupCasa.h
Go to the documentation of this file.
1 //# ImageAttrGroupCasa.h: Attribute group for a CASA image
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_IMAGEATTRGROUPCASA_H
29 #define IMAGES_IMAGEATTRGROUPCASA_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/images/Images/ImageAttrGroup.h>
34 #include <casacore/tables/Tables/TableProxy.h>
35 
36 namespace casacore {
37 
38 // <summary>
39 // Attribute group for a CASA image.
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=ImageAttrGroup>ImageAttrGroup</linkto>
49 // </prerequisite>
50 //
51 // <synopsis>
52 // This is the implementation of base class class ImageAttrGroup for an image
53 // stored in the casacore table format.
54 // See the base class for more information.
55 // </synopsis>
56 
58 {
59 public:
60  // The default constructor creates a null object.
62  {}
63 
64  // Construct the object for an attribute group in the image table.
65  // Note that the group name is the name of a subtable containing the info.
66  ImageAttrGroupCasa (const Table& image, const String& attrGroupName);
67 
69 
70  // Test if it is a null object.
71  Bool isNull() const
72  { return itsTable.table().isNull(); }
73 
74  // Flush the attibrutes if needed.
75  void flush();
76 
77  // Get the number of rows in the group.
78  virtual uInt nrows() const;
79 
80  // Test if an attribute exists.
81  virtual Bool hasAttr (const String& attrName) const;
82 
83  // Get all attribute names.
84  virtual Vector<String> attrNames() const;
85 
86  // Get the datatype of a attribute.
87  // It returns TpOther if the attribute is not defined.
88  virtual DataType dataType (const String& attrName) const;
89 
90  // Get the data of the given attribute.
91  virtual ValueHolder getData (const String& attrName, uInt rownr);
92 
93  // Get the data of all attributes in a rows.
94  virtual Record getDataRow (uInt rownr);
95 
96  // Get the possible units of the values.
97  // An empty vector is returned if the attribute has no units.
98  virtual Vector<String> getUnit (const String& attrName);
99 
100  // Get the possible measure info as type and Ref.
101  // An empty vector is returned if the attribute has no MEASINFO.
102  virtual Vector<String> getMeasInfo (const String& attrName);
103 
104  // Put the data of the given attribute.
105  // If the table does not contain data yet, it will be sized to the size
106  // of the vector. Otherwise the vector size has to match the table size.
107  // <br>If not empty, the units and MEASINFO will be put as column keywords.
108  // The MEASINFO vector must be given as type,Ref.
109  virtual void putData (const String& attrName, uInt rownr,
110  const ValueHolder& data,
111  const Vector<String>& units = Vector<String>(),
112  const Vector<String>& measInfo = Vector<String>());
113 
114 private:
115  // Check if the size matches the number of rows.
116  // Add rows if the table is still empty.
117  void checkRows (const String& attrName, uInt size);
118 
119  // Add a new column for the given attribute for the data type in the value.
120  Bool addNewColumn (const String& attrName, const ValueHolder&);
121 
122  //# Data members.
124 };
125 
126 } //# NAMESPACE CASACORE - END
127 
128 #endif
virtual void putData(const String &attrName, uInt rownr, const ValueHolder &data, const Vector< String > &units=Vector< String >(), const Vector< String > &measInfo=Vector< String >())
Put the data of the given attribute.
virtual DataType dataType(const String &attrName) const
Get the datatype of a attribute.
Bool addNewColumn(const String &attrName, const ValueHolder &)
Add a new column for the given attribute for the data type in the value.
virtual Vector< String > getUnit(const String &attrName)
Get the possible units of the values.
Bool isNull() const
Test if it is a null object.
void flush()
Flush the attibrutes if needed.
ImageAttrGroupCasa()
The default constructor creates a null object.
ImageAttrGroupCasa(const Table &image, const String &attrGroupName)
Construct the object for an attribute group in the image table.
virtual Bool hasAttr(const String &attrName) const
Test if an attribute exists.
virtual Vector< String > attrNames() const
Get all attribute names.
virtual uInt nrows() const
Get the number of rows in the group.
void checkRows(const String &attrName, uInt size)
Check if the size matches the number of rows.
virtual Record getDataRow(uInt rownr)
Get the data of all attributes in a rows.
virtual ValueHolder getData(const String &attrName, uInt rownr)
Get the data of the given attribute.
virtual Vector< String > getMeasInfo(const String &attrName)
Get the possible measure info as type and Ref.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Table & table()
Return the table object.
Definition: TableProxy.h:592
Bool isNull() const
Test if the object is null, i.e.
Definition: Table.h:477
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42