casacore
ExprDerNode.h
Go to the documentation of this file.
1 //# ExprDerNode.h: Nodes representing scalars in table select expression tree
2 //# Copyright (C) 1994,1995,1996,1997,1999,2000,2001
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: ExprDerNode.h 21521 2014-12-10 08:06:42Z gervandiepen $
27 
28 #ifndef TABLES_EXPRDERNODE_H
29 #define TABLES_EXPRDERNODE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/TaQL/ExprNodeRep.h>
34 #include <casacore/tables/Tables/TableColumn.h>
35 #include <casacore/casa/Arrays/Vector.h>
36 #include <casacore/casa/BasicMath/Random.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class TableColumn;
42 class Table;
43 
44 //# This file defines classes derived from TableExprNode representing
45 //# the data type and operator in a table expression.
46 //#
47 //# Data types Bool, Int64, Double, DComplex and String are used.
48 //# Char, uChar, Short, uShort, Int, and uInt are converted to Int64,
49 //# Float to Double, and Complex to DComplex.
50 //# Binary operators +, -, *, /, ==, >=, >, <, <= and != are recognized.
51 //# Also &&, ||, parentheses and unary +, - and ! are recognized.
52 
53 
54 
55 // <summary>
56 // Constant Bool in table select expression tree
57 // </summary>
58 
59 // <use visibility=local>
60 
61 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
62 // </reviewed>
63 
64 // <prerequisite>
65 //# Classes you should understand before using this one.
66 // <li> TableExprNode
67 // </prerequisite>
68 
69 // <synopsis>
70 // This class represents a constant in a table select expression tree.
71 // This is also used to hold the value of a table keyword, which is
72 // constant over the entire table.
73 // </synopsis>
74 
76 {
77 public:
80  Bool getBool (const TableExprId& id);
81 private:
83 };
84 
85 
86 // <summary>
87 // Constant Int64 in table select expression tree
88 // </summary>
89 
90 // <use visibility=local>
91 
92 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
93 // </reviewed>
94 
95 // <prerequisite>
96 //# Classes you should understand before using this one.
97 // <li> TableExprNode
98 // </prerequisite>
99 
100 // <synopsis>
101 // This class represents a constant in a table select expression tree.
102 // This is also used to hold the value of a table keyword, which is
103 // constant over the entire table.
104 // </synopsis>
105 
107 {
108 public:
111  Int64 getInt (const TableExprId& id);
112  Double getDouble (const TableExprId& id);
113  DComplex getDComplex (const TableExprId& id);
114 private:
116 };
117 
118 
119 // <summary>
120 // Constant Double in table select expression tree
121 // </summary>
122 
123 // <use visibility=local>
124 
125 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
126 // </reviewed>
127 
128 // <prerequisite>
129 //# Classes you should understand before using this one.
130 // <li> TableExprNode
131 // </prerequisite>
132 
133 // <synopsis>
134 // This class represents a constant in a table select expression tree.
135 // This is also used to hold the value of a table keyword, which is
136 // constant over the entire table.
137 // </synopsis>
138 
140 {
141 public:
144  Double getDouble (const TableExprId& id);
145  DComplex getDComplex (const TableExprId& id);
146 private:
148 };
149 
150 
151 // <summary>
152 // Constant DComplex in table select expression tree
153 // </summary>
154 
155 // <use visibility=local>
156 
157 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
158 // </reviewed>
159 
160 // <prerequisite>
161 //# Classes you should understand before using this one.
162 // <li> TableExprNode
163 // </prerequisite>
164 
165 // <synopsis>
166 // This class represents a constant in a table select expression tree.
167 // This is also used to hold the value of a table keyword, which is
168 // constant over the entire table.
169 // </synopsis>
170 
172 {
173 public:
176  DComplex getDComplex (const TableExprId& id);
177 private:
179 };
180 
181 
182 // <summary>
183 // Constant String in table select expression tree
184 // </summary>
185 
186 // <use visibility=local>
187 
188 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
189 // </reviewed>
190 
191 // <prerequisite>
192 //# Classes you should understand before using this one.
193 // <li> TableExprNode
194 // </prerequisite>
195 
196 // <synopsis>
197 // This class represents a constant in a table select expression tree.
198 // This is also used to hold the value of a table keyword, which is
199 // constant over the entire table.
200 // </synopsis>
201 
203 {
204 public:
207  String getString (const TableExprId& id);
208 private:
210 };
211 
212 
213 // <summary>
214 // Constant Regex or StringDistance in table select expression tree
215 // </summary>
216 
217 // <use visibility=local>
218 
219 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
220 // </reviewed>
221 
222 // <prerequisite>
223 //# Classes you should understand before using this one.
224 // <li> TableExprNode
225 // </prerequisite>
226 
227 // <synopsis>
228 // This class represents a constant in a table select expression tree.
229 // This is also used to hold the value of a table keyword, which is
230 // constant over the entire table.
231 // </synopsis>
232 
234 {
235 public:
238  TaqlRegex getRegex (const TableExprId& id);
239 private:
242 };
243 
244 
245 // <summary>
246 // Constant Date in table select expression tree
247 // </summary>
248 
249 // <use visibility=local>
250 
251 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
252 // </reviewed>
253 
254 // <prerequisite>
255 //# Classes you should understand before using this one.
256 // <li> TableExprNode
257 // </prerequisite>
258 
259 // <synopsis>
260 // This class represents a constant in a table select expression tree.
261 // This is also used to hold the value of a table keyword, which is
262 // constant over the entire table.
263 // </synopsis>
264 
266 {
267 public:
270  Double getDouble(const TableExprId& id);
271  MVTime getDate (const TableExprId& id);
272 private:
274 };
275 
276 
277 
278 // <summary>
279 // Scalar column in table select expression tree
280 // </summary>
281 
282 // <use visibility=local>
283 
284 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
285 // </reviewed>
286 //
287 // <prerequisite>
288 //# Classes you should understand before using this one.
289 // <li> TableExprNode
290 // </prerequisite>
291 
292 // <synopsis>
293 // This class represents a scalar column in a table select expression tree.
294 // When the select expression gets evaluated, the value of the
295 // given row in the column is used.
296 // </synopsis>
297 
298 
300 {
301 public:
302  TableExprNodeColumn (const Table&, const String& columnName);
304 
305  // This node represents a table column.
306  virtual void getColumnNodes (vector<TableExprNodeRep*>& cols);
307 
308  // Do not apply the selection.
309  virtual void disableApplySelection();
310 
311  // Re-create the column object for a selection of rows.
312  virtual void applySelection (const Vector<uInt>& rownrs);
313 
314  // Get the data type of this scalar column.
315  Bool getColumnDataType (DataType&) const;
316 
317  // Get the data for the given id.
318  Bool getBool (const TableExprId& id);
319  Int64 getInt (const TableExprId& id);
320  Double getDouble (const TableExprId& id);
321  DComplex getDComplex (const TableExprId& id);
322  String getString (const TableExprId& id);
323  const TableColumn& getColumn() const;
324 
325  // Get the data for the given rows.
326  Array<Bool> getColumnBool (const Vector<uInt>& rownrs);
327  Array<uChar> getColumnuChar (const Vector<uInt>& rownrs);
328  Array<Short> getColumnShort (const Vector<uInt>& rownrs);
330  Array<Int> getColumnInt (const Vector<uInt>& rownrs);
331  Array<uInt> getColumnuInt (const Vector<uInt>& rownrs);
332  Array<Float> getColumnFloat (const Vector<uInt>& rownrs);
337 
338  // Get the column unit (can be empty).
339  static Unit getColumnUnit (const TableColumn&);
340 
341 protected:
345 };
346 
347 
348 
349 // <summary>
350 // Rownumber in table select expression tree
351 // </summary>
352 
353 // <use visibility=local>
354 
355 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
356 // </reviewed>
357 
358 // <prerequisite>
359 //# Classes you should understand before using this one.
360 // <li> TableExprNode
361 // </prerequisite>
362 
363 // <synopsis>
364 // This class represents the rownumber() function in a table
365 // select expression tree.
366 // The origin is stored to indicate whether the first rownumber
367 // should be zero (in C++) or an other value (1 in TaQL)
368 // </synopsis>
369 
371 {
372 public:
373  TableExprNodeRownr (const Table&, uInt origin);
375  Int64 getInt (const TableExprId& id);
376 private:
378 };
379 
380 
381 
382 // <summary>
383 // Rowid in table select expression tree
384 // </summary>
385 
386 // <use visibility=local>
387 
388 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
389 // </reviewed>
390 
391 // <prerequisite>
392 //# Classes you should understand before using this one.
393 // <li> TableExprNode
394 // </prerequisite>
395 
396 // <synopsis>
397 // This class represents the rowid() function in a table
398 // select expression tree.
399 // It is meant to get the original row number in a GIVING clause,
400 // but, of course, it can also be used in the SELECT clause.
401 // The row number returned is 0-based.
402 // </synopsis>
403 
405 {
406 public:
407  TableExprNodeRowid (const Table&);
409  virtual void applySelection (const Vector<uInt>& rownrs);
410  Int64 getInt (const TableExprId& id);
411 private:
413 };
414 
415 
416 
417 // <summary>
418 // Random number in table select expression tree
419 // </summary>
420 
421 // <use visibility=local>
422 
423 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
424 // </reviewed>
425 
426 // <prerequisite>
427 //# Classes you should understand before using this one.
428 // <li> TableExprNode
429 // </prerequisite>
430 
431 // <synopsis>
432 // This class represents the rand() function in a table
433 // select expression tree.
434 // </synopsis>
435 
437 {
438 public:
439  TableExprNodeRandom (const Table&);
441  Double getDouble (const TableExprId& id);
442 private:
445 };
446 
447 
448 
449 } //# NAMESPACE CASACORE - END
450 
451 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
virtual Array< uInt > getColumnuInt(const Vector< uInt > &rownrs)
Uniform distribution.
Definition: Random.h:1272
virtual Array< Bool > getColumnBool(const Vector< uInt > &rownrs)
Get the value of the expression evaluated for the entire column.
Main interface class to a read/write table.
Definition: Table.h:149
Constant String in table select expression tree.
Definition: ExprDerNode.h:202
virtual MVTime getDate(const TableExprId &id)
Constant Double in table select expression tree.
Definition: ExprDerNode.h:139
virtual Int64 getInt(const TableExprId &id)
Scalar column in table select expression tree.
Definition: ExprDerNode.h:299
virtual Array< Double > getColumnDouble(const Vector< uInt > &rownrs)
virtual Array< uShort > getColumnuShort(const Vector< uInt > &rownrs)
virtual Array< Float > getColumnFloat(const Vector< uInt > &rownrs)
virtual Array< DComplex > getColumnDComplex(const Vector< uInt > &rownrs)
Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
virtual void applySelection(const Vector< uInt > &rownrs)
Re-create the column object for a selection of rows.
virtual Array< Int > getColumnInt(const Vector< uInt > &rownrs)
defines physical units
Definition: Unit.h:189
virtual Double getDouble(const TableExprId &id)
double Double
Definition: aipstype.h:55
virtual Array< String > getColumnString(const Vector< uInt > &rownrs)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void getColumnNodes(vector< TableExprNodeRep *> &cols)
Get the nodes representing a table column.
Read/write access to a table column.
Definition: TableColumn.h:98
virtual void disableApplySelection()
Do not apply the selection.
virtual Array< Complex > getColumnComplex(const Vector< uInt > &rownrs)
Constant Date in table select expression tree.
Definition: ExprDerNode.h:265
Constant DComplex in table select expression tree.
Definition: ExprDerNode.h:171
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
TableExprNodeConstBool(const Bool &value)
Constant Regex or StringDistance in table select expression tree.
Definition: ExprDerNode.h:233
virtual String getString(const TableExprId &id)
Class to handle a Regex or StringDistance.
Definition: ExprNodeRep.h:75
virtual TaqlRegex getRegex(const TableExprId &id)
Multiplicative linear congruential generator.
Definition: Random.h:305
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Class to deal with Levensthein distance of strings.
Random number in table select expression tree.
Definition: ExprDerNode.h:436
virtual DComplex getDComplex(const TableExprId &id)
virtual Array< uChar > getColumnuChar(const Vector< uInt > &rownrs)
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:266
Constant Int64 in table select expression tree.
Definition: ExprDerNode.h:106
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:553
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Rowid in table select expression tree.
Definition: ExprDerNode.h:404
virtual Array< Short > getColumnShort(const Vector< uInt > &rownrs)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
virtual Bool getColumnDataType(DataType &) const
Get the data type of the column.
Constant Bool in table select expression tree.
Definition: ExprDerNode.h:75
Rownumber in table select expression tree.
Definition: ExprDerNode.h:370