MSTimeParse.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1