casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSTimeParse.h
Go to the documentation of this file.
1 //# MSTimeParse.h: Classes to hold results from time grammar parser
2 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003
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: aips2-request@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 //# $Id$
27 
28 #ifndef MS_MSTIMEPARSE_H
29 #define MS_MSTIMEPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 
44 // <summary>
45 // Class to hold values from time grammar parser
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // </prerequisite>
56 
57 // <etymology>
58 // MSTimeParse is the class used to parse a time command.
59 // </etymology>
60 
61 // <synopsis>
62 // MSTimeParse is used by the parser of time sub-expression statements.
63 // The parser is written in Bison and Flex in files MSTimeGram.y and .l.
64 // The statements in there use the routines in this file to act
65 // upon a reduced rule.
66 // Since multiple tables can be given (with a shorthand), the table
67 // names are stored in a list. The variable names can be qualified
68 // by the table name and will be looked up in the appropriate table.
69 //
70 // The class MSTimeParse only contains information about a table
71 // used in the table command. Global variables (like a list and a vector)
72 // are used in MSTimeParse.cc to hold further information.
73 //
74 // Global functions are used to operate on the information.
75 // The main function is the global function msTimeCommand.
76 // It executes the given STaQL command and returns the resulting ms.
77 // This is, in fact, the only function to be used by a user.
78 // </synopsis>
79 
80 // <motivation>
81 // It is necessary to be able to give a ms command in ASCII.
82 // This can be used in a CLI or in the table browser to get a subset
83 // of a table or to sort a table.
84 // </motivation>
85 
86 //# <todo asof="$DATE:$">
87 //# A List of bugs, limitations, extensions or planned refinements.
88 //# </todo>
89 
90 class MSTimeParse : public MSParse
91 {
92 
93 public:
94  // Default constructor
95  MSTimeParse ();
96 
97  // Associate the ms and the shorthand.
98  MSTimeParse (const MeasurementSet* ms,const TableExprNode& otherTens,const Bool honourRowFlags=True);
99  MSTimeParse (const MeasurementSet* ms,const TableExprNode& colAsTEN,
100  MSSelectableMainColumn& msMainColInterface,
101  const TableExprNode& otherTEN,
102  const Bool honourRowFlags=True);
104 
105 // ~MSTimeParse()
106 // {
107 // if (node_p) delete node_p;node_p=0x0;
108 // if (otherTens_p) delete otherTens_p;otherTens_p=0x0;
109 // }
110 
111  const TableExprNode *selectTime(const MEpoch& time,
112  bool daytime = false);
113  const TableExprNode *selectTimeGT(const MEpoch& lowboundTime,
114  bool daytime = false);
115  const TableExprNode *selectTimeLT(const MEpoch& upboundTime,
116  bool daytime = false);
117  const TableExprNode *selectTimeRange(const MEpoch& lowboundTime,
118  const MEpoch& upboundTime,
119  bool daytime = false,
120  Float edgeWidth=-1.0);
122  const TableExprNode *addCondition(TableExprNode& condition);
123 
124  /*
125  static const MEpoch *dayTimeConvert(Int day=-1, Int hour = -1,
126  Int minute = -1, Int second = -1,
127  Int millisec = -1);
128  */
129 
130  static void setDefaults(TimeFields& tf, Bool dataOrigin=True);
131  void getDefaults();
132  static void copyDefaults(TimeFields& target, TimeFields& source);
133  static const MEpoch *yearTimeConvert(Int year=-1, Int month=-1, Int day=-1,
134  Int hour = -1, Int minute = -1,
135  Int second = -1, Int millisec = -1);
136  static const MEpoch *yearTimeConvert(const TimeFields& tf);
137 
138  // Get table expression node object.
139  static const TableExprNode* node();
140 
141  Int year0() {return defaultYear;}
142  Int month0() {return defaultMonth;}
143  Int day0() {return defaultDay;}
144  Int hour0() {return defaultHour;}
149 
150  static void validate(const TimeFields& tf);
151  static void reset(){timeList.resize(3,0);}
152  static void cleanup() {if (node_p) delete node_p;node_p=0x0;}
153 
155  //private:
156 
161  static Double toTAIInSec(const MEpoch& time);
162  static MEpoch* yeartime;
163  static MEpoch* daytime;
170  void accumulateTimeList(const Double t0, const Double t1,const Double dT=-1);
174 };
175 
176 } //# NAMESPACE CASACORE - END
177 
178 #endif
const TableExprNode * selectTime(const MEpoch &time, bool daytime=false)
~MSTimeParse() { if (node_p) delete node_p;node_p=0x0; if (otherTens_p) delete otherTens_p;otherTens_...
int Int
Definition: aipstype.h:50
const Double hour
hour
static TableExprNode * node_p
Definition: MSTimeParse.h:154
const TableExprNode * selectTimeGT(const MEpoch &lowboundTime, bool daytime=false)
Class to hold values from an ms grammar parser.
Definition: MSParse.h:93
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1580
Handle class for a table column expression tree.
Definition: ExprNode.h:156
const TableExprNode * addCondition(TableExprNode &condition)
const TableExprNode * selectTimeRange(const MEpoch &lowboundTime, const MEpoch &upboundTime, bool daytime=false, Float edgeWidth=-1.0)
Matrix< Double > selectedTimes()
Definition: MSTimeParse.h:121
static TableExprNode columnAsTEN_p
Definition: MSTimeParse.h:172
Class to hold values from time grammar parser.
Definition: MSTimeParse.h:90
static void setDefaults(TimeFields &tf, Bool dataOrigin=True)
const TableExprNode * selectTimeLT(const MEpoch &upboundTime, bool daytime=false)
const Double minute
minute
TableExprNode year(const TableExprNode &node)
Definition: ExprNode.h:1515
TableExprNode month(const TableExprNode &node)
Definition: ExprNode.h:1519
A Measure: instant in time.
Definition: MEpoch.h:104
static TableExprNode * otherTens_p
private:
Definition: MSTimeParse.h:157
static const TableExprNode * node()
Get table expression node object.
static Double toTAIInSec(const MEpoch &time)
static MSSelectableMainColumn * mainColumn_p
Definition: MSTimeParse.h:173
static MSTimeParse * thisMSTParser
Definition: MSTimeParse.h:171
double Double
Definition: aipstype.h:55
static MEpoch * daytime
Definition: MSTimeParse.h:163
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static void copyDefaults(TimeFields &target, TimeFields &source)
float Float
Definition: aipstype.h:54
void accumulateTimeList(const Double t0, const Double t1, const Double dT=-1)
static Matrix< Double > timeList
Definition: MSTimeParse.h:169
const String colName
Definition: MSTimeParse.h:167
A Table intended to hold astronomical data (a set of Measurements).
static void reset()
Definition: MSTimeParse.h:151
const Double second
Time interval [T]:
static MEpoch * yeartime
Definition: MSTimeParse.h:162
static void validate(const TimeFields &tf)
TableExprNode day(const TableExprNode &node)
Definition: ExprNode.h:1523
static const MEpoch * yearTimeConvert(Int year=-1, Int month=-1, Int day=-1, Int hour=-1, Int minute=-1, Int second=-1, Int millisec=-1)
static MeasurementSet * ms_p
Definition: MSTimeParse.h:160
String: the storage and methods of handling collections of characters.
Definition: String.h:225
static Bool defaultTimeComputed
Definition: MSTimeParse.h:158
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:270
static void cleanup()
Definition: MSTimeParse.h:152
MeasurementSet * ms()
Get ms object.
const Bool True
Definition: aipstype.h:43
void resize(size_t nx, size_t ny, bool copyValues=false)
MSTimeParse()
Default constructor.