Virtual scalar column using TaQL. More...
#include <VirtualTaQLColumn.h>
Public Member Functions | |
VirtualTaQLColumn (const String &expr) | |
Construct it with the given TaQL expression. | |
VirtualTaQLColumn (const Record &spec) | |
Construct it with the given specification. | |
virtual | ~VirtualTaQLColumn () |
Destructor is mandatory. | |
virtual DataManager * | clone () const |
Clone the engine object. | |
virtual Record | dataManagerSpec () const |
Get the data manager specification. | |
virtual String | dataManagerType () const |
Return the type name of the engine. | |
const String & | expression () const |
Return the TaQL expression used. | |
virtual int | dataType () const |
Functions to return column info. | |
virtual Bool | isWritable () const |
Test if data can be put into this column. | |
virtual uInt | ndim (uInt rownr) |
Get the dimensionality of the item in the given row. | |
virtual IPosition | shape (uInt rownr) |
Get the shape of the item in the given row. | |
virtual Bool | isShapeDefined (uInt rownr) |
Is the value shape defined in the given row? By default it returns True. | |
Static Public Member Functions | |
static String | className () |
Return the name of the class. | |
static void | registerClass () |
Register the class name and the static makeObject "constructor". | |
static DataManager * | makeObject (const String &dataManagerName, const Record &spec) |
Define the "constructor" to construct this engine when a table is read back. | |
Private Member Functions | |
VirtualTaQLColumn (const VirtualTaQLColumn &) | |
Copy is not needed and therefore forbidden (so it is made private). | |
VirtualTaQLColumn & | operator= (const VirtualTaQLColumn &) |
Assignment is not needed and therefore forbidden (so it is made private). | |
virtual DataManagerColumn * | makeScalarColumn (const String &columnName, int dataType, const String &) |
Create the column object for the scalar column in this engine. | |
virtual DataManagerColumn * | makeIndArrColumn (const String &columnName, int dataType, const String &dataTypeId) |
Create the column object for the indirect array column in this engine. | |
virtual void | create (uInt) |
Let the engine initialize the object for a new table. | |
virtual void | prepare () |
Prepare compiles the expression. | |
virtual void | getBoolV (uInt rownr, Bool *dataPtr) |
Get the scalar value in the given row. | |
virtual void | getuCharV (uInt rownr, uChar *dataPtr) |
virtual void | getShortV (uInt rownr, Short *dataPtr) |
virtual void | getuShortV (uInt rownr, uShort *dataPtr) |
virtual void | getIntV (uInt rownr, Int *dataPtr) |
virtual void | getuIntV (uInt rownr, uInt *dataPtr) |
virtual void | getfloatV (uInt rownr, float *dataPtr) |
virtual void | getdoubleV (uInt rownr, double *dataPtr) |
virtual void | getComplexV (uInt rownr, Complex *dataPtr) |
virtual void | getDComplexV (uInt rownr, DComplex *dataPtr) |
virtual void | getStringV (uInt rownr, String *dataPtr) |
virtual void | getArrayV (uInt rownr, void *dataPtr) |
Get the array value in the given row. | |
IPosition | getResult (uInt rownr, void *dataPtr) |
Get the result. | |
void | clearCurResult () |
Clear the result cache. | |
Private Attributes | |
int | itsDataType |
Bool | itsIsArray |
String | itsColumnName |
String | itsExpr |
TableExprNode * | itsNode |
Bool | itsTempWritable |
Int | itsCurRow |
void * | itsCurResult |
IPosition | itsCurShape |
Virtual scalar column using TaQL.
VirtualTaQLColumn is a virtual column engine to define the contents of a column as a TaQL expression in which possibly other columns are used. It is (of course) only possible to get data from the column; puts cannot be done.
The expression result can be a scalar or array of the basic TaQL data types. The column data type has to be conformant with that TaQL type, thus a column of any integer type has to be used for an integer TaQL result.
Caution: One has to be careful with deleting columns; If in an existing table a TaQL expression uses a deleted column, the expression cannot be parsed anymore and the table cannot be opened anymore; In the future the Table System will be made more forgiving;
The following example creates a table with a few columns. One column is virtual and has a random value if Col3 is true. Otherwise it has value 0.
// Create the table description. TableDesc td; td.addColumn (ScalarColumnDesc<DComplex>("Col1")); td.addColumn (ScalarColumnDesc<Int>("Col2")); td.addColumn (ScalarColumnDesc<Bool>("Col3")); td.addColumn (ScalarColumnDesc<Double>("ColVirt")); // Now create a new table from the description. SetupNewTable newTab("tmtest", td, Table::New); // Define the expression of the virtual column and bind the column to it. // The other columns are by default bound to StandardStMan. VirtualTaQLColumn engine("iif(Col3,rand(),0)"); newTab.bindColumn("ColVirt", engine); Table tab(newTab);
Definition at line 89 of file VirtualTaQLColumn.h.
casacore::VirtualTaQLColumn::VirtualTaQLColumn | ( | const String & | expr | ) |
Construct it with the given TaQL expression.
casacore::VirtualTaQLColumn::VirtualTaQLColumn | ( | const Record & | spec | ) |
Construct it with the given specification.
virtual casacore::VirtualTaQLColumn::~VirtualTaQLColumn | ( | ) | [virtual] |
Destructor is mandatory.
casacore::VirtualTaQLColumn::VirtualTaQLColumn | ( | const VirtualTaQLColumn & | ) | [private] |
Copy is not needed and therefore forbidden (so it is made private).
static String casacore::VirtualTaQLColumn::className | ( | ) | [static] |
Return the name of the class.
void casacore::VirtualTaQLColumn::clearCurResult | ( | ) | [private] |
Clear the result cache.
virtual DataManager* casacore::VirtualTaQLColumn::clone | ( | ) | const [virtual] |
Clone the engine object.
Implements casacore::DataManager.
virtual void casacore::VirtualTaQLColumn::create | ( | uInt | ) | [private, virtual] |
Let the engine initialize the object for a new table.
It defines a column keyword holding the expression.
Reimplemented from casacore::VirtualColumnEngine.
virtual Record casacore::VirtualTaQLColumn::dataManagerSpec | ( | ) | const [virtual] |
Get the data manager specification.
Reimplemented from casacore::DataManager.
virtual String casacore::VirtualTaQLColumn::dataManagerType | ( | ) | const [virtual] |
Return the type name of the engine.
(i.e. its class name VirtualTaQLColumn).
Implements casacore::DataManager.
virtual int casacore::VirtualTaQLColumn::dataType | ( | ) | const [virtual] |
Functions to return column info.
Implements casacore::DataManagerColumn.
const String& casacore::VirtualTaQLColumn::expression | ( | ) | const [inline] |
Return the TaQL expression used.
Definition at line 129 of file VirtualTaQLColumn.h.
References itsExpr.
virtual void casacore::VirtualTaQLColumn::getArrayV | ( | uInt | rownr, | |
void * | dataPtr | |||
) | [private, virtual] |
Get the array value in the given row.
The argument dataPtr is in fact an Array<T>*, but a void* is needed to be generic. The array pointed to by dataPtr has to have the correct shape (which is guaranteed by the ArrayColumn get function). The default implementation throws an "invalid operation" exception.
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getBoolV | ( | uInt | rownr, | |
Bool * | dataPtr | |||
) | [private, virtual] |
Get the scalar value in the given row.
The default implementation throws an "invalid operation" exception.
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getComplexV | ( | uInt | rownr, | |
Complex * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getDComplexV | ( | uInt | rownr, | |
DComplex * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getdoubleV | ( | uInt | rownr, | |
double * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getfloatV | ( | uInt | rownr, | |
float * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
Reimplemented from casacore::DataManagerColumn.
Get the result.
virtual void casacore::VirtualTaQLColumn::getShortV | ( | uInt | rownr, | |
Short * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getStringV | ( | uInt | rownr, | |
String * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getuCharV | ( | uInt | rownr, | |
uChar * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getuIntV | ( | uInt | rownr, | |
uInt * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::getuShortV | ( | uInt | rownr, | |
uShort * | dataPtr | |||
) | [private, virtual] |
Reimplemented from casacore::DataManagerColumn.
Is the value shape defined in the given row? By default it returns True.
Reimplemented from casacore::DataManagerColumn.
virtual Bool casacore::VirtualTaQLColumn::isWritable | ( | ) | const [virtual] |
Test if data can be put into this column.
This does not test if the data file is writable, only if it is in principle allowed to store data into the column. (It may not be allowed for virtual columns). The default is True.
Reimplemented from casacore::DataManagerColumn.
virtual DataManagerColumn* casacore::VirtualTaQLColumn::makeIndArrColumn | ( | const String & | columnName, | |
int | dataType, | |||
const String & | dataTypeId | |||
) | [private, virtual] |
Create the column object for the indirect array column in this engine.
Reimplemented from casacore::VirtualColumnEngine.
static DataManager* casacore::VirtualTaQLColumn::makeObject | ( | const String & | dataManagerName, | |
const Record & | spec | |||
) | [static] |
Define the "constructor" to construct this engine when a table is read back.
This "constructor" has to be registered by the user of the engine. If the engine is commonly used, its registration can be added into the registerAllCtor function in DataManReg.cc. This function gets automatically invoked by the table system.
virtual DataManagerColumn* casacore::VirtualTaQLColumn::makeScalarColumn | ( | const String & | columnName, | |
int | dataType, | |||
const String & | ||||
) | [private, virtual] |
Create the column object for the scalar column in this engine.
Reimplemented from casacore::VirtualColumnEngine.
Get the dimensionality of the item in the given row.
By default it returns shape(rownr).nelements().
Reimplemented from casacore::DataManagerColumn.
VirtualTaQLColumn& casacore::VirtualTaQLColumn::operator= | ( | const VirtualTaQLColumn & | ) | [private] |
Assignment is not needed and therefore forbidden (so it is made private).
Reimplemented from casacore::DataManagerColumn.
virtual void casacore::VirtualTaQLColumn::prepare | ( | ) | [private, virtual] |
Prepare compiles the expression.
Reimplemented from casacore::VirtualColumnEngine.
static void casacore::VirtualTaQLColumn::registerClass | ( | ) | [static] |
Register the class name and the static makeObject "constructor".
This will make the engine known to the table system.
Get the shape of the item in the given row.
By default it returns a zero-length IPosition (for a scalar value).
Reimplemented from casacore::DataManagerColumn.
Definition at line 204 of file VirtualTaQLColumn.h.
void* casacore::VirtualTaQLColumn::itsCurResult [private] |
Definition at line 209 of file VirtualTaQLColumn.h.
Int casacore::VirtualTaQLColumn::itsCurRow [private] |
Definition at line 208 of file VirtualTaQLColumn.h.
Definition at line 210 of file VirtualTaQLColumn.h.
int casacore::VirtualTaQLColumn::itsDataType [private] |
Definition at line 202 of file VirtualTaQLColumn.h.
String casacore::VirtualTaQLColumn::itsExpr [private] |
Definition at line 205 of file VirtualTaQLColumn.h.
Referenced by expression().
Bool casacore::VirtualTaQLColumn::itsIsArray [private] |
Definition at line 203 of file VirtualTaQLColumn.h.
Definition at line 206 of file VirtualTaQLColumn.h.
Definition at line 207 of file VirtualTaQLColumn.h.