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/Containers/Record.h>
38 #include <casacore/casa/BasicSL/Complex.h>
39 #include <casacore/casa/Quanta/MVTime.h>
40 #include <casacore/casa/Quanta/Unit.h>
41 #include <casacore/casa/Utilities/DataType.h>
42 #include <casacore/casa/Utilities/Regex.h>
43 #include <casacore/casa/Utilities/StringDistance.h>
44 #include <casacore/casa/iosfwd.h>
45 #include <vector>
46 
47 namespace casacore { //# NAMESPACE CASACORE - BEGIN
48 
49 //# Forward Declarations
50 class TableExprNode;
51 class TableExprNodeColumn;
52 class TableExprGroupFuncBase;
53 template<class T> class Block;
54 
55 //# Define a shared pointer to the Rep class.
58 
59 
60 // <summary>
61 // Class to handle a Regex or StringDistance.
62 // </summary>
63 
64 // <use visibility=local>
65 
66 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
67 // </reviewed>
68 
69 // <prerequisite>
70 //# Classes you should understand before using this one.
71 // <li> <linkto class=Regex>Regex</linkto>
72 // <li> <linkto class=StringDistance>StringDistance</linkto>
73 // </prerequisite>
74 
75 // <synopsis>
76 // A StringDistance (Levensthein distance) in TaQL is given in the same way
77 // as a Regex. This class is needed to have a single object in the parse tree
78 // objects containing them (in class TableExprNodeConstRegex).
79 // </synopsis>
80 
81 class TaqlRegex
82 {
83 public:
84  // Construct from a regex.
85  explicit TaqlRegex (const Regex& regex)
86  : itsRegex(regex)
87  {}
88 
89  // Construct from a StringDistance.
90  explicit TaqlRegex (const StringDistance& dist)
91  : itsDist(dist)
92  {}
93 
94  // Does the regex or maximum string distance match?
95  Bool match (const String& str) const
96  { return itsRegex.regexp().empty() ?
97  itsDist.match(str) : str.matches(itsRegex);
98  }
99 
100  // Return the regular expression.
101  const Regex& regex() const
102  { return itsRegex; }
103 
104 private:
107 };
108 
109 
110 
111 // <summary>
112 // Abstract base class for a node in a table column expression tree
113 // </summary>
114 
115 // <use visibility=local>
116 
117 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
118 // </reviewed>
119 
120 // <prerequisite>
121 //# Classes you should understand before using this one.
122 // <li> <linkto class=TableExprNode>TableExprNode</linkto>
123 // </prerequisite>
124 
125 // <etymology>
126 // TableExprNodeRep is the (abstract) REPresentation of a node in a table
127 // expression tree.
128 // </etymology>
129 
130 // <synopsis>
131 // TableExprNodeRep is the base class for all nodes in a table
132 // expression tree. It is used by the handle class TableExprNode.
133 // <p>
134 // The objects of this class are reference-counted to make it possible
135 // that the same object is reused.
136 // </synopsis>
137 
138 // <motivation>
139 // TableExprNodeRep and its derivations store a table select expression
140 // before actually evaluating it. It is also possible that the classes
141 // are used by the table expression parser defined in TableParse and
142 // TableGram.
143 // <br>
144 // For each operator a special derived class is implemented.
145 // Another approach could have been to store the operator as
146 // a flag and switch on that. However, that causes extra overhead
147 // and the C++ virtual function mechanism is designed for
148 // these purposes.
149 // </motivation>
150 
151 // <todo asof="$DATE:$">
152 //# A List of bugs, limitations, extensions or planned refinements.
153 // <li> add selection by comparing with a set of values
154 // </todo>
155 
156 
158 {
159 public:
160  // Define the data types of a node.
169  NTReal, //# NTInt or NTDouble
170  NTDouCom, //# NTDouble or NTComplex
171  NTNumeric, //# NTInt, NTDouble, or NTComplex
172  NTAny //# Any data type
173  };
174 
175  // Define the value types.
176  enum ValueType {
182  VTIndex
183  };
184 
185  // Define the operator types.
186  // LE and LT are handled as GE and GT with swapped operands.
187  enum OperType {OtPlus, OtMinus, OtTimes, OtDivide, OtModulo,
188  OtBitAnd, OtBitOr, OtBitXor, OtBitNegate,
189  OtEQ, OtGE, OtGT, OtNE, OtIN,
190  OtAND, OtOR, OtNOT, OtMIN,
191  OtColumn, OtField, OtLiteral, OtFunc, OtSlice, OtUndef,
192  OtRownr, OtRandom
193  };
194 
195  // Define the value types of the 2 arguments when arrays are involved.
196  enum ArgType {
197  NoArr, ArrArr, ArrSca, ScaArr
198  };
199 
200  // Define (sub-)expression type
201  enum ExprType {
202  // A constant subexpression which can be evaluated immediately.
204  // A variable (i.e. row dependent) subexpression which
205  // has to be evaluated for each table row.
206  Variable
207  // An expensive constant subexpression which should only be
208  // evaluated when needed (e.g. a subquery).
209 // Lazy
210  };
211 
212  // Construct a node.
214  Int ndim, const IPosition& shape,
215  const Table& table);
216 
217  // This constructor is called from the derived TableExprNodeRep.
219 
220  // Copy constructor.
222 
223  // The destructor deletes all the underlying TableExprNode objects.
224  virtual ~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 or its children.
239  void checkAggrFuncs();
240 
241  // Get the nodes representing an aggregate function.
242  virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
243 
244  // Get the nodes representing a table column.
245  virtual void getColumnNodes (std::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 MArray<Bool> getArrayBool (const TableExprId& id);
277  virtual MArray<Int64> getArrayInt (const TableExprId& id);
278  virtual MArray<Double> getArrayDouble (const TableExprId& id);
279  virtual MArray<DComplex> getArrayDComplex (const TableExprId& id);
280  virtual MArray<String> getArrayString (const TableExprId& id);
281  virtual MArray<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, MArray<Bool>& value)
299  { value = getArrayBool (id); }
300  void get (const TableExprId& id, MArray<Int64>& value)
301  { value = getArrayInt (id); }
302  void get (const TableExprId& id, MArray<Double>& value)
303  { value = getArrayDouble (id); }
304  void get (const TableExprId& id, MArray<DComplex>& value)
305  { value = getArrayDComplex (id); }
306  void get (const TableExprId& id, MArray<MVTime>& value)
307  { value = getArrayDate (id); }
308  void get (const TableExprId& id, MArray<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 give an argument as scalar or array.
314  // <group>
315  MArray<Bool> getBoolAS (const TableExprId& id);
316  MArray<Int64> getIntAS (const TableExprId& id);
317  MArray<Double> getDoubleAS (const TableExprId& id);
318  MArray<DComplex> getDComplexAS (const TableExprId& id);
319  MArray<String> getStringAS (const TableExprId& id);
320  MArray<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 MArray<Bool> hasArrayBool (const TableExprId& id,
333  const MArray<Bool>& value);
334  virtual MArray<Bool> hasArrayInt (const TableExprId& id,
335  const MArray<Int64>& value);
336  virtual MArray<Bool> hasArrayDouble (const TableExprId& id,
337  const MArray<Double>& value);
338  virtual MArray<Bool> hasArrayDComplex (const TableExprId& id,
339  const MArray<DComplex>& value);
340  virtual MArray<Bool> hasArrayString (const TableExprId& id,
341  const MArray<String>& value);
342  virtual MArray<Bool> hasArrayDate (const TableExprId& id,
343  const MArray<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  // Is the data type real (i.e., integer or double)?
394  Bool isReal() const;
395 
396  // Get the value type.
397  ValueType valueType() const;
398 
399  // Set the value type.
400  void setValueType (ValueType vtype);
401 
402  // Get the operator type.
403  OperType operType() const;
404 
405  // Get the expression type.
406  ExprType exprType() const;
407 
408  // Is the expression a constant?
409  Bool isConstant() const;
410 
411  // Get the unit.
412  const Unit& unit() const;
413 
414  // Set the unit.
415  // It also sets the datatype to NTDouble if it is NTInt.
416  void setUnit (const Unit& unit);
417 
418  // Get the attributes.
419  const Record& attributes() const;
420 
421  // Set the attributes.
422  void setAttributes (const Record&);
423 
424  // Get the fixed dimensionality (same for all rows).
425  Int ndim() const;
426 
427  // Get the fixed shape (same for all rows).
428  const IPosition& shape() const;
429 
430  // Get the shape for the given row.
431  // It returns the fixed shape if defined, otherwise getShape(id).
432  const IPosition& shape (const TableExprId& id);
433 
434  // Is the value in the given row defined?
435  // The default implementation returns True.
436  virtual Bool isDefined (const TableExprId& id);
437 
438  // Show the expression tree.
439  virtual void show (ostream&, uInt indent) const;
440 
441  // Get table. This gets the Table object to which a
442  // TableExprNode belongs. A TableExprNode belongs to the Table to
443  // which the first column used in an expression belongs.
444  // <group>
445  Table& table();
446  const Table& table() const;
447  // </group>
448 
449  // Replace a node with a constant expression by node with its value.
450  static TENShPtr replaceConstNode (const TENShPtr& node);
451 
452  // Let a set node convert itself to the given unit.
453  // The default implementation does nothing.
454  virtual void adaptSetUnits (const Unit&);
455 
456  // Create a range object from a column and an interval.
457  static void createRange (Block<TableExprRange>&,
458  TableExprNodeColumn*, Double start, Double end);
459 
460  // Create a empty range object.
461  static void createRange (Block<TableExprRange>&);
462 
463  // Convert a NodeDataType to a string.
464  static String typeString (NodeDataType);
465 
466  // Convert a ValueType to a string.
467  static String typeString (ValueType);
468 
469 protected:
470  Table table_p; //# Table from which node is "derived"
471  NodeDataType dtype_p; //# data type of the operation
472  ValueType vtype_p; //# value type of the result
473  OperType optype_p; //# operator type
474  ArgType argtype_p; //# argument types
475  ExprType exprtype_p; //# Constant or Variable
476  Int ndim_p; //# Fixed dimensionality of node values
477  //# -1 = variable dimensionality
478  IPosition shape_p; //# Fixed shape of node values
479  Unit unit_p; //# Unit of the values
480  Record attributes_p; //# Possible attributes (for UDFs)
481 
482  // Get the shape for the given row.
483  virtual const IPosition& getShape (const TableExprId& id);
484 
485  // If one of the children is a constant, convert its data type
486  // to that of the other operand (if appropriate).
487  // This avoids that conversions are done for each get.
488  // The default implementation does nothing.
489  virtual void convertConstChild();
490 
491  // Check if this node uses the same table pointer.
492  // Fill the Table object if it is still null.
493  // <group>
494  void checkTablePtr (const TENShPtr& node);
495  static void checkTablePtr (Table& table, const TENShPtr& node);
496  // </group>
497 
498  // Set expression type to Variable if node is Variable.
499  // <group>
500  void fillExprType (const TENShPtr& node);
501  static void fillExprType (ExprType&, const TENShPtr& node);
502  // </group>
503 
504  // If the node is constant, it is evaluated and replaced by
505  // the appropriate TableExprNodeConst object.
506  // If not constant, it calls the virtual ConvertConstChild function
507  // which can convert a constant child if appropriate.
508  static TENShPtr convertNode (const TENShPtr& thisNode,
509  Bool convertConstType);
510 
511 private:
512  // A copy of a TableExprNodeRep cannot be made.
514 };
515 
516 
517 
518 
519 
520 // <summary>
521 // Abstract base class for a node having 0, 1, or 2 child nodes.
522 // </summary>
523 
524 // <use visibility=local>
525 
526 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
527 // </reviewed>
528 
529 // <prerequisite>
530 //# Classes you should understand before using this one.
531 // <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
532 // </prerequisite>
533 
534 // <etymology>
535 // TableExprNodeBinary is a node in the table expression tree
536 // representing a binary node (i.e. having up to 2 operands).
537 // </etymology>
538 
539 // <synopsis>
540 // TableExprNodeBinary is the abstract base class for all nodes in a table
541 // expression tree using up to 2 operands.
542 // It is used as the base class for the node classes representing
543 // operator +, -, etc..
544 // </synopsis>
545 
546 // <motivation>
547 // This class contains the common functionality for the classes
548 // representing a binary (or unary) operator.
549 // </motivation>
550 
551 //# <todo asof="$DATE:$">
552 //# A List of bugs, limitations, extensions or planned refinements.
553 //# <li> to be filled in
554 //# </todo>
555 
556 
558 {
559 public:
560  // Constructor
563 
564  // Destructor
565  virtual ~TableExprNodeBinary();
566 
567  // Show the expression tree.
568  virtual void show (ostream&, uInt indent) const;
569 
570  // Get the nodes representing an aggregate function.
571  virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
572 
573  // Get the nodes representing a table column.
574  virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
575 
576  // Check the data types and get the common one.
577  static NodeDataType getDT (NodeDataType leftDtype,
578  NodeDataType rightDype,
579  OperType operType);
580 
581  // Check the data and value types and get the common one.
582  static TableExprNodeRep getCommonTypes (const TENShPtr& left,
583  const TENShPtr& right,
584  OperType operType);
585 
586  // Set the children.
587  // If needed, their properties like data type and unit are adapted.
588  void setChildren (const TENShPtr& left, const TENShPtr& right,
589  Bool adapt=True);
590 
591  // Handle the units of the children and possibly set the parent's unit.
592  // The default implementation make the units of the children equal and
593  // set the parent unit to that unit if the parent is not a Bool value.
594  virtual void handleUnits();
595 
596  // If one of the children is a constant, convert its data type
597  // to that of the other operand. This avoids that conversions are
598  // done for each get.
599  void adaptDataTypes();
600 
601  // Get the child nodes.
602  // <group>
603  const TENShPtr& getLeftChild() const
604  { return lnode_p; }
605  const TENShPtr& getRightChild() const
606  { return rnode_p; }
607  // </group>
608 
609 protected:
610  // Make the units equal.
611  // Replace the right node if needed.
612  static const Unit& makeEqualUnits (const TENShPtr& left,
613  TENShPtr& right);
614 
615  TENShPtr lnode_p; //# left operand
616  TENShPtr rnode_p; //# right operand
617 };
618 
619 
620 
621 
622 // <summary>
623 // Abstract base class for a node having multiple child nodes.
624 // </summary>
625 
626 // <use visibility=local>
627 
628 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
629 // </reviewed>
630 
631 // <prerequisite>
632 //# Classes you should understand before using this one.
633 // <li> <linkto class=TableExprNodeRep>TableExprNodeRep</linkto>
634 // </prerequisite>
635 
636 // <etymology>
637 // TableExprNodeMulti is a node in the table expression tree
638 // which can have MULTIple child nodes.
639 // </etymology>
640 
641 // <synopsis>
642 // TableExprNodeMulti is the abstract base class for all nodes in a table
643 // expression tree using multiple operands.
644 // It is used as the base class for the node classes representing
645 // functions, sets, indices, etc..
646 // </synopsis>
647 
648 // <motivation>
649 // This class contains the common functionality for the classes
650 // representing a node with multiple operands.
651 // </motivation>
652 
653 //# <todo asof="$DATE:$">
654 //# A List of bugs, limitations, extensions or planned refinements.
655 //# <li> to be filled in
656 //# </todo>
657 
658 
660 {
661 public:
662  // Constructor
664  const TableExprNodeRep& source);
665 
666  // Destructor
667  virtual ~TableExprNodeMulti();
668 
669  // Show the expression tree.
670  virtual void show (ostream&, uInt indent) const;
671 
672  // Get the nodes representing an aggregate function.
673  virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
674 
675  // Get the nodes representing a table column.
676  virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
677 
678  // Check number of arguments
679  // low <= number_of_args <= high
680  // It throws an exception if wrong number of arguments.
681  static uInt checkNumOfArg (uInt low, uInt high,
682  const std::vector<TENShPtr>& nodes);
683 
684  // Get the child nodes.
685  const std::vector<TENShPtr>& getChildren() const
686  { return operands_p; }
687 
688  // Check datatype of nodes and return output type.
689  // It also sets the expected data type of the operands (from dtIn).
690  // Conversion of Int,Double.String to Date is by default possible.
691  static NodeDataType checkDT (Block<Int>& dtypeOper,
692  NodeDataType dtIn, NodeDataType dtOut,
693  const std::vector<TENShPtr>& nodes,
694  Bool dateConv=True);
695 
696 protected:
697  std::vector<TENShPtr> operands_p;
698 };
699 
700 
701 
702 //# Get the data type of the node.
704  { return dtype_p; }
705 
707  { return dtype_p==NTInt || dtype_p==NTDouble; }
708 
709 //# Get the value type of the node.
711  { return vtype_p; }
712 
713 //# Set the value type of the node.
715  { vtype_p = vtype; }
716 
717 //# Get the operator type of the node.
719  { return optype_p; }
720 
721 //# Get the expression type of the node.
723  { return exprtype_p; }
724 
725 //# Is the expression a constant?
727  { return (exprtype_p == Constant); }
728 
729 //# Get the unit of the node.
730 inline const Unit& TableExprNodeRep::unit() const
731  { return unit_p; }
732 
734  { return attributes_p; }
735 
736 inline void TableExprNodeRep::setAttributes (const Record& attributes)
737  { attributes_p = attributes; }
738 
739 //# Get the fixed dimensionality of the node.
741  { return ndim_p; }
742 
743 //# Get the fixed shape of the node.
744 inline const IPosition& TableExprNodeRep::shape() const
745  { return shape_p; }
746 
747 //# Get the table from which the node is derived.
749  { return table_p; }
750 inline const Table& TableExprNodeRep::table() const
751  { return table_p; }
752 
753 inline void TableExprNodeRep::checkTablePtr (const TENShPtr& node)
754  { checkTablePtr (table_p, node); }
755 inline void TableExprNodeRep::fillExprType (const TENShPtr& node)
756  { fillExprType (exprtype_p, node); }
757 
758 
759 } //# NAMESPACE CASACORE - END
760 
761 #endif
void setAttributes(const Record &)
Set the attributes.
Definition: ExprNodeRep.h:736
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
CountedPtr< TableExprNodeRep > TENShPtr
Definition: ExprNodeRep.h:56
const Record & attributes() const
Get the attributes.
Definition: ExprNodeRep.h:733
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
TaqlRegex(const Regex &regex)
Construct from a regex.
Definition: ExprNodeRep.h:85
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:153
Int ndim() const
Get the fixed dimensionality (same for all rows).
Definition: ExprNodeRep.h:740
void fillExprType(const TENShPtr &node)
Set expression type to Variable if node is Variable.
Definition: ExprNodeRep.h:755
A constant subexpression which can be evaluated immediately.
Definition: ExprNodeRep.h:203
PtrHolder< T > & operator=(const PtrHolder< T > &other)
Scalar column in table select expression tree.
Definition: ExprDerNode.h:299
Bool match(const String &str) const
Does the regex or maximum string distance match?
Definition: ExprNodeRep.h:95
const std::vector< TENShPtr > & getChildren() const
Get the child nodes.
Definition: ExprNodeRep.h:685
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Definition: ExprNodeRep.h:90
NodeDataType
Define the data types of a node.
Definition: ExprNodeRep.h:161
Abstract base class for a node in a table column expression tree.
Definition: ExprNodeRep.h:157
Bool empty() const
Test for empty.
Definition: String.h:375
ValueType valueType() const
Get the value type.
Definition: ExprNodeRep.h:710
const TENShPtr & getLeftChild() const
Get the child nodes.
Definition: ExprNodeRep.h:603
void setValueType(ValueType vtype)
Set the value type.
Definition: ExprNodeRep.h:714
defines physical units
Definition: Unit.h:189
const IPosition & shape() const
Get the fixed shape (same for all rows).
Definition: ExprNodeRep.h:744
StringDistance itsDist
Definition: ExprNodeRep.h:106
ExprType
Define (sub-)expression type.
Definition: ExprNodeRep.h:201
ArgType
Define the value types of the 2 arguments when arrays are involved.
Definition: ExprNodeRep.h:196
NodeDataType dataType() const
Get the data type of the derived TableExprNode object.
Definition: ExprNodeRep.h:703
Abstract base class for a node having multiple child nodes.
Definition: ExprNodeRep.h:659
double Double
Definition: aipstype.h:55
OperType
Define the operator types.
Definition: ExprNodeRep.h:187
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:101
OperType operType() const
Get the operator type.
Definition: ExprNodeRep.h:718
const String & regexp() const
Get the regular expression string.
Definition: Regex.h:259
A hierarchical collection of named fields of various types.
Definition: Record.h:180
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:706
ValueType
Define the value types.
Definition: ExprNodeRep.h:176
const Unit & unit() const
Get the unit.
Definition: ExprNodeRep.h:730
ExprType exprType() const
Get the expression type.
Definition: ExprNodeRep.h:722
Bool match(const String &target) const
Test if the given target string is within the maximum distance.
void checkTablePtr(const TENShPtr &node)
Check if this node uses the same table pointer.
Definition: ExprNodeRep.h:753
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:2163
const TENShPtr & getRightChild() const
Definition: ExprNodeRep.h:605
std::vector< TENShPtr > operands_p
Definition: ExprNodeRep.h:697
Bool isConstant() const
Is the expression a constant?
Definition: ExprNodeRep.h:726
simple 1-D array
Definition: ArrayIO.h:47
The identification of a TaQL selection subject.
Definition: TableExprId.h:97
Table & table()
Get table.
Definition: ExprNodeRep.h:748
Class to handle a Regex or StringDistance.
Definition: ExprNodeRep.h:81
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:557
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