Go to the documentation of this file.
28 #ifndef TABLES_EXPRNODEREP_H
29 #define TABLES_EXPRNODEREP_H
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>
51 class TableExprNodeColumn;
52 class TableExprGroupFuncBase;
53 template<
class T>
class Block;
242 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
245 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
440 virtual void show (ostream&,
uInt indent)
const;
510 Bool convertConstType);
569 virtual void show (ostream&,
uInt indent)
const;
572 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
575 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
671 virtual void show (ostream&,
uInt indent)
const;
674 virtual void getAggrNodes (std::vector<TableExprNodeRep*>& aggr);
677 virtual void getColumnNodes (std::vector<TableExprNodeRep*>& cols);
683 const std::vector<TENShPtr>& nodes);
694 const std::vector<TENShPtr>& nodes,
virtual Array< Double > getColumnDouble(const Vector< uInt > &rownrs)
void setValueType(ValueType vtype)
Set the value type.
virtual MArray< Bool > hasArrayInt(const TableExprId &id, const MArray< Int64 > &value)
ArgType
Define the value types of the 2 arguments when arrays are involved.
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
Int ndim() const
Get the fixed dimensionality (same for all rows).
void get(const TableExprId &id, MArray< String > &value)
static String typeString(NodeDataType)
Convert a NodeDataType to a string.
virtual Bool isLazyAggregate() const
Is the aggregate function a lazy or an immediate one? The default implementation returns True (becaus...
TableExprNodeBinary(NodeDataType, ValueType, OperType, const Table &)
Constructor.
static uInt checkNumOfArg(uInt low, uInt high, const std::vector< TENShPtr > &nodes)
Check number of arguments low <= number_of_args <= high It throws an exception if wrong number of arg...
virtual MArray< Bool > hasArrayDate(const TableExprId &id, const MArray< MVTime > &value)
A Vector of integers, for indexing into Array<T> objects.
const TENShPtr & getLeftChild() const
Get the child nodes.
std::vector< TENShPtr > operands_p
ValueType
Define the value types.
CountedPtr< TableExprNodeRep > TENShPtr
virtual Bool hasDComplex(const TableExprId &id, const DComplex &value)
Bool isReal() const
Is the data type real (i.e., integer or double)?
virtual Array< uShort > getColumnuShort(const Vector< uInt > &rownrs)
TaqlRegex(const StringDistance &dist)
Construct from a StringDistance.
Bool empty() const
Test for empty.
virtual Bool getBool(const TableExprId &id)
Get a scalar value for this node in the given row.
uInt nrow() const
Get the number of rows in the table associated with this expression.
void get(const TableExprId &id, MVTime &value)
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
OperType operType() const
Get the operator type.
static TENShPtr replaceConstNode(const TENShPtr &node)
Replace a node with a constant expression by node with its value.
Table & table()
Get table.
virtual Array< DComplex > getColumnDComplex(const Vector< uInt > &rownrs)
std::complex< Double > DComplex
Class to handle date/time type conversions and I/O.
void setAttributes(const Record &)
Set the attributes.
virtual void convertConstChild()
If one of the children is a constant, convert its data type to that of the other operand (if appropri...
A constant subexpression which can be evaluated immediately.
ExprType
Define (sub-)expression type.
virtual CountedPtr< TableExprGroupFuncBase > makeGroupAggrFunc()
Create the correct immediate aggregate function object.
ValueType valueType() const
Get the value type.
void setChildren(const TENShPtr &left, const TENShPtr &right, Bool adapt=True)
Set the children.
NodeDataType dataType() const
Get the data type of the derived TableExprNode object.
virtual MArray< Bool > hasArrayString(const TableExprId &id, const MArray< String > &value)
MArray< Double > getDoubleAS(const TableExprId &id)
static TENShPtr convertNode(const TENShPtr &thisNode, Bool convertConstType)
If the node is constant, it is evaluated and replaced by the appropriate TableExprNodeConst object.
virtual Bool hasDate(const TableExprId &id, const MVTime &value)
virtual DComplex getDComplex(const TableExprId &id)
virtual Array< Int > getColumnInt(const Vector< uInt > &rownrs)
virtual Bool getColumnDataType(DataType &) const
Get the data type of the column.
virtual void disableApplySelection()
Do not apply the selection.
void get(const TableExprId &id, Bool &value)
General get functions for template purposes.
MArray< Bool > getBoolAS(const TableExprId &id)
Get a value as an array, even it it is a scalar.
const Unit & unit() const
Get the unit.
virtual Array< Short > getColumnShort(const Vector< uInt > &rownrs)
virtual ~TableExprNodeRep()
The destructor deletes all the underlying TableExprNode objects.
virtual Array< String > getColumnString(const Vector< uInt > &rownrs)
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
virtual Bool hasBool(const TableExprId &id, Bool value)
Does a value occur in an array or set? The default implementation tests if it is in an array.
MArray< DComplex > getDComplexAS(const TableExprId &id)
virtual void handleUnits()
Handle the units of the children and possibly set the parent's unit.
OperType
Define the operator types.
virtual MArray< MVTime > getArrayDate(const TableExprId &id)
Bool isConstant() const
Is the expression a constant?
virtual MVTime getDate(const TableExprId &id)
virtual void show(ostream &, uInt indent) const
Show the expression tree.
virtual Bool hasDouble(const TableExprId &id, Double value)
void get(const TableExprId &id, String &value)
const TENShPtr & getRightChild() const
virtual const IPosition & getShape(const TableExprId &id)
Get the shape for the given row.
void get(const TableExprId &id, MArray< DComplex > &value)
virtual Array< uInt > getColumnuInt(const Vector< uInt > &rownrs)
void checkTablePtr(const TENShPtr &node)
Check if this node uses the same table pointer.
virtual Array< uChar > getColumnuChar(const Vector< uInt > &rownrs)
void adaptDataTypes()
If one of the children is a constant, convert its data type to that of the other operand.
Main interface class to a read/write table.
virtual MArray< Bool > hasArrayDouble(const TableExprId &id, const MArray< Double > &value)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual Array< Complex > getColumnComplex(const Vector< uInt > &rownrs)
virtual Double getUnitFactor() const
Get the unit conversion factor.
virtual void ranges(Block< TableExprRange > &)
Convert the tree to a number of range vectors which at least select the same things.
TaqlRegex(const Regex ®ex)
Construct from a regex.
void checkAggrFuncs()
Throw an exception if an aggregate function is used in the expression node or its children.
virtual void show(ostream &, uInt indent) const
Show the expression tree.
static void createRange(Block< TableExprRange > &, TableExprNodeColumn *, Double start, Double end)
Create a range object from a column and an interval.
void setUnit(const Unit &unit)
Set the unit.
virtual Array< Int64 > getColumnInt64(const Vector< uInt > &rownrs)
const IPosition & shape() const
Get the fixed shape (same for all rows).
virtual MArray< Double > getArrayDouble(const TableExprId &id)
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
virtual void getColumnNodes(std::vector< TableExprNodeRep * > &cols)
Get the nodes representing a table column.
void get(const TableExprId &id, MArray< Bool > &value)
this file contains all the compiler specific defines
static NodeDataType getDT(NodeDataType leftDtype, NodeDataType rightDype, OperType operType)
Check the data types and get the common one.
const std::vector< TENShPtr > & getChildren() const
Get the child nodes.
void get(const TableExprId &id, DComplex &value)
const Regex & regex() const
Return the regular expression.
MArray< Int64 > getIntAS(const TableExprId &id)
The identification of a TaQL selection subject.
virtual void getAggrNodes(std::vector< TableExprNodeRep * > &aggr)
Get the nodes representing an aggregate function.
void get(const TableExprId &id, Int64 &value)
virtual MArray< Bool > hasArrayBool(const TableExprId &id, const MArray< Bool > &value)
void get(const TableExprId &id, MArray< Double > &value)
MArray< MVTime > getDateAS(const TableExprId &id)
TableExprNodeRep(NodeDataType, ValueType, OperType, ArgType, ExprType, Int ndim, const IPosition &shape, const Table &table)
Construct a node.
virtual ~TableExprNodeBinary()
Destructor.
virtual ~TableExprNodeMulti()
Destructor.
TableExprNodeRep & operator=(const TableExprNodeRep &)
A copy of a TableExprNodeRep cannot be made.
NodeDataType
Define the data types of a node.
const String & regexp() const
Get the regular expression string.
virtual Bool hasString(const TableExprId &id, const String &value)
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
void fillExprType(const TENShPtr &node)
Set expression type to Variable if node is Variable.
Bool match(const String &target) const
Test if the given target string is within the maximum distance.
const Record & attributes() const
Get the attributes.
virtual Bool isDefined(const TableExprId &id)
Is the value in the given row defined? The default implementation returns True.
Abstract base class for a node in a table column expression tree.
static const Unit & makeEqualUnits(const TENShPtr &left, TENShPtr &right)
Make the units equal.
String: the storage and methods of handling collections of characters.
void get(const TableExprId &id, MArray< MVTime > &value)
ExprType exprType() const
Get the expression type.
bool Bool
Define the standard types used by Casacore.
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
TableExprNodeMulti(NodeDataType, ValueType, OperType, const TableExprNodeRep &source)
Constructor.
Regular expression class.
Bool match(const String &str) const
Does the regex or maximum string distance match?
A hierarchical collection of named fields of various types.
virtual void show(ostream &, uInt indent) const
Show the expression tree.
Abstract base class for a node having 0, 1, or 2 child nodes.
static TableExprNodeRep getCommonTypes(const TENShPtr &left, const TENShPtr &right, OperType operType)
Check the data and value types and get the common one.
MArray< String > getStringAS(const TableExprId &id)
virtual MArray< Bool > hasArrayDComplex(const TableExprId &id, const MArray< DComplex > &value)
virtual Array< Float > getColumnFloat(const Vector< uInt > &rownrs)
Scalar column in table select expression tree.
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
virtual Array< Bool > getColumnBool(const Vector< uInt > &rownrs)
Get the value of the expression evaluated for the entire column.
Bool matches(const string &str, Int pos=0) const
Matches entire string from pos (or till pos if negative pos).
virtual void applySelection(const Vector< uInt > &rownrs)
Re-create the column object for a selection of rows.
virtual void adaptSetUnits(const Unit &)
Let a set node convert itself to the given unit.
Abstract base class for a node having multiple child nodes.
void get(const TableExprId &id, MArray< Int64 > &value)
Class to handle a Regex or StringDistance.
virtual String getString(const TableExprId &id)
virtual Bool hasInt(const TableExprId &id, Int64 value)
virtual Double getDouble(const TableExprId &id)
virtual Int64 getInt(const TableExprId &id)
static NodeDataType checkDT(Block< Int > &dtypeOper, NodeDataType dtIn, NodeDataType dtOut, const std::vector< TENShPtr > &nodes, Bool dateConv=True)
Check datatype of nodes and return output type.
virtual MArray< String > getArrayString(const TableExprId &id)
Class to deal with Levensthein distance of strings.
virtual TaqlRegex getRegex(const TableExprId &id)
void get(const TableExprId &id, Double &value)
virtual MArray< Bool > getArrayBool(const TableExprId &id)
Get an array value for this node in the given row.