casa
$Rev:20696$
|
00001 //# TableInfo.h: Table type, subtype and further info 00002 //# Copyright (C) 1996,1997,1999 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: TableInfo.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00027 00028 #ifndef TABLES_TABLEINFO_H 00029 #define TABLES_TABLEINFO_H 00030 00031 //# Includes 00032 #include <casa/aips.h> 00033 #include <casa/BasicSL/String.h> 00034 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 // <summary> 00039 // Table type, subtype and further info 00040 // </summary> 00041 00042 // <use visibility=local> 00043 00044 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tTable.cc"> 00045 // </reviewed> 00046 00047 //# <prerequisite> 00048 //# Classes you should understand before using this one. 00049 //# </prerequisite> 00050 00051 // <etymology> 00052 // TableInfo holds information (like type) about a table. 00053 // </etymology> 00054 00055 // <synopsis> 00056 // TableInfo holds information about a table. It contains the following 00057 // information: 00058 // <dl> 00059 // <dt> Type 00060 // <dd> the type of a table (e.g. IMAGE, LOG). 00061 // <dt> SubType 00062 // <dd> the subtype of a table (e.g. UVDATA, MAP or ANTENNAPATTERN for 00063 // type IMAGE). 00064 // <dt> Readme 00065 // <dd> An arbitrary number of lines containing ancillary text 00066 // describing the table (or maybe its history). 00067 // </dl> 00068 // This information is stored 00069 // in the file <src>table.info</src> in the table directory. 00070 // Regular tables as well as reference tables (results of sort/select) 00071 // have their own table.info file. 00072 // <br> 00073 // The initial table-info of a regular table is blank. It has to be set 00074 // explicitly by the user. 00075 // <br> 00076 // The initial table-info of a reference table 00077 // is a copy of the table-info of its parent table. The user can add 00078 // lines to the readme information to describe the table in more detail. 00079 // Of course, the type and/or subtype can be changed at will. 00080 // <p> 00081 // The type and subtype information are stored at the beginning of 00082 // the first two lines of the file as: 00083 // <srcblock> 00084 // Type = TypeString 00085 // SubType = SubTypeString 00086 // </srcblock> 00087 // These lines in the table.info file can be used by external programs 00088 // (like the filebrowser) to determine the type of table being handled. 00089 // <p> 00090 // The third line in the file is blank. The line(s) thereafter contain 00091 // the possible readme information (note that multiple readme lines are 00092 // possible). They can be added using the function <src>readmeAddLine</src>. 00093 // <p> 00094 // Existing tables do not have a table.info file yet. The table system 00095 // will handle them correctly and use a blank type, subtype 00096 // and readme string. A table.info file will be created when the 00097 // table is opened for update. 00098 // <p> 00099 // To be sure that different table types have unique names, it can be 00100 // useful to use enum's and to define them in one common file. For 00101 // AIPS++ tables this enum is defined in this file. 00102 00103 // <example> 00104 // <srcblock> 00105 // // Open a table for update. 00106 // Table table("name", Table::Update); 00107 // // Get its TableInfo object. 00108 // TableInfo& info = table.tableInfo(); 00109 // // Set type and subtype. 00110 // info.setType ("IMAGE"); 00111 // info.setSubType ("SubTypeString"); 00112 // // Add a few readme lines. The second one adds 2 lines. 00113 // info.readmeAddLine ("the first readme string"); 00114 // info.readmeAddLine ("the second readme string\nthe third readme string"); 00115 // // Display the type, etc.. 00116 // cout << info.type() << " " << info.subType() << endl; 00117 // cout << info.readme(); 00118 // </srcblock> 00119 // </example> 00120 00121 // <motivation> 00122 // External programs need to be able to determine the type of a table. 00123 // </motivation> 00124 00125 //# <todo asof="$DATE:$"> 00126 //# A List of bugs, limitations, extensions or planned refinements. 00127 //# </todo> 00128 00129 00130 class TableInfo 00131 { 00132 public: 00133 // enum for various standard Table types. 00134 // Underscores in the enumerator indicate different sub-types 00135 enum Type { 00136 // a PagedImage is a PagedArray with coordinates and Masking (opt.) 00137 PAGEDIMAGE, 00138 // a PagedArray (.../Lattices/PagedArray.h) 00139 PAGEDARRAY, 00140 // MeasurementSet main Table 00141 MEASUREMENTSET, 00142 // MeasurementSet Antenna table 00143 ANTENNA, 00144 // MeasurementSet Array table 00145 ARRAY, 00146 // MeasurementSet Feed characteristics table 00147 FEED, 00148 // MeasurementSet Field table 00149 FIELD, 00150 // MeasurementSet Observation information table 00151 OBSERVATION, 00152 // MeasurementSet Oserving Log table 00153 OBSLOG, 00154 // MeasurementSet Source table 00155 SOURCE, 00156 // MeasurementSet Spectral Window table 00157 SPECTRALWINDOW, 00158 // MeasurementSet System Calibration table 00159 SYSCAL, 00160 // MeasurementSet Weather table 00161 WEATHER, 00162 // Measurement Equation Calibration table 00163 ME_CALIBRATION, 00164 // AIPS++ Log table 00165 LOG, 00166 // A ComponentList table contains parameterised representations of the 00167 // sky brightness. 00168 COMPONENTLIST 00169 }; 00170 00171 // Create an empty object. 00172 TableInfo(); 00173 00174 // Create the object reading it from the given file name. 00175 // If the file does not exist, type, subtype and readme are 00176 // initialized to a blank string. 00177 explicit TableInfo (const String& fileName); 00178 00179 // Create a TableInfo object of one of the predefined types. 00180 // This is a centralised way of setting the Table type only. 00181 TableInfo (Type which); 00182 00183 // Copy constructor (copy semantics). 00184 TableInfo (const TableInfo& that); 00185 00186 // Assignment (copy semantics). 00187 TableInfo& operator= (const TableInfo& that); 00188 00189 ~TableInfo(); 00190 00191 // Get the table (sub)type. 00192 // <group> 00193 const String& type() const; 00194 const String& subType() const; 00195 // </group> 00196 00197 // Get the readme. 00198 const String& readme() const; 00199 00200 // Set the table (sub)type. 00201 void setType (const String& type); 00202 void setSubType (const String& subType); 00203 00204 // Convert the Type enumerator to a type and subType string 00205 // <group> 00206 static String type(Type tableType); 00207 static String subType(Type tableType); 00208 // </group> 00209 00210 // Clear the readme. 00211 void readmeClear(); 00212 00213 // Add a line to the readme. 00214 // It will itself add a newline character ('\n') to the end of the line. 00215 void readmeAddLine (const String& readmeLine); 00216 00217 // Write the TableInfo object. 00218 void flush (const String& fileName); 00219 00220 private: 00221 String type_p; 00222 String subType_p; 00223 String readme_p; 00224 Bool writeIt_p; // True = object has changed, so has to be written 00225 }; 00226 00227 00228 00229 inline const String& TableInfo::type() const 00230 { 00231 return type_p; 00232 } 00233 inline const String& TableInfo::subType() const 00234 { 00235 return subType_p; 00236 } 00237 inline const String& TableInfo::readme() const 00238 { 00239 return readme_p; 00240 } 00241 00242 00243 00244 00245 } //# NAMESPACE CASA - END 00246 00247 #endif