casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
casa::TableExprFuncNode Class Reference

Class representing a function in table select expression. More...

#include <ExprFuncNode.h>

Inheritance diagram for casa::TableExprFuncNode:
casa::TableExprNodeMulti casa::TableExprNodeRep casa::TableExprConeNode

List of all members.

Public Types

enum  FunctionType {
  piFUNC,
  eFUNC,
  cFUNC,
  near2FUNC,
  near3FUNC,
  nearabs2FUNC,
  nearabs3FUNC,
  sinFUNC,
  sinhFUNC,
  cosFUNC,
  coshFUNC,
  expFUNC,
  logFUNC,
  log10FUNC,
  sqrtFUNC,
  powFUNC,
  conjFUNC,
  squareFUNC,
  cubeFUNC,
  minFUNC,
  maxFUNC,
  normFUNC,
  absFUNC,
  argFUNC,
  realFUNC,
  imagFUNC,
  intFUNC,
  asinFUNC,
  acosFUNC,
  atanFUNC,
  atan2FUNC,
  tanFUNC,
  tanhFUNC,
  signFUNC,
  roundFUNC,
  floorFUNC,
  ceilFUNC,
  fmodFUNC,
  complexFUNC,
  arrsumFUNC,
  arrsumsFUNC,
  arrproductFUNC,
  arrproductsFUNC,
  arrsumsqrFUNC,
  arrsumsqrsFUNC,
  arrminFUNC,
  arrminsFUNC,
  runminFUNC,
  boxminFUNC,
  arrmaxFUNC,
  arrmaxsFUNC,
  runmaxFUNC,
  boxmaxFUNC,
  arrmeanFUNC,
  arrmeansFUNC,
  runmeanFUNC,
  boxmeanFUNC,
  arrvarianceFUNC,
  arrvariancesFUNC,
  runvarianceFUNC,
  boxvarianceFUNC,
  arrstddevFUNC,
  arrstddevsFUNC,
  runstddevFUNC,
  boxstddevFUNC,
  arravdevFUNC,
  arravdevsFUNC,
  runavdevFUNC,
  boxavdevFUNC,
  arrrmsFUNC,
  arrrmssFUNC,
  runrmsFUNC,
  boxrmsFUNC,
  arrmedianFUNC,
  arrmediansFUNC,
  runmedianFUNC,
  boxmedianFUNC,
  arrfractileFUNC,
  arrfractilesFUNC,
  anyFUNC,
  anysFUNC,
  runanyFUNC,
  boxanyFUNC,
  allFUNC,
  allsFUNC,
  runallFUNC,
  boxallFUNC,
  ntrueFUNC,
  ntruesFUNC,
  gnfalseFUNC,
  nfalseFUNC,
  nfalsesFUNC,
  arrayFUNC,
  transposeFUNC,
  isnanFUNC,
  isinfFUNC,
  isfiniteFUNC,
  isdefFUNC,
  ndimFUNC,
  nelemFUNC,
  shapeFUNC,
  strlengthFUNC,
  upcaseFUNC,
  downcaseFUNC,
  trimFUNC,
  ltrimFUNC,
  rtrimFUNC,
  substrFUNC,
  replaceFUNC,
  regexFUNC,
  patternFUNC,
  sqlpatternFUNC,
  datetimeFUNC,
  mjdtodateFUNC,
  mjdFUNC,
  dateFUNC,
  timeFUNC,
  yearFUNC,
  monthFUNC,
  dayFUNC,
  cmonthFUNC,
  weekdayFUNC,
  cdowFUNC,
  weekFUNC,
  ctodFUNC,
  cdateFUNC,
  ctimeFUNC,
  hmsFUNC,
  dmsFUNC,
  hdmsFUNC,
  randFUNC,
  rownrFUNC,
  rowidFUNC,
  iifFUNC,
  angdistFUNC,
  angdistxFUNC,
  conesFUNC,
  cones3FUNC,
  anyconeFUNC,
  anycone3FUNC,
  findconeFUNC,
  findcone3FUNC,
  NRFUNC
}

Public Member Functions

 TableExprFuncNode (FunctionType, NodeDataType, ValueType, const TableExprNodeSet &source)
 Constructor.
 ~TableExprFuncNode ()
 Destructor.
virtual Bool isSingleValue () const
 Does the node result in a single value (for e.g.
Bool getBool (const TableExprId &id)
 'get' Functions to get the desired result of a function
Int64 getInt (const TableExprId &id)
Double getDouble (const TableExprId &id)
DComplex getDComplex (const TableExprId &id)
String getString (const TableExprId &id)
TaqlRegex getRegex (const TableExprId &id)
MVTime getDate (const TableExprId &id)
void setScale (Double scale)
 Set unit scale factor (needed for sqrt).
Double getScale () const
 Get possible unit scale factor (needed for sqrt).
const PtrBlock
< TableExprNodeRep * > & 
operands () const
 Some functions to be used by TableExprNodeFuncArray.
PtrBlock< TableExprNodeRep * > & rwOperands ()
FunctionType funcType () const
NodeDataType argDataType () const

Static Public Member Functions

static NodeDataType checkOperands (Block< Int > &dtypeOper, ValueType &resVT, Block< Int > &vtypeOper, FunctionType, PtrBlock< TableExprNodeRep * > &)
 Check the data and value types of the operands.
static Double fillUnits (TableExprNodeRep *node, PtrBlock< TableExprNodeRep * > &nodes, FunctionType func)
 Fill the result unit in the node.
static TableExprNodeRepfillNode (TableExprFuncNode *thisNode, PtrBlock< TableExprNodeRep * > &nodes, const Block< Int > &dtypeOper)
 Link the children to the node and convert the children to constants if possible.
static void fillChildNodes (TableExprFuncNode *thisNode, PtrBlock< TableExprNodeRep * > &nodes, const Block< Int > &dtypeOper)
 Link the children to the node and convert the children to constants if possible.
static String stringDT (const MVTime &dt, Int prec, MVTime::formatTypes)
 Convert the date and/or time to a string.
static String stringDateTime (const MVTime &dt, Int prec)
static String stringDate (const MVTime &dt)
static String stringTime (const MVTime &dt, Int prec)
static String stringAngle (double val, Int prec, MVAngle::formatTypes type)
 Convert angle to a string (hms or dms).
static String stringHMS (double val, Int prec)
static String stringDMS (double val, Int prec)
static double angdist (double ra1, double dec1, double ra2, double dec2)
 Get the angular distance between two positions on a sphere.

Private Member Functions

void tryToConst ()
 Try if the function gives a constant result.

Static Private Member Functions

static const UnitmakeEqualUnits (PtrBlock< TableExprNodeRep * > &nodes, uInt starg, uInt endarg)
 Make the units of nodes from starg till endarg equal.

Private Attributes

FunctionType funcType_p
NodeDataType argDataType_p
Double scale_p

Detailed Description

Class representing a function in table select expression.

Intended use:

Internal

Review Status

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

Prerequisite

Synopsis

This class represents a function in a table select tree. The rownumber function is represented by class TableExprNodeRownr . The rowid function is represented by class TableExprNodeRowid . The rand function is represented by class TableExprNodeRandom .

When one wants to add a function to the table selection grammar, the following has to be done:

Definition at line 75 of file ExprFuncNode.h.


Member Enumeration Documentation

Enumerator:
piFUNC 
eFUNC 
cFUNC 
near2FUNC 

for Int, or Double or Complex returning Bool (2 is with default tolerance)

near3FUNC 
nearabs2FUNC 
nearabs3FUNC 
sinFUNC 

for Int, Double or DComplex returning Double or Complex

sinhFUNC 
cosFUNC 
coshFUNC 
expFUNC 
logFUNC 
log10FUNC 
sqrtFUNC 
powFUNC 
conjFUNC 
squareFUNC 

for Int, Double or DComplex returning Int, Double or Complex

cubeFUNC 
minFUNC 
maxFUNC 
normFUNC 

for Int, Double or DComplex returning Int or Double

absFUNC 
argFUNC 
realFUNC 

for Int, Double or DComplex returning Double

imagFUNC 
intFUNC 

for Int or Double returning Int (using floor)

asinFUNC 

for Int or Double returning Double

acosFUNC 
atanFUNC 
atan2FUNC 
tanFUNC 
tanhFUNC 
signFUNC 

for Int or Double returning Int or Double

roundFUNC 
floorFUNC 
ceilFUNC 
fmodFUNC 
complexFUNC 

for Int, Double or DComplex returning DComplex

arrsumFUNC 

for Int, Double or Complex array returning the same

arrsumsFUNC 
arrproductFUNC 
arrproductsFUNC 
arrsumsqrFUNC 
arrsumsqrsFUNC 
arrminFUNC 

for Int or Double array returning Int or Double

arrminsFUNC 
runminFUNC 
boxminFUNC 
arrmaxFUNC 
arrmaxsFUNC 
runmaxFUNC 
boxmaxFUNC 
arrmeanFUNC 

for Int or Double array returning Double

arrmeansFUNC 
runmeanFUNC 
boxmeanFUNC 
arrvarianceFUNC 
arrvariancesFUNC 
runvarianceFUNC 
boxvarianceFUNC 
arrstddevFUNC 
arrstddevsFUNC 
runstddevFUNC 
boxstddevFUNC 
arravdevFUNC 
arravdevsFUNC 
runavdevFUNC 
boxavdevFUNC 
arrrmsFUNC 
arrrmssFUNC 
runrmsFUNC 
boxrmsFUNC 
arrmedianFUNC 
arrmediansFUNC 
runmedianFUNC 
boxmedianFUNC 
arrfractileFUNC 
arrfractilesFUNC 
anyFUNC 

for Bool array returning Bool

anysFUNC 
runanyFUNC 
boxanyFUNC 
allFUNC 
allsFUNC 
runallFUNC 
boxallFUNC 
ntrueFUNC 

for Bool array returning Int scalar

ntruesFUNC 
gnfalseFUNC 
nfalseFUNC 
nfalsesFUNC 
arrayFUNC 

for any type returning array of that type

transposeFUNC 
isnanFUNC 

for Int, Double or DComplex array returning Bool

isinfFUNC 
isfiniteFUNC 
isdefFUNC 

for any array returning Bool scalar

ndimFUNC 

for any array returning Int scalar

nelemFUNC 
shapeFUNC 

for any array returning Int array

strlengthFUNC 

for String

upcaseFUNC 
downcaseFUNC 
trimFUNC 
ltrimFUNC 
rtrimFUNC 
substrFUNC 
replaceFUNC 
regexFUNC 
patternFUNC 
sqlpatternFUNC 
datetimeFUNC 

for Date

mjdtodateFUNC 
mjdFUNC 
dateFUNC 
timeFUNC 
yearFUNC 
monthFUNC 
dayFUNC 
cmonthFUNC 
weekdayFUNC 
cdowFUNC 
weekFUNC 
ctodFUNC 
cdateFUNC 
ctimeFUNC 
hmsFUNC 

return angles as hms strings

dmsFUNC 

return angles as dms strings

hdmsFUNC 

return angles as hms/dms strings

randFUNC 

special function returning a random Double number

rownrFUNC 

special function returning Int row number

rowidFUNC 

special function returning Int row id (meant for GIVING)

iifFUNC 

special function resembling if statement

angdistFUNC 

angular distance returning radians

angdistxFUNC 
conesFUNC 

other functions, implemented in derived class

cones3FUNC 
anyconeFUNC 
anycone3FUNC 
findconeFUNC 
findcone3FUNC 
NRFUNC 

Definition at line 79 of file ExprFuncNode.h.


Constructor & Destructor Documentation

Constructor.

Destructor.


Member Function Documentation

static double casa::TableExprFuncNode::angdist ( double  ra1,
double  dec1,
double  ra2,
double  dec2 
) [inline, static]

Get the angular distance between two positions on a sphere.

Definition at line 345 of file ExprFuncNode.h.

References casa::acos(), casa::cos(), and casa::sin().

Definition at line 324 of file ExprFuncNode.h.

References argDataType_p.

Referenced by casa::TableExprFuncNodeArray::argDataType().

static NodeDataType casa::TableExprFuncNode::checkOperands ( Block< Int > &  dtypeOper,
ValueType resVT,
Block< Int > &  vtypeOper,
FunctionType  ,
PtrBlock< TableExprNodeRep * > &   
) [static]

Check the data and value types of the operands.

It sets the exptected data and value types of the operands. Set the value type of the function result and returns the data type of the function result.

Reimplemented in casa::TableExprConeNode.

static void casa::TableExprFuncNode::fillChildNodes ( TableExprFuncNode thisNode,
PtrBlock< TableExprNodeRep * > &  nodes,
const Block< Int > &  dtypeOper 
) [static]

Link the children to the node and convert the children to constants if possible.

static TableExprNodeRep* casa::TableExprFuncNode::fillNode ( TableExprFuncNode thisNode,
PtrBlock< TableExprNodeRep * > &  nodes,
const Block< Int > &  dtypeOper 
) [static]

Link the children to the node and convert the children to constants if possible.

Also convert the node to constant if possible.

static Double casa::TableExprFuncNode::fillUnits ( TableExprNodeRep node,
PtrBlock< TableExprNodeRep * > &  nodes,
FunctionType  func 
) [static]

Fill the result unit in the node.

Adapt the children nodes if their units need to be converted. It returns a possible scale factor in case result unit is SI (for sqrt).

Definition at line 322 of file ExprFuncNode.h.

References funcType_p.

Referenced by casa::TableExprFuncNodeArray::funcType().

'get' Functions to get the desired result of a function

Reimplemented from casa::TableExprNodeRep.

Reimplemented in casa::TableExprConeNode.

Reimplemented from casa::TableExprNodeRep.

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

Reimplemented from casa::TableExprNodeRep.

Reimplemented from casa::TableExprNodeRep.

Reimplemented from casa::TableExprNodeRep.

Reimplemented in casa::TableExprConeNode.

Reimplemented from casa::TableExprNodeRep.

Get possible unit scale factor (needed for sqrt).

Definition at line 313 of file ExprFuncNode.h.

References scale_p.

Reimplemented from casa::TableExprNodeRep.

virtual Bool casa::TableExprFuncNode::isSingleValue ( ) const [virtual]

Does the node result in a single value (for e.g.

GROUPBY)? This is the case for reduction functions and constant functions.

Reimplemented from casa::TableExprNodeRep.

static const Unit& casa::TableExprFuncNode::makeEqualUnits ( PtrBlock< TableExprNodeRep * > &  nodes,
uInt  starg,
uInt  endarg 
) [static, private]

Make the units of nodes from starg till endarg equal.

Return the unit found.

Some functions to be used by TableExprNodeFuncArray.

Definition at line 318 of file ExprFuncNode.h.

References casa::TableExprNodeMulti::operands_p.

Referenced by casa::TableExprFuncNodeArray::operands().

void casa::TableExprFuncNode::setScale ( Double  scale) [inline]

Set unit scale factor (needed for sqrt).

Definition at line 309 of file ExprFuncNode.h.

References scale_p.

Referenced by casa::TableExprFuncNodeArray::setScale().

static String casa::TableExprFuncNode::stringAngle ( double  val,
Int  prec,
MVAngle::formatTypes  type 
) [static]

Convert angle to a string (hms or dms).

static String casa::TableExprFuncNode::stringDate ( const MVTime dt) [static]
static String casa::TableExprFuncNode::stringDateTime ( const MVTime dt,
Int  prec 
) [static]
static String casa::TableExprFuncNode::stringDMS ( double  val,
Int  prec 
) [static]
static String casa::TableExprFuncNode::stringDT ( const MVTime dt,
Int  prec,
MVTime::formatTypes   
) [static]

Convert the date and/or time to a string.

static String casa::TableExprFuncNode::stringHMS ( double  val,
Int  prec 
) [static]
static String casa::TableExprFuncNode::stringTime ( const MVTime dt,
Int  prec 
) [static]

Try if the function gives a constant result.

If so, set the expression type to Constant.

Reimplemented in casa::TableExprConeNode.


Member Data Documentation

Definition at line 360 of file ExprFuncNode.h.

Referenced by argDataType().

Definition at line 359 of file ExprFuncNode.h.

Referenced by funcType().

Definition at line 361 of file ExprFuncNode.h.

Referenced by getScale(), and setScale().


The documentation for this class was generated from the following file: