casacore
ExprNodeRep.h
Go to the documentation of this file.
1 //# ExprNodeRep.h: Abstract base class for a node in a table column expression tree
2 //# Copyright (C) 1994,1995,1996,1997,1998,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: ExprNodeRep.h 21262 2012-09-07 12:38:36Z gervandiepen $
27 
28 #ifndef TABLES_EXPRNODEREP_H
29 #define TABLES_EXPRNODEREP_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/Tables/Table.h>
34 #include <casacore/tables/TaQL/TableExprId.h>
35 #include <casacore/tables/TaQL/ExprRange.h>
36 #include <casacore/tables/TaQL/MArray.h>
37 #include <casacore/casa/BasicSL/Complex.h>
38 #include <casacore/casa/Quanta/MVTime.h>
39 #include <casacore/casa/Quanta/Unit.h>
40 #include <casacore/casa/Utilities/DataType.h>
41 #include <casacore/casa/Utilities/Regex.h>
42 #include <casacore/casa/Utilities/StringDistance.h>
43 #include <casacore/casa/iosfwd.h>
44 
45 namespace casacore { //# NAMESPACE CASACORE - BEGIN
46 
47 //# Forward Declarations
48 class TableExprNode;
49 class TableExprNodeColumn;
50 class TableExprGroupFuncBase;
51 template<class T> class Block;
52 
53 
54 // <summary>
55 // Class to handle a Regex or StringDistance.
56 // </summary>
57 
58 // <use visibility=local>
59 
60 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
61 // </reviewed>
62 
63 // <prerequisite>
64 //# Classes you should understand before using this one.
65 // <li> <linkto class=Regex>Regex</linkto>
66 // <li> <linkto class=StringDistance>StringDistance</linkto>
67 // </prerequisite>
68 
69 // <synopsis>
70 // A StringDistance (Levensthein distance) in TaQL is given in the same way
71 // as a Regex. This class is needed to have a single object in the parse tree
72 // objects containing them (in class TableExprNodeConstRegex).
73 // </synopsis>
74 
75 class TaqlRegex
76 {
77 public:
78  // Construct from a regex.
79  explicit TaqlRegex (const Regex& regex)
80  : itsRegex(regex)
81  {}
82 
83  // Construct from a StringDistance.
84  explicit TaqlRegex (const StringDistance& dist)
85  : itsDist(dist)
86  {}
87 
88  // Does the regex or maximum string distance match?
89  Bool match (const String& str) const
90  { return itsRegex.regexp().empty() ?
91  itsDist.match(str) : str.matches(itsRegex);
92  }
93 
94  // Return the regular expression.
95  const Regex& regex() const
96  { return itsRegex; }
97 
98 private:
101 };
102 
103 
104 
105 // <summary>
106 // Abstract base class for a node in a table column expression tree
107 // </summary>
108 
109 // <use visibility=local>
110 
111 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
112 // </reviewed>
113 
114 // <prerequisite>
115 //# Classes you should understand before using this one.
116 // <li> <linkto class=TableExprNode>TableExprNode</linkto>
117 // </prerequisite>
118 
119 // <etymology>
120 // TableExprNodeRep is the (abstract) REPresentation of a node in a table
121 // expression tree.
122 // </etymology>
123 
124 // <synopsis>
125 // TableExprNodeRep is the base class for all nodes in a table
126 // expression tree. It is used by the handle class TableExprNode.
127 // <p>
128 // The objects of this class are reference-counted to make it possible
129 // that the same object is reused.
130 // </synopsis>
131 
132 // <motivation>
133 // TableExprNodeRep and its derivations store a table select expression
134 // before actually evaluating it. It is also possible that the classes
135 // are used by the table expression parser defined in TableParse and
136 // TableGram.
137 // <br>
138 // For each operator a special derived class is implemented.
139 // Another approach could have been to store the operator as
140 // a flag and switch on that. However, that causes extra overhead
141 // and the C++ virtual function mechanism is designed for
142 // these purposes.
143 // </motivation>
144 
145 // <todo asof="$DATE:$">
146 //# A List of bugs, limitations, extensions or planned refinements.
147 // <li> add selection by comparing with a set of values
148 // </todo>
149 
150 
152 {
153 public:
154  // Define the data types of a node.
163  NTReal, //# NTInt or NTDouble
164  NTDouCom, //# NTDouble or NTComplex
165  NTNumeric, //# NTInt, NTDouble, or NTComplex
166  NTAny //# Any data type
167  };
168 
169  // Define the value types.
170  enum ValueType {
176  VTIndex
177  };
178 
179  // Define the operator types.
180  // LE and LT are handled as GE and GT with swapped operands.
181  enum OperType {OtPlus, OtMinus, OtTimes, OtDivide, OtModulo,
182  OtBitAnd, OtBitOr, OtBitXor, OtBitNegate,
183  OtEQ, OtGE, OtGT, OtNE, OtIN,
184  OtAND, OtOR, OtNOT, OtMIN,
185  OtColumn, OtField, OtLiteral, OtFunc, OtSlice, OtUndef,
186  OtRownr, OtRandom
187  };
188 
189  // Define the value types of the 2 arguments when arrays are involved.
190  enum ArgType {
191  NoArr, ArrArr, ArrSca, ScaArr
192  };
193 
194  // Define (sub-)expression type
195  enum ExprType {
196  // A constant subexpression which can be evaluated immediately.
198  // A variable (i.e. row dependent) subexpression which
199  // has to be evaluated for each table row.
200  Variable
201  // An expensive constant subexpression which should only be
202  // evaluated when needed (e.g. a subquery).
203 // Lazy
204  };
205 
206  // Construct a node.
208  Int ndim, const IPosition& shape,
209  const Table& table);
210 
211  // This constructor is called from the derived TableExprNodeRep.
213 
214  // Copy constructor.
216 
217  // The destructor deletes all the underlying TableExprNode objects.
218  virtual ~TableExprNodeRep();
219 
220  // Link to this object, i.e. increase its reference count.
221  TableExprNodeRep* link();
222 
223  // Unlink from the given object.
224  // If its reference count is zero, delete it.
225  static void unlink (TableExprNodeRep*);
226 
227  // Do not apply the selection.
228  virtual void disableApplySelection();
229 
230  // Re-create the column object for a selection of rows.
231  // The default implementation does nothing.
232  virtual void applySelection (const Vector<uInt>& rownrs);
233 
234  // Get the unit conversion factor.
235  // Default 1 is returned.
236  virtual Double getUnitFactor() const;
237 
238  // Throw an exception if an aggregate function is used in
239  // the expression node.
240  static void checkAggrFuncs (const TableExprNodeRep* node);
241 
242  // Get the nodes representing an aggregate function.
243  virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr);
244 
245  // Get the nodes representing a table column.
246  virtual void getColumnNodes (vector<TableExprNodeRep*>& cols);
247 
248  // Create the correct immediate aggregate function object.
249  // The default implementation throws an exception, because it should
250  // only be called for TableExprAggrNode(Array).
251  virtual CountedPtr<TableExprGroupFuncBase> makeGroupAggrFunc();
252 
253  // Is the aggregate function a lazy or an immediate one?
254  // The default implementation returns True
255  // (because all UDF aggregate functions have to be lazy).
256  virtual Bool isLazyAggregate() const;
257 
258  // Get a scalar value for this node in the given row.
259  // The appropriate functions are implemented in the derived classes and
260  // will usually invoke the get in their children and apply the
261  // operator on the resulting values.
262  // <group>
263  virtual Bool getBool (const TableExprId& id);
264  virtual Int64 getInt (const TableExprId& id);
265  virtual Double getDouble (const TableExprId& id);
266  virtual DComplex getDComplex (const TableExprId& id);
267  virtual String getString (const TableExprId& id);
268  virtual TaqlRegex getRegex (const TableExprId& id);
269  virtual MVTime getDate (const TableExprId& id);
270  // </group>
271 
272  // Get an array value for this node in the given row.
273  // The appropriate functions are implemented in the derived classes and
274  // will usually invoke the get in their children and apply the
275  // operator on the resulting values.
276  // <group>
277  virtual MArray<Bool> getArrayBool (const TableExprId& id);
278  virtual MArray<Int64> getArrayInt (const TableExprId& id);
279  virtual MArray<Double> getArrayDouble (const TableExprId& id);
280  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
281  virtual MArray<String> getArrayString (const TableExprId& id);
282  virtual MArray<MVTime> getArrayDate (const TableExprId& id);
283  // </group>
284 
285  // General get functions for template purposes.
286  // <group>
287  void get (const TableExprId& id, Bool& value)
288  { value = getBool (id); }
289  void get (const TableExprId& id, Int64& value)
290  { value = getInt (id); }
291  void get (const TableExprId& id, Double& value)
292  { value = getDouble (id); }
293  void get (const TableExprId& id, DComplex& value)
294  { value = getDComplex (id); }
295  void get (const TableExprId& id, MVTime& value)
296  { value = getDate (id); }
297  void get (const TableExprId& id, String& value)
298  { value = getString (id); }
299  void get (const TableExprId& id, MArray<Bool>& value)
300  { value = getArrayBool (id); }
301  void get (const TableExprId& id, MArray<Int64>& value)
302  { value = getArrayInt (id); }
303  void get (const TableExprId& id, MArray<Double>& value)
304  { value = getArrayDouble (id); }
305  void get (const TableExprId& id, MArray<DComplex>& value)
306  { value = getArrayDComplex (id); }
307  void get (const TableExprId& id, MArray<MVTime>& value)
308  { value = getArrayDate (id); }
309  void get (const TableExprId& id, MArray<String>& value)
310  { value = getArrayString (id); }
311  // </group>
312 
313  // Get a value as an array, even it it is a scalar.
314  // This is useful if one could give an argument as scalar or array.
315  // <group>
316  MArray<Bool> getBoolAS (const TableExprId& id);
317  MArray<Int64> getIntAS (const TableExprId& id);
318  MArray<Double> getDoubleAS (const TableExprId& id);
319  MArray<DComplex> getDComplexAS (const TableExprId& id);
320  MArray<String> getStringAS (const TableExprId& id);
321  MArray<MVTime> getDateAS (const TableExprId& id);
322  // </group>
323 
324  // Does a value occur in an array or set?
325  // The default implementation tests if it is in an array.
326  // <group>
327  virtual Bool hasBool (const TableExprId& id, Bool value);
328  virtual Bool hasInt (const TableExprId& id, Int64 value);
329  virtual Bool hasDouble (const TableExprId& id, Double value);
330  virtual Bool hasDComplex (const TableExprId& id, const DComplex& value);
331  virtual Bool hasString (const TableExprId& id, const String& value);
332  virtual Bool hasDate (const TableExprId& id, const MVTime& value);
333  virtual MArray<Bool> hasArrayBool (const TableExprId& id,
334  const MArray<Bool>& value);
335  virtual MArray<Bool> hasArrayInt (const TableExprId& id,
336  const MArray<Int64>& value);
337  virtual MArray<Bool> hasArrayDouble (const TableExprId& id,
338  const MArray<Double>& value);
339  virtual MArray<Bool> hasArrayDComplex (const TableExprId& id,
340  const MArray<DComplex>& value);
341  virtual MArray<Bool> hasArrayString (const TableExprId& id,
342  const MArray<String>& value);
343  virtual MArray<Bool> hasArrayDate (const TableExprId& id,
344  const MArray<MVTime>& value);
345  // </group>
346 
347  // Get the number of rows in the table associated with this expression.
348  // One is returned if the expression is a constant.
349  // Zero is returned if no table is associated with it.
350  uInt nrow() const;
351 
352  // Get the data type of the column.
353  // It returns True when it could set the data type (which it can
354  // if the expression is a scalar column or a constant array column pixel).
355  // Otherwise it returns False.
356  virtual Bool getColumnDataType (DataType&) const;
357 
358  // Get the value of the expression evaluated for the entire column.
359  // The data of function called should match the data type as
360  // returned by function <src>getColumnDataType</src>.
361  // <group>
362  virtual Array<Bool> getColumnBool (const Vector<uInt>& rownrs);
363  virtual Array<uChar> getColumnuChar (const Vector<uInt>& rownrs);
364  virtual Array<Short> getColumnShort (const Vector<uInt>& rownrs);
365  virtual Array<uShort> getColumnuShort (const Vector<uInt>& rownrs);
366  virtual Array<Int> getColumnInt (const Vector<uInt>& rownrs);
367  virtual Array<uInt> getColumnuInt (const Vector<uInt>& rownrs);
368  virtual Array<Float> getColumnFloat (const Vector<uInt>& rownrs);
369  virtual Array<Double> getColumnDouble (const Vector<uInt>& rownrs);
370  virtual Array<Complex> getColumnComplex (const Vector<uInt>& rownrs);
371  virtual Array<DComplex> getColumnDComplex (const Vector<uInt>& rownrs);
372  virtual Array<String> getColumnString (const Vector<uInt>& rownrs);
373  // </group>
374 
375  // Convert the tree to a number of range vectors which at least
376  // select the same things.
377  // This function is very useful to convert the expression to
378  // some intervals covering the select expression. This can
379  // be used to do a rough fast selection via an index and do the
380  // the slower final selection on that much smaller subset.
381  // The function can only convert direct comparisons of columns
382  // with constants (via ==, !=, >, >=, < or <=) and their combinations
383  // using && or ||.
384  virtual void ranges (Block<TableExprRange>&);
385 
386  // Get the data type of the derived TableExprNode object.
387  // This is the data type of the resulting value. E.g. a compare
388  // of 2 numeric values results in a Bool, thus the data type
389  // of, say, TableExprNodeEQ<T> is always Bool.
390  // Function getInternalDT gives the internal data type, thus in
391  // the example above the data type of T.
392  NodeDataType dataType() const;
393 
394  // Is the data type real (i.e., integer or double)?
395  Bool isReal() const;
396 
397  // Get the value type.
398  ValueType valueType() const;
399 
400  // Set the value type.
401  void setValueType (ValueType vtype);
402 
403  // Get the operator type.
404  OperType operType() const;
405 
406  // Get the expression type.
407  ExprType exprType() const;
408 
409  // Is the expression a constant?
410  Bool isConstant() const;
411 
412  // Get the unit.
413  const Unit& unit() const;
414 
415  // Set the unit.
416  // It also sets the datatype to NTDouble if it is NTInt.
417  void setUnit (const Unit& unit);
418 
419  // Get the fixed dimensionality (same for all rows).
420  Int ndim() const;
421 
422  // Get the fixed shape (same for all rows).
423  const IPosition& shape() const;
424 
425  // Get the shape for the given row.
426  // It returns the fixed shape if defined, otherwise getShape(id).
427  const IPosition& shape (const TableExprId& id);
428 
429  // Is the value in the given row defined?
430  // The default implementation returns True.
431  virtual Bool isDefined (const TableExprId& id);
432 
433  // Show the expression tree.
434  virtual void show (ostream&, uInt indent) const;
435 
436  // Get table. This gets the Table object to which a
437  // TableExprNode belongs. A TableExprNode belongs to the Table to
438  // which the first column used in an expression belongs.
439  // <group>
440  Table& table();
441  const Table& table() const;
442  // </group>
443 
444  // Let a set node convert itself to the given unit.
445  // The default implementation does nothing.
446  virtual void adaptSetUnits (const Unit&);
447 
448  // Create a range object from a column and an interval.
449  static void createRange (Block<TableExprRange>&,
450  TableExprNodeColumn*, Double start, Double end);
451 
452  // Create a empty range object.
453  static void createRange (Block<TableExprRange>&);
454 
455  // Convert a NodeDataType to a string.
456  static String typeString (NodeDataType);
457 
458  // Convert a ValueType to a string.
459  static String typeString (ValueType);
460 
461 protected:
462  uInt count_p; //# Reference count
463  Table table_p; //# Table from which node is "derived"
464  NodeDataType dtype_p; //# data type of the operation
465  ValueType vtype_p; //# value type of the result
466  OperType optype_p; //# operator type
467  ArgType argtype_p; //# argument types
468  ExprType exprtype_p; //# Constant or Variable
469  Int ndim_p; //# Fixed dimensionality of node values
470  //# -1 = variable dimensionality
471  IPosition shape_p; //# Fixed shape of node values
472  Unit unit_p; //# Unit of the values
473 
474  // Get the shape for the given row.
475  virtual const IPosition& getShape (const TableExprId& id);
476 
477  // Get pointer to REPresentation object.
478  // This is used by derived classes.
479  static TableExprNodeRep* getRep (TableExprNode&);
480 
481  // When one of the children is a constant, convert its data type
482  // to that of the other operand. This avoids that conversions are
483  // done for each get.
484  // The default implementation does nothing.
485  virtual void convertConstChild();
486 
487  // Check if this node uses the same table pointer.
488  // Fill the Table object if it is still null.
489  // <group>
490  void checkTablePtr (const TableExprNodeRep* node);
491  static void checkTablePtr (Table& table,
492  const TableExprNodeRep* node);
493  // </group>
494 
495  // Set expression type to Variable if node is Variable.
496  // <group>
497  void fillExprType (const TableExprNodeRep* node);
498  static void fillExprType (ExprType&, const TableExprNodeRep* node);
499  // </group>
500 
501  // When the node is constant, it is evaluated and replaced by
502  // the appropriate TableExprNodeConst object.
503  // If not constant, it calls the virtual ConvertConstChild function
504  // which can convert a constant child when appropriate.
505  static TableExprNodeRep* convertNode (TableExprNodeRep* thisNode,
506  Bool convertConstType);
507 
508 private:
509  // A copy of a TableExprNodeRep cannot be made.
511 };
512 
513 
514 
515 
516 // <summary>
517 // Abstract base class for a node having 0, 1, or 2 child nodes.
518 // </summary>
519 
520 // <use visibility=local>
521 
522 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
523 // </reviewed>
524 
525 // <prerequisite>
526 //# Classes you should understand before using this one.
527 // <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
528 // </prerequisite>
529 
530 // <etymology>
531 // TableExprNodeBinary is a node in the table expression tree
532 // representing a binary node (i.e. having 2 operands).
533 // </etymology>
534 
535 // <synopsis>
536 // TableExprNodeBinary is the abstract base class for all nodes in a table
537 // expression tree using up to 2 operands.
538 // It is used as the base class for the node classes representing
539 // operator +, -, etc..
540 // </synopsis>
541 
542 // <motivation>
543 // This class contains the common functionality for the classes
544 // representing a binary (or unary) operator.
545 // </motivation>
546 
547 //# <todo asof="$DATE:$">
548 //# A List of bugs, limitations, extensions or planned refinements.
549 //# <li> to be filled in
550 //# </todo>
551 
552 
554 {
555 public:
556  // Constructor
559 
560  // Destructor
561  virtual ~TableExprNodeBinary();
562 
563  // Show the expression tree.
564  virtual void show (ostream&, uInt indent) const;
565 
566  // Get the nodes representing an aggregate function.
567  virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr);
568 
569  // Get the nodes representing a table column.
570  virtual void getColumnNodes (vector<TableExprNodeRep*>& cols);
571 
572  // Check the data types and get the common one.
573  static NodeDataType getDT (NodeDataType leftDtype,
574  NodeDataType rightDype,
575  OperType operType);
576 
577  // Check the data and value types and get the common one.
578  static TableExprNodeRep getTypes (const TableExprNodeRep& left,
579  const TableExprNodeRep& right,
580  OperType operType);
581 
582  // Link the children to the node and convert the children
583  // to constants if needed and possible. Also convert the node to
584  // constant if possible.
585  // The operand data types can be adapted as needed.
586  static TableExprNodeRep* fillNode (TableExprNodeBinary* thisNode,
587  TableExprNodeRep* left,
588  TableExprNodeRep* right,
589  Bool convertConstType,
590  Bool adaptDataType=True);
591 
592  // Handle the units of the children and possibly set the parent's unit.
593  // The default implementation make the units of the children equal and
594  // set the parent unit to that unit if the parent is not a Bool value.
595  virtual void handleUnits();
596 
597  // When one of the children is a constant, convert its data type
598  // to that of the other operand. This avoids that conversions are
599  // done for each get.
600  void convertConstChild();
601 
602  // Get the child nodes.
603  // <group>
605  { return lnode_p; }
607  { return rnode_p; }
608  // </group>
609 
610 protected:
611  // Make the units equal.
612  // Replace the right node if needed.
613  static const Unit& makeEqualUnits (TableExprNodeRep* left,
614  TableExprNodeRep*& right);
615 
616  TableExprNodeRep* lnode_p; //# left operand
617  TableExprNodeRep* rnode_p; //# right operand
618 };
619 
620 
621 
622 
623 // <summary>
624 // Abstract base class for a node having multiple child nodes.
625 // </summary>
626 
627 // <use visibility=local>
628 
629 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
630 // </reviewed>
631 
632 // <prerequisite>
633 //# Classes you should understand before using this one.
634 // <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
635 // </prerequisite>
636 
637 // <etymology>
638 // TableExprNodeMulti is a node in the table expression tree
639 // which can have MULTIple child nodes.
640 // </etymology>
641 
642 // <synopsis>
643 // TableExprNodeMulti is the abstract base class for all nodes in a table
644 // expression tree using multiple operands.
645 // It is used as the base class for the node classes representing
646 // functions, sets, indices, etc..
647 // </synopsis>
648 
649 // <motivation>
650 // This class contains the common functionality for the classes
651 // representing a node with multiple operands.
652 // </motivation>
653 
654 //# <todo asof="$DATE:$">
655 //# A List of bugs, limitations, extensions or planned refinements.
656 //# <li> to be filled in
657 //# </todo>
658 
659 
661 {
662 public:
663  // Constructor
665  const TableExprNodeRep& source);
666 
667  // Destructor
668  virtual ~TableExprNodeMulti();
669 
670  // Show the expression tree.
671  virtual void show (ostream&, uInt indent) const;
672 
673  // Get the nodes representing an aggregate function.
674  virtual void getAggrNodes (vector<TableExprNodeRep*>& aggr);
675 
676  // Get the nodes representing a table column.
677  virtual void getColumnNodes (vector<TableExprNodeRep*>& cols);
678 
679  // Check number of arguments
680  // low <= number_of_args <= high
681  // It throws an exception if wrong number of arguments.
682  static uInt checkNumOfArg (uInt low, uInt high,
683  const PtrBlock<TableExprNodeRep*>& nodes);
684 
685  // Get the child nodes.
687  { return operands_p; }
688 
689  // Check datatype of nodes and return output type.
690  // It also sets the expected data type of the operands (from dtIn).
691  static NodeDataType checkDT (Block<Int>& dtypeOper,
692  NodeDataType dtIn, NodeDataType dtOut,
693  const PtrBlock<TableExprNodeRep*>& nodes);
694 
695 protected:
697 };
698 
699 
700 
701 //# Get the data type of the node.
703  { return dtype_p; }
704 
706  { return dtype_p==NTInt || dtype_p==NTDouble; }
707 
708 //# Get the value type of the node.
710  { return vtype_p; }
711 
712 //# Set the value type of the node.
714  { vtype_p = vtype; }
715 
716 //# Get the operator type of the node.
718  { return optype_p; }
719 
720 //# Get the expression type of the node.
722  { return exprtype_p; }
723 
724 //# Is the expression a constant?
726  { return (exprtype_p == Constant); }
727 
728 //# Get the unit of the node.
729 inline const Unit& TableExprNodeRep::unit() const
730  { return unit_p; }
731 
732 //# Get the fixed dimensionality of the node.
734  { return ndim_p; }
735 
736 //# Get the fixed shape of the node.
737 inline const IPosition& TableExprNodeRep::shape() const
738  { return shape_p; }
739 
740 //# Get the table from which the node is derived.
742  { return table_p; }
743 inline const Table& TableExprNodeRep::table() const
744  { return table_p; }
745 
747  { checkTablePtr (table_p, node); }
749  { fillExprType (exprtype_p, node); }
750 
751 //# Link to the node.
753 {
754  count_p++;
755  return this;
756 }
757 
758 
759 } //# NAMESPACE CASACORE - END
760 
761 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
void fillExprType(const TableExprNodeRep *node)
Set expression type to Variable if node is Variable.
Definition: ExprNodeRep.h:748
int Int
Definition: aipstype.h:50
TaqlRegex(const Regex &regex)
Construct from a regex.
Definition: ExprNodeRep.h:79
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
Main interface class to a read/write table.
Definition: Table.h:149
const PtrBlock< TableExprNodeRep * > & getChildren() const
Get the child nodes.
Definition: ExprNodeRep.h:686
Int ndim() const
Get the fixed dimensionality (same for all rows).
Definition: ExprNodeRep.h:733
const TableExprNodeRep * getRightChild() const
Definition: ExprNodeRep.h:606
Handle class for a table column expression tree.
Definition: ExprNode.h:614
A constant subexpression which can be evaluated immediately.
Definition: ExprNodeRep.h:197
PtrHolder< T > & operator=(const PtrHolder< T > &other)
Scalar column in table select expression tree.
Definition: ExprDerNode.h:299
PtrBlock< TableExprNodeRep * > operands_p
Definition: ExprNodeRep.h:696
Bool match(const String &str) const
Does the regex or maximum string distance match?
Definition: ExprNodeRep.h:89
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Definition: ExprNodeRep.h:84
NodeDataType
Define the data types of a node.
Definition: ExprNodeRep.h:155
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:151
const TableExprNodeRep * getLeftChild() const
Get the child nodes.
Definition: ExprNodeRep.h:604
Bool empty() const
Test for empty.
Definition: String.h:375
ValueType valueType() const
Get the value type.
Definition: ExprNodeRep.h:709
void setValueType(ValueType vtype)
Set the value type.
Definition: ExprNodeRep.h:713
defines physical units
Definition: Unit.h:189
const IPosition & shape() const
Get the fixed shape (same for all rows).
Definition: ExprNodeRep.h:737
StringDistance itsDist
Definition: ExprNodeRep.h:100
ExprType
Define (sub-)expression type.
Definition: ExprNodeRep.h:195
ArgType
Define the value types of the 2 arguments when arrays are involved.
Definition: ExprNodeRep.h:190
NodeDataType dataType() const
Get the data type of the derived TableExprNode object.
Definition: ExprNodeRep.h:702
Referenced counted pointer for constant data.
Definition: CountedPtr.h:86
Abstract base class for a node having multiple child nodes.
Definition: ExprNodeRep.h:660
double Double
Definition: aipstype.h:55
OperType
Define the operator types.
Definition: ExprNodeRep.h:181
Regular expression class.
Definition: Regex.h:198
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
const Regex & regex() const
Return the regular expression.
Definition: ExprNodeRep.h:95
OperType operType() const
Get the operator type.
Definition: ExprNodeRep.h:717
TableExprNodeRep * rnode_p
Definition: ExprNodeRep.h:617
const String & regexp() const
Get the regular expression string.
Definition: Regex.h:259
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool isReal() const
Is the data type real (i.e., integer or double)?
Definition: ExprNodeRep.h:705
ValueType
Define the value types.
Definition: ExprNodeRep.h:170
const Unit & unit() const
Get the unit.
Definition: ExprNodeRep.h:729
ExprType exprType() const
Get the expression type.
Definition: ExprNodeRep.h:721
Bool match(const String &target) const
Test if the given target string is within the maximum distance.
A drop-in replacement for Block<T*>.
Definition: Block.h:861
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:2151
void checkTablePtr(const TableExprNodeRep *node)
Check if this node uses the same table pointer.
Definition: ExprNodeRep.h:746
Bool isConstant() const
Is the expression a constant?
Definition: ExprNodeRep.h:725
simple 1-D array
Definition: ArrayIO.h:47
The identification of a TaQL selection subject.
Definition: TableExprId.h:98
Table & table()
Get table.
Definition: ExprNodeRep.h:741
Class to handle a Regex or StringDistance.
Definition: ExprNodeRep.h:75
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Class to deal with Levensthein distance of strings.
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:266
Abstract base class for a node having 0, 1, or 2 child nodes.
Definition: ExprNodeRep.h:553
const Bool True
Definition: aipstype.h:43
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
TableExprNodeRep * lnode_p
Definition: ExprNodeRep.h:616
TableExprNodeRep * link()
Link to this object, i.e.
Definition: ExprNodeRep.h:752