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