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