casacore::TableExprFuncNode Class Reference

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

#include <ExprFuncNode.h>

Inheritance diagram for casacore::TableExprFuncNode:
casacore::TableExprNodeMulti casacore::TableExprNodeRep casacore::TableExprAggrNode casacore::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,
  nfalseFUNC,
  nfalsesFUNC,
  arrayFUNC,
  transposeFUNC,
  resizeFUNC,
  diagonalFUNC,
  isnanFUNC,
  isinfFUNC,
  isfiniteFUNC,
  isdefFUNC,
  isnullFUNC,
  iscolFUNC,
  iskeyFUNC,
  ndimFUNC,
  nelemFUNC,
  shapeFUNC,
  strlengthFUNC,
  upcaseFUNC,
  downcaseFUNC,
  capitalizeFUNC,
  trimFUNC,
  ltrimFUNC,
  rtrimFUNC,
  substrFUNC,
  replaceFUNC,
  regexFUNC,
  patternFUNC,
  sqlpatternFUNC,
  datetimeFUNC,
  mjdtodateFUNC,
  mjdFUNC,
  dateFUNC,
  timeFUNC,
  yearFUNC,
  monthFUNC,
  dayFUNC,
  cmonthFUNC,
  weekdayFUNC,
  cdowFUNC,
  weekFUNC,
  ctodFUNC,
  cdateFUNC,
  ctimeFUNC,
  stringFUNC,
  hmsFUNC,
  dmsFUNC,
  hdmsFUNC,
  randFUNC,
  rownrFUNC,
  rowidFUNC,
  iifFUNC,
  angdistFUNC,
  angdistxFUNC,
  conesFUNC,
  cones3FUNC,
  anyconeFUNC,
  anycone3FUNC,
  findconeFUNC,
  findcone3FUNC,
  boolFUNC,
  nullarrayFUNC,
  marrayFUNC,
  arrdataFUNC,
  arrmaskFUNC,
  negatemaskFUNC,
  replmaskedFUNC,
  replunmaskedFUNC,
  arrflatFUNC,
  FirstAggrFunc,
  countallFUNC,
  gcountFUNC,
  gfirstFUNC,
  glastFUNC,
  gminFUNC,
  gmaxFUNC,
  gsumFUNC,
  gproductFUNC,
  gsumsqrFUNC,
  gmeanFUNC,
  gvarianceFUNC,
  gstddevFUNC,
  grmsFUNC,
  ganyFUNC,
  gallFUNC,
  gntrueFUNC,
  gnfalseFUNC,
  FirstAggrArrayFunc,
  gminsFUNC,
  gmaxsFUNC,
  gsumsFUNC,
  gproductsFUNC,
  gsumsqrsFUNC,
  gmeansFUNC,
  gvariancesFUNC,
  gstddevsFUNC,
  grmssFUNC,
  ganysFUNC,
  gallsFUNC,
  gntruesFUNC,
  gnfalsesFUNC,
  LastAggrArrayFunc,
  ghistFUNC,
  gaggrFUNC,
  growidFUNC,
  gmedianFUNC,
  gfractileFUNC,
  gexpridFUNC,
  NRFUNC
}

Public Member Functions

 TableExprFuncNode (FunctionType, NodeDataType, ValueType, const TableExprNodeSet &source, const Table &=Table())
 Constructor.
 ~TableExprFuncNode ()
 Destructor.
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 void getPrintFormat (String &fmt, Int &width, Int &prec, const PtrBlock< TableExprNodeRep * > &operands, const TableExprId &id)
 Get the possible print format, width, and/or precision.
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 stringValue (Bool val, const String &fmt, Int width)
 Convert a value to a string.
static String stringValue (Int64 val, const String &fmt, Int width)
static String stringValue (Double val, const String &fmt, Int width, Int prec, const std::pair< int, int > &mvFormat, const Unit &unit)
static String stringValue (const DComplex &val, const String &fmt, Int width, Int prec)
static String stringValue (const String &val, const String &fmt, Int width)
static String stringValue (const MVTime &val, const String &fmt, Int width, const std::pair< int, int > &mvFormat)
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 std::pair< int, int > getMVFormat (const String &fmt)
 Get the MVTime/Angle format and optional precision.
static double angdist (double ra1, double dec1, double ra2, double dec2)
 Get the angular distance between two positions on a sphere.
static Int64 string2Int (const String &)
 Read a string as an integer, double, complex or bool.
static Double string2Real (const String &)
static DComplex string2Complex (const String &)
static Bool string2Bool (const String &)

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
Table table_p
 (needed for sqrt)

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 76 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, DComplex, Bool or String returning Double

imagFUNC 
intFUNC 

for Int, Double, Bool or String 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 
nfalseFUNC 
nfalsesFUNC 
arrayFUNC 

for any type returning array of that type

transposeFUNC 
resizeFUNC 
diagonalFUNC 
isnanFUNC 

for Int, Double or DComplex array returning Bool

isinfFUNC 
isfiniteFUNC 
isdefFUNC 

for any array returning Bool scalar

isnullFUNC 
iscolFUNC 
iskeyFUNC 
ndimFUNC 

for any array returning Int scalar

nelemFUNC 
shapeFUNC 

for any array returning Int array

strlengthFUNC 

for String

upcaseFUNC 
downcaseFUNC 
capitalizeFUNC 
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 
stringFUNC 

return values as strings

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 

cone search functions, implemented in derived class

cones3FUNC 
anyconeFUNC 
anycone3FUNC 
findconeFUNC 
findcone3FUNC 
boolFUNC 

for Int, Double, Complex or String returning Bool

nullarrayFUNC 

masked array functions

marrayFUNC 
arrdataFUNC 
arrmaskFUNC 
negatemaskFUNC 
replmaskedFUNC 
replunmaskedFUNC 
arrflatFUNC 
FirstAggrFunc 
countallFUNC 
gcountFUNC 
gfirstFUNC 
glastFUNC 
gminFUNC 
gmaxFUNC 
gsumFUNC 
gproductFUNC 
gsumsqrFUNC 
gmeanFUNC 
gvarianceFUNC 
gstddevFUNC 
grmsFUNC 
ganyFUNC 
gallFUNC 
gntrueFUNC 
gnfalseFUNC 
FirstAggrArrayFunc 
gminsFUNC 
gmaxsFUNC 
gsumsFUNC 
gproductsFUNC 
gsumsqrsFUNC 
gmeansFUNC 
gvariancesFUNC 
gstddevsFUNC 
grmssFUNC 
ganysFUNC 
gallsFUNC 
gntruesFUNC 
gnfalsesFUNC 
LastAggrArrayFunc 
ghistFUNC 
gaggrFUNC 
growidFUNC 
gmedianFUNC 
gfractileFUNC 
gexpridFUNC 
NRFUNC 

Definition at line 80 of file ExprFuncNode.h.


Constructor & Destructor Documentation

casacore::TableExprFuncNode::TableExprFuncNode ( FunctionType  ,
NodeDataType  ,
ValueType  ,
const TableExprNodeSet source,
const Table = Table() 
)

Constructor.

casacore::TableExprFuncNode::~TableExprFuncNode (  ) 

Destructor.


Member Function Documentation

static double casacore::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 432 of file ExprFuncNode.h.

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

NodeDataType casacore::TableExprFuncNode::argDataType (  )  const [inline]

Definition at line 383 of file ExprFuncNode.h.

References argDataType_p.

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

static NodeDataType casacore::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 casacore::TableExprConeNode.

static void casacore::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.

Reimplemented in casacore::TableExprConeNode.

static TableExprNodeRep* casacore::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.

Reimplemented in casacore::TableExprConeNode.

static Double casacore::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).

FunctionType casacore::TableExprFuncNode::funcType (  )  const [inline]

Definition at line 381 of file ExprFuncNode.h.

References funcType_p.

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

Bool casacore::TableExprFuncNode::getBool ( const TableExprId id  )  [virtual]

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

Reimplemented from casacore::TableExprNodeRep.

Reimplemented in casacore::TableExprAggrNode, and casacore::TableExprConeNode.

MVTime casacore::TableExprFuncNode::getDate ( const TableExprId id  )  [virtual]

Reimplemented from casacore::TableExprNodeRep.

Reimplemented in casacore::TableExprAggrNode.

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

Reimplemented from casacore::TableExprNodeRep.

Reimplemented in casacore::TableExprAggrNode.

Double casacore::TableExprFuncNode::getDouble ( const TableExprId id  )  [virtual]

Reimplemented from casacore::TableExprNodeRep.

Reimplemented in casacore::TableExprAggrNode.

Int64 casacore::TableExprFuncNode::getInt ( const TableExprId id  )  [virtual]
static std::pair<int,int> casacore::TableExprFuncNode::getMVFormat ( const String fmt  )  [static]

Get the MVTime/Angle format and optional precision.

0,0 is returned if empty or unknown format.

static void casacore::TableExprFuncNode::getPrintFormat ( String fmt,
Int width,
Int prec,
const PtrBlock< TableExprNodeRep * > &  operands,
const TableExprId id 
) [static]

Get the possible print format, width, and/or precision.

TaqlRegex casacore::TableExprFuncNode::getRegex ( const TableExprId id  )  [virtual]

Reimplemented from casacore::TableExprNodeRep.

Double casacore::TableExprFuncNode::getScale (  )  const [inline]

Get possible unit scale factor (needed for sqrt).

Definition at line 372 of file ExprFuncNode.h.

References scale_p.

String casacore::TableExprFuncNode::getString ( const TableExprId id  )  [virtual]

Reimplemented from casacore::TableExprNodeRep.

Reimplemented in casacore::TableExprAggrNode.

static const Unit& casacore::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.

const PtrBlock<TableExprNodeRep*>& casacore::TableExprFuncNode::operands (  )  const [inline]

Some functions to be used by TableExprNodeFuncArray.

Definition at line 377 of file ExprFuncNode.h.

References casacore::TableExprNodeMulti::operands_p.

Referenced by casacore::TableExprAggrNode::operand(), and casacore::TableExprFuncNodeArray::operands().

PtrBlock<TableExprNodeRep*>& casacore::TableExprFuncNode::rwOperands (  )  [inline]
void casacore::TableExprFuncNode::setScale ( Double  scale  )  [inline]

Set unit scale factor (needed for sqrt).

Definition at line 368 of file ExprFuncNode.h.

References scale_p.

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

static Bool casacore::TableExprFuncNode::string2Bool ( const String  )  [static]
static DComplex casacore::TableExprFuncNode::string2Complex ( const String  )  [static]
static Int64 casacore::TableExprFuncNode::string2Int ( const String  )  [static]

Read a string as an integer, double, complex or bool.

static Double casacore::TableExprFuncNode::string2Real ( const String  )  [static]
static String casacore::TableExprFuncNode::stringAngle ( double  val,
Int  prec,
MVAngle::formatTypes  type 
) [static]

Convert angle to a string (hms or dms).

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

Convert the date and/or time to a string.

static String casacore::TableExprFuncNode::stringHMS ( double  val,
Int  prec 
) [static]
static String casacore::TableExprFuncNode::stringTime ( const MVTime dt,
Int  prec 
) [static]
static String casacore::TableExprFuncNode::stringValue ( const MVTime val,
const String fmt,
Int  width,
const std::pair< int, int > &  mvFormat 
) [static]
static String casacore::TableExprFuncNode::stringValue ( const String val,
const String fmt,
Int  width 
) [static]
static String casacore::TableExprFuncNode::stringValue ( const DComplex &  val,
const String fmt,
Int  width,
Int  prec 
) [static]
static String casacore::TableExprFuncNode::stringValue ( Double  val,
const String fmt,
Int  width,
Int  prec,
const std::pair< int, int > &  mvFormat,
const Unit unit 
) [static]
static String casacore::TableExprFuncNode::stringValue ( Int64  val,
const String fmt,
Int  width 
) [static]
static String casacore::TableExprFuncNode::stringValue ( Bool  val,
const String fmt,
Int  width 
) [static]

Convert a value to a string.

If fmt is empty, ostringstream is used. Otherwise the printf-like format is used. If possible, a double value is converted to radians if formatted as angle.

void casacore::TableExprFuncNode::tryToConst (  )  [private]

Try if the function gives a constant result.

If so, set the expression type to Constant.

Reimplemented in casacore::TableExprConeNode.


Member Data Documentation

Definition at line 453 of file ExprFuncNode.h.

Referenced by argDataType().

Definition at line 452 of file ExprFuncNode.h.

Referenced by funcType().

Definition at line 454 of file ExprFuncNode.h.

Referenced by getScale(), and setScale().

(needed for sqrt)

Reimplemented from casacore::TableExprNodeRep.

Definition at line 456 of file ExprFuncNode.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1