casa::TableExprNodeRep Class Reference
[Tables_internal_classes]

#include <ExprNodeRep.h>

Inheritance diagram for casa::TableExprNodeRep:

Inheritance graph
[legend]
Collaboration diagram for casa::TableExprNodeRep:

Collaboration graph
[legend]
List of all members.

Detailed Description

Abstract base class for a node in a table column expression tree.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

TableExprNodeRep is the (abstract) REPresentation of a node in a table expression tree.

Synopsis

TableExprNodeRep is the base class for all nodes in a table expression tree. It is used by the handle class TableExprNode.

The objects of this class are reference-counted to make it possible that the same object is reused.

Motivation

TableExprNodeRep and its derivations store a table select expression before actually evaluating it. It is also possible that the classes are used by the table expression parser defined in TableParse and TableGram.
For each operator a special derived class is implemented. Another approach could have been to store the operator as a flag and switch on that. However, that causes extra overhead and the C++ virtual function mechanism is designed for these purposes.

To Do

Definition at line 97 of file ExprNodeRep.h.
void checkTablePtr (const TableExprNodeRep *node)
 Check if this node uses the same table pointer.
static void checkTablePtr (Table &table, const TableExprNodeRep *node)
void fillExprType (const TableExprNodeRep *node)
 Set expression type to Variable if node is Variable.
static void fillExprType (ExprType &, const TableExprNodeRep *node)

Public Types

enum  NodeDataType
 Define the data types of a node. More...
enum  ValueType
 Define the value types. More...
enum  OperType
 Define the operator types. More...
enum  ArgType
 Define the value types of the 2 arguments when arrays are involved. More...
enum  ExprType
 Define (sub-)expression type. More...

Public Member Functions

 TableExprNodeRep (NodeDataType, ValueType, OperType, ArgType, ExprType, Int ndim, const IPosition &shape, const Table &table)
 Construct a node.
 TableExprNodeRep (NodeDataType, ValueType, OperType, const Table &)
 This constructor is called from the derived TableExprNodeRep.
 TableExprNodeRep (const TableExprNodeRep &)
 Copy constructor.
virtual ~TableExprNodeRep ()
 The destructor deletes all the underlying TableExprNode objects.
TableExprNodeReplink ()
 Link to this object, i.e.
virtual Double getUnitFactor () const
 Get the unit conversion factor.
uInt nrow () const
 Get the number of rows in the table associated with this expression.
virtual Bool getColumnDataType (DataType &) const
 Get the data type of the column.
virtual void ranges (Block< TableExprRange > &)
 Convert the tree to a number of range vectors which at least select the same things.
NodeDataType dataType () const
 Get the data type of the derived TableExprNode object.
ValueType valueType () const
 Get the value type.
void setValueType (ValueType vtype)
 Set the value type.
OperType operType () const
 Get the operator type.
ExprType exprType () const
 Get the expression type.
Bool isConstant () const
 Is the exprerssion a constant?
const Unitunit () const
 Get the unit.
void setUnit (const Unit &unit)
 Set the unit.
Int ndim () const
 Get the fixed dimensionality (same for all rows).
const IPositionshape () const
 Get the fixed shape (same for all rows).
const IPositionshape (const TableExprId &id)
 Get the shape for the given row.
virtual Bool isDefined (const TableExprId &id)
 Is the value in the given row defined? The default implementation returns True.
virtual void show (ostream &, uInt indent) const
 Show the expression tree.
virtual void replaceTablePtr (const Table &)
 Replace the Table pointer in this node and all its children.
virtual void adaptSetUnits (const Unit &)
 Let a set node convert itself to the given unit.
virtual Bool getBool (const TableExprId &id)
 Get a scalar value for this node in the given row.
virtual Double getDouble (const TableExprId &id)
virtual DComplex getDComplex (const TableExprId &id)
virtual String getString (const TableExprId &id)
virtual Regex getRegex (const TableExprId &id)
virtual MVTime getDate (const TableExprId &id)
virtual Array< BoolgetArrayBool (const TableExprId &id)
 Get an array value for this node in the given row.
virtual Array< DoublegetArrayDouble (const TableExprId &id)
virtual Array< DComplex > getArrayDComplex (const TableExprId &id)
virtual Array< StringgetArrayString (const TableExprId &id)
virtual Array< MVTimegetArrayDate (const TableExprId &id)
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.
virtual Bool hasDouble (const TableExprId &id, Double value)
virtual Bool hasDComplex (const TableExprId &id, const DComplex &value)
virtual Bool hasString (const TableExprId &id, const String &value)
virtual Bool hasDate (const TableExprId &id, const MVTime &value)
virtual Array< BoolhasArrayBool (const TableExprId &id, const Array< Bool > &value)
virtual Array< BoolhasArrayDouble (const TableExprId &id, const Array< Double > &value)
virtual Array< BoolhasArrayDComplex (const TableExprId &id, const Array< DComplex > &value)
virtual Array< BoolhasArrayString (const TableExprId &id, const Array< String > &value)
virtual Array< BoolhasArrayDate (const TableExprId &id, const Array< MVTime > &value)
virtual Array< BoolgetColumnBool ()
 Get the value of the expression evaluated for the entire column.
virtual Array< uChargetColumnuChar ()
virtual Array< ShortgetColumnShort ()
virtual Array< uShortgetColumnuShort ()
virtual Array< IntgetColumnInt ()
virtual Array< uIntgetColumnuInt ()
virtual Array< FloatgetColumnFloat ()
virtual Array< DoublegetColumnDouble ()
virtual Array< Complex > getColumnComplex ()
virtual Array< DComplex > getColumnDComplex ()
virtual Array< StringgetColumnString ()
Tabletable ()
 Get table.
const Tabletable () const

Static Public Member Functions

static void unlink (TableExprNodeRep *)
 Unlink from the given object.
static void createRange (Block< TableExprRange > &, TableExprNodeColumn *, Double start, Double end)
 Create a range object from a column and an interval.
static void createRange (Block< TableExprRange > &)
 Create a empty range object.

Protected Member Functions

virtual const IPositiongetShape (const TableExprId &id)
 Get the shape for the given row.
virtual void convertConstChild ()
 When one of the children is a constant, convert its data type to that of the other operand.

Static Protected Member Functions

static TableExprNodeRepgetRep (TableExprNode &)
 Get pointer to REPresentation object.
static TableExprNodeRepconvertNode (TableExprNodeRep *thisNode, Bool convertConstType)
 When the node is constant, it is evaluated and replaced by the appropriate TableExprNodeConst object.

Protected Attributes

uInt count_p
Table table_p
NodeDataType dtype_p
ValueType vtype_p
OperType optype_p
ArgType argtype_p
ExprType exprtype_p
Int ndim_p
IPosition shape_p
Unit unit_p

Private Member Functions

TableExprNodeRepoperator= (const TableExprNodeRep &)
 A copy of a TableExprNodeRep cannot be made.


Member Enumeration Documentation

enum casa::TableExprNodeRep::NodeDataType

Define the data types of a node.

Definition at line 101 of file ExprNodeRep.h.

enum casa::TableExprNodeRep::ValueType

Define the value types.

Definition at line 113 of file ExprNodeRep.h.

enum casa::TableExprNodeRep::OperType

Define the operator types.

LE and LT are handled as GE and GT with swapped operands.

Definition at line 124 of file ExprNodeRep.h.

enum casa::TableExprNodeRep::ArgType

Define the value types of the 2 arguments when arrays are involved.

Definition at line 132 of file ExprNodeRep.h.

enum casa::TableExprNodeRep::ExprType

Define (sub-)expression type.

Definition at line 137 of file ExprNodeRep.h.


Constructor & Destructor Documentation

casa::TableExprNodeRep::TableExprNodeRep ( NodeDataType  ,
ValueType  ,
OperType  ,
ArgType  ,
ExprType  ,
Int  ndim,
const IPosition shape,
const Table table 
)

Construct a node.

casa::TableExprNodeRep::TableExprNodeRep ( NodeDataType  ,
ValueType  ,
OperType  ,
const Table  
)

This constructor is called from the derived TableExprNodeRep.

casa::TableExprNodeRep::TableExprNodeRep ( const TableExprNodeRep  ) 

Copy constructor.

virtual casa::TableExprNodeRep::~TableExprNodeRep (  )  [virtual]

The destructor deletes all the underlying TableExprNode objects.


Member Function Documentation

TableExprNodeRep * casa::TableExprNodeRep::link (  )  [inline]

Link to this object, i.e.

increase its reference count.

Definition at line 611 of file ExprNodeRep.h.

References count_p.

static void casa::TableExprNodeRep::unlink ( TableExprNodeRep  )  [static]

Unlink from the given object.

If its reference count is zero, delete it.

virtual Double casa::TableExprNodeRep::getUnitFactor (  )  const [virtual]

Get the unit conversion factor.

Default 1 is returned.

virtual Bool casa::TableExprNodeRep::getBool ( const TableExprId id  )  [virtual]

Get a scalar value for this node in the given row.

The appropriate functions are implemented in the derived classes and will usually invoke the get in their children and apply the operator on the resulting values.

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getBool().

virtual Double casa::TableExprNodeRep::getDouble ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getDouble().

virtual DComplex casa::TableExprNodeRep::getDComplex ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getDComplex().

virtual String casa::TableExprNodeRep::getString ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getString().

virtual Regex casa::TableExprNodeRep::getRegex ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get().

virtual MVTime casa::TableExprNodeRep::getDate ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get().

virtual Array<Bool> casa::TableExprNodeRep::getArrayBool ( const TableExprId id  )  [virtual]

Get an array value for this node in the given row.

The appropriate functions are implemented in the derived classes and will usually invoke the get in their children and apply the operator on the resulting values.

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getArrayBool().

virtual Array<Double> casa::TableExprNodeRep::getArrayDouble ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getArrayDouble().

virtual Array<DComplex> casa::TableExprNodeRep::getArrayDComplex ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getArrayDComplex().

virtual Array<String> casa::TableExprNodeRep::getArrayString ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get(), and casa::TableExprNode::getArrayString().

virtual Array<MVTime> casa::TableExprNodeRep::getArrayDate ( const TableExprId id  )  [virtual]

Referenced by casa::TableExprNode::get().

virtual Bool casa::TableExprNodeRep::hasBool ( const TableExprId id,
Bool  value 
) [virtual]

Does a value occur in an array or set? The default implementation tests if it is in an array.

virtual Bool casa::TableExprNodeRep::hasDouble ( const TableExprId id,
Double  value 
) [virtual]

virtual Bool casa::TableExprNodeRep::hasDComplex ( const TableExprId id,
const DComplex &  value 
) [virtual]

virtual Bool casa::TableExprNodeRep::hasString ( const TableExprId id,
const String value 
) [virtual]

virtual Bool casa::TableExprNodeRep::hasDate ( const TableExprId id,
const MVTime value 
) [virtual]

virtual Array<Bool> casa::TableExprNodeRep::hasArrayBool ( const TableExprId id,
const Array< Bool > &  value 
) [virtual]

virtual Array<Bool> casa::TableExprNodeRep::hasArrayDouble ( const TableExprId id,
const Array< Double > &  value 
) [virtual]

virtual Array<Bool> casa::TableExprNodeRep::hasArrayDComplex ( const TableExprId id,
const Array< DComplex > &  value 
) [virtual]

virtual Array<Bool> casa::TableExprNodeRep::hasArrayString ( const TableExprId id,
const Array< String > &  value 
) [virtual]

virtual Array<Bool> casa::TableExprNodeRep::hasArrayDate ( const TableExprId id,
const Array< MVTime > &  value 
) [virtual]

uInt casa::TableExprNodeRep::nrow (  )  const

Get the number of rows in the table associated with this expression.

One is returned if the expression is a constant. Zero is returned if no table is associated with it.

Referenced by casa::TableExprNode::nrow().

virtual Bool casa::TableExprNodeRep::getColumnDataType ( DataType &   )  const [virtual]

Get the data type of the column.

It returns True when it could set the data type (which it can if the expression is a scalar column or a constant array column pixel). Otherwise it returns False.

virtual Array<Bool> casa::TableExprNodeRep::getColumnBool (  )  [virtual]

Get the value of the expression evaluated for the entire column.

The data of function called should match the data type as returned by function getColumnDataType.

Referenced by casa::TableExprNode::getColumnBool().

virtual Array<uChar> casa::TableExprNodeRep::getColumnuChar (  )  [virtual]

Referenced by casa::TableExprNode::getColumnuChar().

virtual Array<Short> casa::TableExprNodeRep::getColumnShort (  )  [virtual]

Referenced by casa::TableExprNode::getColumnShort().

virtual Array<uShort> casa::TableExprNodeRep::getColumnuShort (  )  [virtual]

Referenced by casa::TableExprNode::getColumnuShort().

virtual Array<Int> casa::TableExprNodeRep::getColumnInt (  )  [virtual]

Referenced by casa::TableExprNode::getColumnInt().

virtual Array<uInt> casa::TableExprNodeRep::getColumnuInt (  )  [virtual]

Referenced by casa::TableExprNode::getColumnuInt().

virtual Array<Float> casa::TableExprNodeRep::getColumnFloat (  )  [virtual]

Referenced by casa::TableExprNode::getColumnFloat().

virtual Array<Double> casa::TableExprNodeRep::getColumnDouble (  )  [virtual]

Referenced by casa::TableExprNode::getColumnDouble().

virtual Array<Complex> casa::TableExprNodeRep::getColumnComplex (  )  [virtual]

Referenced by casa::TableExprNode::getColumnComplex().

virtual Array<DComplex> casa::TableExprNodeRep::getColumnDComplex (  )  [virtual]

Referenced by casa::TableExprNode::getColumnDComplex().

virtual Array<String> casa::TableExprNodeRep::getColumnString (  )  [virtual]

Referenced by casa::TableExprNode::getColumnString().

virtual void casa::TableExprNodeRep::ranges ( Block< TableExprRange > &   )  [virtual]

Convert the tree to a number of range vectors which at least select the same things.

This function is very useful to convert the expression to some intervals covering the select expression. This can be used to do a rough fast selection via an index and do the the slower final selection on that much smaller subset. The function can only convert direct comparisons of columns with constants (via ==, !=, >, >=, < or <=) and their combinations using && or ||.

Referenced by casa::TableExprNode::ranges().

TableExprNodeRep::NodeDataType casa::TableExprNodeRep::dataType (  )  const [inline]

Get the data type of the derived TableExprNode object.

This is the data type of the resulting value. E.g. a compare of 2 numeric values results in a Bool, thus the data type of, say, TableExprNodeEQ<T> is always Bool. Function getInternalDT gives the internal data type, thus in the example above the data type of T.

Definition at line 560 of file ExprNodeRep.h.

References dtype_p.

TableExprNodeRep::ValueType casa::TableExprNodeRep::valueType (  )  const [inline]

Get the value type.

Definition at line 564 of file ExprNodeRep.h.

References vtype_p.

Referenced by casa::TableExprNode::isScalar().

void casa::TableExprNodeRep::setValueType ( ValueType  vtype  )  [inline]

Set the value type.

Definition at line 568 of file ExprNodeRep.h.

References vtype_p.

TableExprNodeRep::OperType casa::TableExprNodeRep::operType (  )  const [inline]

Get the operator type.

Definition at line 572 of file ExprNodeRep.h.

References optype_p.

TableExprNodeRep::ExprType casa::TableExprNodeRep::exprType (  )  const [inline]

Get the expression type.

Definition at line 576 of file ExprNodeRep.h.

References exprtype_p.

Bool casa::TableExprNodeRep::isConstant (  )  const [inline]

Is the exprerssion a constant?

Definition at line 580 of file ExprNodeRep.h.

References Constant, and exprtype_p.

Referenced by casa::TableExprNodeIndex::getSlicer().

const Unit & casa::TableExprNodeRep::unit (  )  const [inline]

Get the unit.

Definition at line 584 of file ExprNodeRep.h.

References unit_p.

Referenced by setUnit(), and casa::TableExprNode::unit().

void casa::TableExprNodeRep::setUnit ( const Unit unit  )  [inline]

Set the unit.

Definition at line 588 of file ExprNodeRep.h.

References unit(), and unit_p.

Int casa::TableExprNodeRep::ndim (  )  const [inline]

Get the fixed dimensionality (same for all rows).

Definition at line 592 of file ExprNodeRep.h.

References ndim_p.

const IPosition & casa::TableExprNodeRep::shape (  )  const [inline]

Get the fixed shape (same for all rows).

Definition at line 596 of file ExprNodeRep.h.

References shape_p.

const IPosition& casa::TableExprNodeRep::shape ( const TableExprId id  ) 

Get the shape for the given row.

It returns the fixed shape if defined, otherwise getShape(id).

virtual Bool casa::TableExprNodeRep::isDefined ( const TableExprId id  )  [virtual]

Is the value in the given row defined? The default implementation returns True.

virtual void casa::TableExprNodeRep::show ( ostream &  ,
uInt  indent 
) const [virtual]

Show the expression tree.

Referenced by casa::TableExprNode::show().

Table & casa::TableExprNodeRep::table (  )  [inline]

Get table.

This gets the Table object to which a TableExprNode belongs. A TableExprNode belongs to the Table to which the column(s) used in an expression belong. Note that all columns in an expression have to belong to the same table.

Definition at line 600 of file ExprNodeRep.h.

References table_p.

Referenced by casa::TableExprNode::table().

const Table & casa::TableExprNodeRep::table (  )  const [inline]

Definition at line 602 of file ExprNodeRep.h.

References table_p.

virtual void casa::TableExprNodeRep::replaceTablePtr ( const Table  )  [virtual]

Replace the Table pointer in this node and all its children.

virtual void casa::TableExprNodeRep::adaptSetUnits ( const Unit  )  [virtual]

Let a set node convert itself to the given unit.

The default implementation does nothing.

static void casa::TableExprNodeRep::createRange ( Block< TableExprRange > &  ,
TableExprNodeColumn ,
Double  start,
Double  end 
) [static]

Create a range object from a column and an interval.

static void casa::TableExprNodeRep::createRange ( Block< TableExprRange > &   )  [static]

Create a empty range object.

virtual const IPosition& casa::TableExprNodeRep::getShape ( const TableExprId id  )  [protected, virtual]

Get the shape for the given row.

static TableExprNodeRep* casa::TableExprNodeRep::getRep ( TableExprNode  )  [static, protected]

Get pointer to REPresentation object.

This is used by derived classes.

virtual void casa::TableExprNodeRep::convertConstChild (  )  [protected, virtual]

When one of the children is a constant, convert its data type to that of the other operand.

This avoids that conversions are done for each get. The default implementation does nothing.

void casa::TableExprNodeRep::checkTablePtr ( const TableExprNodeRep node  )  [inline, protected]

Check if this node uses the same table pointer.

Fill the Table object if it is still null.

Definition at line 605 of file ExprNodeRep.h.

References table_p.

static void casa::TableExprNodeRep::checkTablePtr ( Table table,
const TableExprNodeRep node 
) [static, protected]

void casa::TableExprNodeRep::fillExprType ( const TableExprNodeRep node  )  [inline, protected]

Set expression type to Variable if node is Variable.

Definition at line 607 of file ExprNodeRep.h.

References exprtype_p.

static void casa::TableExprNodeRep::fillExprType ( ExprType ,
const TableExprNodeRep node 
) [static, protected]

static TableExprNodeRep* casa::TableExprNodeRep::convertNode ( TableExprNodeRep thisNode,
Bool  convertConstType 
) [static, protected]

When the node is constant, it is evaluated and replaced by the appropriate TableExprNodeConst object.

If not constant, it calls the virtual ConvertConstChild function which can convert a constant child when appropriate.

TableExprNodeRep& casa::TableExprNodeRep::operator= ( const TableExprNodeRep  )  [private]

A copy of a TableExprNodeRep cannot be made.


Member Data Documentation

uInt casa::TableExprNodeRep::count_p [protected]

Definition at line 327 of file ExprNodeRep.h.

Referenced by link().

Table casa::TableExprNodeRep::table_p [protected]

Definition at line 328 of file ExprNodeRep.h.

Referenced by checkTablePtr(), and table().

NodeDataType casa::TableExprNodeRep::dtype_p [protected]

Definition at line 329 of file ExprNodeRep.h.

Referenced by dataType().

ValueType casa::TableExprNodeRep::vtype_p [protected]

Definition at line 330 of file ExprNodeRep.h.

Referenced by setValueType(), and valueType().

OperType casa::TableExprNodeRep::optype_p [protected]

Definition at line 331 of file ExprNodeRep.h.

Referenced by operType().

ArgType casa::TableExprNodeRep::argtype_p [protected]

Definition at line 332 of file ExprNodeRep.h.

ExprType casa::TableExprNodeRep::exprtype_p [protected]

Definition at line 333 of file ExprNodeRep.h.

Referenced by exprType(), fillExprType(), and isConstant().

Int casa::TableExprNodeRep::ndim_p [protected]

Definition at line 334 of file ExprNodeRep.h.

Referenced by ndim().

IPosition casa::TableExprNodeRep::shape_p [protected]

Definition at line 336 of file ExprNodeRep.h.

Referenced by shape().

Unit casa::TableExprNodeRep::unit_p [protected]

Definition at line 337 of file ExprNodeRep.h.

Referenced by setUnit(), and unit().


The documentation for this class was generated from the following file:
Generated on Mon Sep 1 22:45:29 2008 for NRAOCASA by  doxygen 1.5.1