casa
$Rev:20696$
|
00001 //# MSTimeParse.h: Classes to hold results from time grammar parser 00002 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003 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: MSTimeParse.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $ 00027 00028 #ifndef MS_MSTIMEPARSE_H 00029 #define MS_MSTIMEPARSE_H 00030 00031 //# Includes 00032 #include <ms/MeasurementSets/MSParse.h> 00033 #include <ms/MeasurementSets/MSSelectableMainColumn.h> 00034 #include <measures/Measures/MEpoch.h> 00035 #include <ms/MeasurementSets/MSTimeDefinitions.h> 00036 #include <casa/Containers/Block.h> 00037 #include <casa/Arrays/Matrix.h> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //# Forward Declarations 00042 00043 // <summary> 00044 // Class to hold values from time grammar parser 00045 // </summary> 00046 00047 // <use visibility=local> 00048 00049 // <reviewed reviewer="" date="" tests=""> 00050 // </reviewed> 00051 00052 // <prerequisite> 00053 //# Classes you should understand before using this one. 00054 // </prerequisite> 00055 00056 // <etymology> 00057 // MSTimeParse is the class used to parse a time command. 00058 // </etymology> 00059 00060 // <synopsis> 00061 // MSTimeParse is used by the parser of time sub-expression statements. 00062 // The parser is written in Bison and Flex in files MSTimeGram.y and .l. 00063 // The statements in there use the routines in this file to act 00064 // upon a reduced rule. 00065 // Since multiple tables can be given (with a shorthand), the table 00066 // names are stored in a list. The variable names can be qualified 00067 // by the table name and will be looked up in the appropriate table. 00068 // 00069 // The class MSTimeParse only contains information about a table 00070 // used in the table command. Global variables (like a list and a vector) 00071 // are used in MSTimeParse.cc to hold further information. 00072 // 00073 // Global functions are used to operate on the information. 00074 // The main function is the global function msTimeCommand. 00075 // It executes the given STaQL command and returns the resulting ms. 00076 // This is, in fact, the only function to be used by a user. 00077 // </synopsis> 00078 00079 // <motivation> 00080 // It is necessary to be able to give a ms command in ASCII. 00081 // This can be used in a CLI or in the table browser to get a subset 00082 // of a table or to sort a table. 00083 // </motivation> 00084 00085 //# <todo asof="$DATE:$"> 00086 //# A List of bugs, limitations, extensions or planned refinements. 00087 //# </todo> 00088 00089 class MSTimeParse : public MSParse 00090 { 00091 00092 public: 00093 // Default constructor 00094 MSTimeParse (); 00095 00096 // Associate the ms and the shorthand. 00097 MSTimeParse (const MeasurementSet* ms,const TableExprNode& otherTens,const Bool honourRowFlags=True); 00098 MSTimeParse (const MeasurementSet* ms,const TableExprNode& colAsTEN, 00099 MSSelectableMainColumn& msMainColInterface, 00100 const TableExprNode& otherTEN, 00101 const Bool honourRowFlags=True); 00102 ~MSTimeParse() {columnAsTEN_p=TableExprNode();}; 00103 00104 // ~MSTimeParse() 00105 // { 00106 // if (node_p) delete node_p;node_p=0x0; 00107 // if (otherTens_p) delete otherTens_p;otherTens_p=0x0; 00108 // }; 00109 00110 const TableExprNode *selectTime(const MEpoch& time, 00111 bool daytime = false); 00112 const TableExprNode *selectTimeGT(const MEpoch& lowboundTime, 00113 bool daytime = false); 00114 const TableExprNode *selectTimeLT(const MEpoch& upboundTime, 00115 bool daytime = false); 00116 const TableExprNode *selectTimeRange(const MEpoch& lowboundTime, 00117 const MEpoch& upboundTime, 00118 bool daytime = false); 00119 Matrix<Double> selectedTimes() {return timeList;}; 00120 const TableExprNode *addCondition(TableExprNode& condition); 00121 00122 /* 00123 static const MEpoch *dayTimeConvert(Int day=-1, Int hour = -1, 00124 Int minute = -1, Int second = -1, 00125 Int millisec = -1); 00126 */ 00127 00128 static void setDefaults(TimeFields& tf, Bool dataOrigin=True); 00129 void getDefaults(); 00130 static void copyDefaults(TimeFields& target, TimeFields& source); 00131 static const MEpoch *yearTimeConvert(Int year=-1, Int month=-1, Int day=-1, 00132 Int hour = -1, Int minute = -1, 00133 Int second = -1, Int millisec = -1); 00134 static const MEpoch *yearTimeConvert(const TimeFields& tf); 00135 00136 // Get table expression node object. 00137 static const TableExprNode* node(); 00138 00139 Int year0() {return defaultYear;}; 00140 Int month0() {return defaultMonth;}; 00141 Int day0() {return defaultDay;}; 00142 Int hour0() {return defaultHour;}; 00143 Int minute0() {return defaultMinute;}; 00144 Int second0() {return defaultSeconds;}; 00145 Int fractionalsec0() {return defaultFractionalSec;}; 00146 Double defaultInteg() {return defaultExposure;}; 00147 00148 static void validate(const TimeFields& tf); 00149 static void reset(){timeList.resize(2,0);}; 00150 static void cleanup() {if (node_p) delete node_p;node_p=0x0;}; 00151 00152 static TableExprNode* node_p; 00153 //private: 00154 00155 static TableExprNode *otherTens_p; 00156 static Bool defaultTimeComputed; 00157 MVTime firstRowTime; 00158 static MeasurementSet *ms_p; 00159 static Double toTAIInSec(const MEpoch& time); 00160 static MEpoch* yeartime; 00161 static MEpoch* daytime; 00162 Int defaultYear, defaultMonth, defaultDay, 00163 defaultHour, defaultMinute, defaultSeconds, defaultFractionalSec; 00164 Double defaultExposure; 00165 const String colName; 00166 Bool honourRowFlags_p; 00167 static Matrix<Double> timeList; 00168 void accumulateTimeList(const Double t0, const Double t1); 00169 static MSTimeParse *thisMSTParser; 00170 static TableExprNode columnAsTEN_p; 00171 static MSSelectableMainColumn *mainColumn_p; 00172 }; 00173 00174 } //# NAMESPACE CASA - END 00175 00176 #endif