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);
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:
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:
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:
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:
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:
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 (std::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<rownr_t>& 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);
323  const TableColumn& getColumn() const;
324 
325  // Get the data for the given rows.
338 
339  // Get the column unit (can be empty).
340  static Unit getColumnUnit (const TableColumn&);
341 
342 protected:
346 };
347 
348 
349 
350 // <summary>
351 // Rownumber in table select expression tree
352 // </summary>
353 
354 // <use visibility=local>
355 
356 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
357 // </reviewed>
358 
359 // <prerequisite>
360 //# Classes you should understand before using this one.
361 // <li> TableExprNode
362 // </prerequisite>
363 
364 // <synopsis>
365 // This class represents the rownumber() function in a table
366 // select expression tree.
367 // The origin is stored to indicate whether the first rownumber
368 // should be zero (in C++) or another value (1 in TaQL).
369 // </synopsis>
370 
372 {
373 public:
374  TableExprNodeRownr (const Table&, uInt origin);
376  Int64 getInt (const TableExprId& id);
377 private:
379 };
380 
381 
382 
383 // <summary>
384 // Rowid in table select expression tree
385 // </summary>
386 
387 // <use visibility=local>
388 
389 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
390 // </reviewed>
391 
392 // <prerequisite>
393 //# Classes you should understand before using this one.
394 // <li> TableExprNode
395 // </prerequisite>
396 
397 // <synopsis>
398 // This class represents the rowid() function in a table
399 // select expression tree.
400 // It is meant to get the original row number in a GIVING clause,
401 // but, of course, it can also be used in the SELECT clause.
402 // The row number returned is 0-based.
403 // </synopsis>
404 
406 {
407 public:
410  virtual void applySelection (const Vector<rownr_t>& rownrs);
411  Int64 getInt (const TableExprId& id);
412 private:
414 };
415 
416 
417 
418 // <summary>
419 // Random number in table select expression tree
420 // </summary>
421 
422 // <use visibility=local>
423 
424 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
425 // </reviewed>
426 
427 // <prerequisite>
428 //# Classes you should understand before using this one.
429 // <li> TableExprNode
430 // </prerequisite>
431 
432 // <synopsis>
433 // This class represents the rand() function in a table
434 // select expression tree.
435 // </synopsis>
436 
438 {
439 public:
443 private:
446 };
447 
448 
449 
450 } //# NAMESPACE CASACORE - END
451 
452 #endif
Multiplicative linear congruential generator.
Definition: Random.h:306
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:559
Scalar column in table select expression tree.
Definition: ExprDerNode.h:300
Array< Float > getColumnFloat(const Vector< rownr_t > &rownrs)
Array< uShort > getColumnuShort(const Vector< rownr_t > &rownrs)
Array< uChar > getColumnuChar(const Vector< rownr_t > &rownrs)
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
This node represents a table column.
static Unit getColumnUnit(const TableColumn &)
Get the column unit (can be empty).
Int64 getInt(const TableExprId &id)
Array< uInt > getColumnuInt(const Vector< rownr_t > &rownrs)
virtual void disableApplySelection()
Do not apply the selection.
Array< Int > getColumnInt(const Vector< rownr_t > &rownrs)
Array< String > getColumnString(const Vector< rownr_t > &rownrs)
Array< Double > getColumnDouble(const Vector< rownr_t > &rownrs)
Array< Complex > getColumnComplex(const Vector< rownr_t > &rownrs)
Bool getBool(const TableExprId &id)
Get the data for the given id.
TableExprNodeColumn(const Table &, const String &columnName)
const TableColumn & getColumn() const
Double getDouble(const TableExprId &id)
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
Array< Int64 > getColumnInt64(const Vector< rownr_t > &rownrs)
Array< DComplex > getColumnDComplex(const Vector< rownr_t > &rownrs)
Array< Bool > getColumnBool(const Vector< rownr_t > &rownrs)
Get the data for the given rows.
Array< Short > getColumnShort(const Vector< rownr_t > &rownrs)
DComplex getDComplex(const TableExprId &id)
String getString(const TableExprId &id)
Bool getColumnDataType(DataType &) const
Get the data type of this scalar column.
Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
TableExprNodeConstBool(const Bool &value)
Constant DComplex in table select expression tree.
Definition: ExprDerNode.h:172
TableExprNodeConstDComplex(const DComplex &value)
DComplex getDComplex(const TableExprId &id)
Constant Date in table select expression tree.
Definition: ExprDerNode.h:266
TableExprNodeConstDate(const MVTime &value)
Double getDouble(const TableExprId &id)
MVTime getDate(const TableExprId &id)
Constant Double in table select expression tree.
Definition: ExprDerNode.h:140
DComplex getDComplex(const TableExprId &id)
Double getDouble(const TableExprId &id)
TableExprNodeConstDouble(const Double &value)
Constant Int64 in table select expression tree.
Definition: ExprDerNode.h:107
Double getDouble(const TableExprId &id)
TableExprNodeConstInt(const Int64 &value)
DComplex getDComplex(const TableExprId &id)
Int64 getInt(const TableExprId &id)
Constant Regex or StringDistance in table select expression tree.
Definition: ExprDerNode.h:234
TaqlRegex getRegex(const TableExprId &id)
TableExprNodeConstRegex(const TaqlRegex &value)
Constant String in table select expression tree.
Definition: ExprDerNode.h:203
TableExprNodeConstString(const String &value)
String getString(const TableExprId &id)
Random number in table select expression tree.
Definition: ExprDerNode.h:438
Double getDouble(const TableExprId &id)
TableExprNodeRandom(const Table &)
Rowid in table select expression tree.
Definition: ExprDerNode.h:406
virtual void applySelection(const Vector< rownr_t > &rownrs)
Re-create the column object for a selection of rows.
TableExprNodeRowid(const Table &)
Int64 getInt(const TableExprId &id)
Vector< rownr_t > rownrs_p
Definition: ExprDerNode.h:413
Rownumber in table select expression tree.
Definition: ExprDerNode.h:372
TableExprNodeRownr(const Table &, uInt origin)
Int64 getInt(const TableExprId &id)
Uniform distribution.
Definition: Random.h:1273
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
double Double
Definition: aipstype.h:55