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