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