casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableInfo.h
Go to the documentation of this file.
1 //# TableInfo.h: Table type, subtype and further info
2 //# Copyright (C) 1996,1997,1999
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 TABLES_TABLEINFO_H
29 #define TABLES_TABLEINFO_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary>
39 // Table type, subtype and further info
40 // </summary>
41 
42 // <use visibility=local>
43 
44 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTable.cc">
45 // </reviewed>
46 
47 //# <prerequisite>
48 //# Classes you should understand before using this one.
49 //# </prerequisite>
50 
51 // <etymology>
52 // TableInfo holds information (like type) about a table.
53 // </etymology>
54 
55 // <synopsis>
56 // TableInfo holds information about a table. It contains the following
57 // information:
58 // <dl>
59 // <dt> Type
60 // <dd> the type of a table (e.g. IMAGE, LOG).
61 // <dt> SubType
62 // <dd> the subtype of a table (e.g. UVDATA, MAP or ANTENNAPATTERN for
63 // type IMAGE).
64 // <dt> Readme
65 // <dd> An arbitrary number of lines containing ancillary text
66 // describing the table (or maybe its history).
67 // </dl>
68 // This information is stored
69 // in the file <src>table.info</src> in the table directory.
70 // Regular tables as well as reference tables (results of sort/select)
71 // have their own table.info file.
72 // <br>
73 // The initial table-info of a regular table is blank. It has to be set
74 // explicitly by the user.
75 // <br>
76 // The initial table-info of a reference table
77 // is a copy of the table-info of its parent table. The user can add
78 // lines to the readme information to describe the table in more detail.
79 // Of course, the type and/or subtype can be changed at will.
80 // <p>
81 // The type and subtype information are stored at the beginning of
82 // the first two lines of the file as:
83 // <srcblock>
84 // Type = TypeString
85 // SubType = SubTypeString
86 // </srcblock>
87 // These lines in the table.info file can be used by external programs
88 // (like the filebrowser) to determine the type of table being handled.
89 // <p>
90 // The third line in the file is blank. The line(s) thereafter contain
91 // the possible readme information (note that multiple readme lines are
92 // possible). They can be added using the function <src>readmeAddLine</src>.
93 // <p>
94 // Existing tables do not have a table.info file yet. The table system
95 // will handle them correctly and use a blank type, subtype
96 // and readme string. A table.info file will be created when the
97 // table is opened for update.
98 // <p>
99 // To be sure that different table types have unique names, it can be
100 // useful to use enum's and to define them in one common file. For
101 // Casacore tables this enum is defined in this file.
102 
103 // <example>
104 // <srcblock>
105 // // Open a table for update.
106 // Table table("name", Table::Update);
107 // // Get its TableInfo object.
108 // TableInfo& info = table.tableInfo();
109 // // Set type and subtype.
110 // info.setType ("IMAGE");
111 // info.setSubType ("SubTypeString");
112 // // Add a few readme lines. The second one adds 2 lines.
113 // info.readmeAddLine ("the first readme string");
114 // info.readmeAddLine ("the second readme string\nthe third readme string");
115 // // Display the type, etc..
116 // cout << info.type() << " " << info.subType() << endl;
117 // cout << info.readme();
118 // </srcblock>
119 // </example>
120 
121 // <motivation>
122 // External programs need to be able to determine the type of a table.
123 // </motivation>
124 
125 //# <todo asof="$DATE:$">
126 //# A List of bugs, limitations, extensions or planned refinements.
127 //# </todo>
128 
129 
131 {
132 public:
133  // enum for various standard Table types.
134  // Underscores in the enumerator indicate different sub-types
135  enum Type {
136  // a PagedImage is a PagedArray with coordinates and Masking (opt.)
138  // a PagedArray (.../Lattices/PagedArray.h)
140  // MeasurementSet main Table
142  // MeasurementSet Antenna table
144  // MeasurementSet Array table
146  // MeasurementSet Feed characteristics table
148  // MeasurementSet Field table
150  // MeasurementSet Observation information table
152  // MeasurementSet Oserving Log table
154  // MeasurementSet Source table
156  // MeasurementSet Spectral Window table
158  // MeasurementSet System Calibration table
160  // MeasurementSet Weather table
162  // Measurement Equation Calibration table
164  // Casacore Log table
166  // A ComponentList table contains parameterised representations of the
167  // sky brightness.
169  };
170 
171  // Create an empty object.
172  TableInfo();
173 
174  // Create the object reading it from the given file name.
175  // If the file does not exist, type, subtype and readme are
176  // initialized to a blank string.
177  explicit TableInfo (const String& fileName);
178 
179  // Create a TableInfo object of one of the predefined types.
180  // This is a centralised way of setting the Table type only.
181  TableInfo (Type which);
182 
183  // Copy constructor (copy semantics).
184  TableInfo (const TableInfo& that);
185 
186  // Assignment (copy semantics).
187  TableInfo& operator= (const TableInfo& that);
188 
189  ~TableInfo();
190 
191  // Get the table (sub)type.
192  // <group>
193  const String& type() const;
194  const String& subType() const;
195  // </group>
196 
197  // Get the readme.
198  const String& readme() const;
199 
200  // Set the table (sub)type.
201  void setType (const String& type);
202  void setSubType (const String& subType);
203 
204  // Convert the Type enumerator to a type and subType string
205  // <group>
206  static String type(Type tableType);
207  static String subType(Type tableType);
208  // </group>
209 
210  // Clear the readme.
211  void readmeClear();
212 
213  // Add a line to the readme.
214  // It will itself add a newline character ('\n') to the end of the line.
215  void readmeAddLine (const String& readmeLine);
216 
217  // Write the TableInfo object.
218  void flush (const String& fileName);
219 
220 private:
224  Bool writeIt_p; // True = object has changed, so has to be written
225 };
226 
227 
228 
229 inline const String& TableInfo::type() const
230 {
231  return type_p;
232 }
233 inline const String& TableInfo::subType() const
234 {
235  return subType_p;
236 }
237 inline const String& TableInfo::readme() const
238 {
239  return readme_p;
240 }
241 
242 
243 
244 
245 } //# NAMESPACE CASACORE - END
246 
247 #endif
A ComponentList table contains parameterised representations of the sky brightness.
Definition: TableInfo.h:168
TableInfo & operator=(const TableInfo &that)
Assignment (copy semantics).
void readmeClear()
Clear the readme.
MeasurementSet Feed characteristics table.
Definition: TableInfo.h:147
MeasurementSet Weather table.
Definition: TableInfo.h:161
MeasurementSet Oserving Log table.
Definition: TableInfo.h:153
MeasurementSet Source table.
Definition: TableInfo.h:155
MeasurementSet System Calibration table.
Definition: TableInfo.h:159
const String & subType() const
Definition: TableInfo.h:233
Measurement Equation Calibration table.
Definition: TableInfo.h:163
const String & type() const
Get the table (sub)type.
Definition: TableInfo.h:229
MeasurementSet Field table.
Definition: TableInfo.h:149
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Type
enum for various standard Table types.
Definition: TableInfo.h:135
Table type, subtype and further info.
Definition: TableInfo.h:130
MeasurementSet Antenna table.
Definition: TableInfo.h:143
MeasurementSet Spectral Window table.
Definition: TableInfo.h:157
a PagedImage is a PagedArray with coordinates and Masking (opt.)
Definition: TableInfo.h:137
void readmeAddLine(const String &readmeLine)
Add a line to the readme.
void setType(const String &type)
Set the table (sub)type.
const String & readme() const
Get the readme.
Definition: TableInfo.h:237
MeasurementSet main Table.
Definition: TableInfo.h:141
TableInfo()
Create an empty object.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
MeasurementSet Observation information table.
Definition: TableInfo.h:151
a PagedArray (.../Lattices/PagedArray.h)
Definition: TableInfo.h:139
MeasurementSet Array table.
Definition: TableInfo.h:145
void setSubType(const String &subType)
Casacore Log table.
Definition: TableInfo.h:165
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
void flush(const String &fileName)
Write the TableInfo object.