casa
5.7.0-16
|
Readonly access to a table row. More...
#include <TableRow.h>
Public Member Functions | |
ROTableRow () | |
Create a detached ROTableRow object. More... | |
ROTableRow (const Table &table, Bool storedColumnsOnly=True) | |
Create a ROTableRow object for the given Table. More... | |
ROTableRow (const Table &table, const Vector< String > &columnNames, Bool exclude=False) | |
Create a ROTableRow object for the given Table. More... | |
ROTableRow (const ROTableRow &) | |
Copy constructor (copy semantics). More... | |
~ROTableRow () | |
ROTableRow & | operator= (const ROTableRow &) |
Assignment (copy semantics). More... | |
Bool | isAttached () const |
Test if a Table is attached to this object. More... | |
const Table & | table () const |
Get the Table used for this object. More... | |
const TableRecord & | record () const |
Get the record containing all fields. More... | |
Int64 | rowNumber () const |
Get the number of the last row read. More... | |
Vector< String > | columnNames () const |
Get a vector consisting of all columns names. More... | |
const TableRecord & | get (uInt rownr, Bool alwaysRead=False) const |
Get the values of all columns used from the given row. More... | |
const Block< Bool > & | getDefined () const |
Get the block telling for each column if its value in the row was indefined in the table. More... | |
Protected Member Functions | |
void | copy (const ROTableRow &that) |
Copy that object to this object. More... | |
void | create (const Table &table, Bool storedColumnsOnly, Bool writable) |
Create the record, column, and field objects for all columns in the table. More... | |
void | create (const Table &table, const Vector< String > &columnNames, Bool exclude, Bool writable) |
Create the record, column, and field objects for the given columns. More... | |
void | putRecord (uInt rownr) |
Put the values found in the internal TableRecord at the given row. More... | |
void | putField (uInt rownr, const TableRecord &record, Int whichColumn, Int whichField) |
Put a value in the given field in the TableRecord into the given row and column. More... | |
void | setReread (uInt rownr) |
Set the switch to reread when the current row has been put. More... | |
Protected Attributes | |
TableRecord * | itsRecord |
Table | itsTable |
Block< void * > | itsTabCols |
Block< void * > | itsColumns |
Block< void * > | itsFields |
Block< Bool > | itsDefined |
uInt | itsNrused |
Int64 | itsLastRow |
Bool | itsReread |
Private Member Functions | |
void | init () |
Initialize the object. More... | |
void | makeDescExclude (RecordDesc &description, const Vector< String > &columnNames, Bool writable) |
Make a RecordDesc from the table with some excluded column names. More... | |
void | addColumnToDesc (RecordDesc &description, const TableColumn &column, Bool skipOther) |
Add a column to the record. More... | |
void | makeObjects (const RecordDesc &description) |
Make the required objects. More... | |
void | deleteObjects () |
Delete all objects. More... | |
Readonly access to a table row.
Public interface
This class provides easy access to the contents of a table, one row at a time. 'Normal' access to a table is by columns, each of which contains values of the same type. A table row, by contrast, will be a collection of heterogeneous data, similar to a C struct. For this reason, the TableRow classes (ROTableRow and TableRow) are built around and provide access to the class TableRecord . The TableRow delegates much of its behaviour to the TableRecord class. For example:
The simplest constructor will include all columns in the TableRow object (although columns with a non-standard data type will be excluded, because they cannot be represented in a TableRecord). However, it is possible to be more selective and to include only some columns in the TableRow object. The various constructors show how this can be done.
It is possible to have multiple TableRow objects for the same table. They can contain different columns or they can share columns.
On construction an internal TableRecord object is created containing the required fields. The contents of this record will be changed with each get call, but the structure of it is fixed. This means that RORecordFieldPtr objects can be constructed once and used many times. This results in potentially faster access to the record, because it avoids unnecessary name lookups.
Please note that the TableRecord& returned by the get() function is the same as returned by the record() function. Therefore the RORecordField objects can be created in advance.
Definition at line 138 of file TableRow.h.
casacore::ROTableRow::ROTableRow | ( | ) |
Create a detached ROTableRow object.
This means that no Table, etc. is contained in it. Function isAttached will return False for it.
This constructor should normally not be used, because it does not result in a valid object. It should only be used when really needed (e.g. when an array of objects has to be used).
Create a ROTableRow object for the given Table.
Its TableRecord will contain all columns except columns with datatype TpOther (i.e. non-standard data types).
If the flag storedColumnsOnly
is True, only the columns actually stored by a storage manager will be selected. This is useful when the contents of an entire row have to be copied. Virtual columns are calculated on-the-fly (often using stored columns), thus it makes no sense to copy their data.
Caution: If the table contains columns with large arrays, it may be better not to use this constructor; Each get will read in all data in the row, thus also the large data array(s); In that case it is better to use the constructor which includes selected columns only;
casacore::ROTableRow::ROTableRow | ( | const Table & | table, |
const Vector< String > & | columnNames, | ||
Bool | exclude = False |
||
) |
Create a ROTableRow object for the given Table.
Its TableRecord will contain all columns given in the Vector. An exception is thrown if an unknown column name is given.
When exclude=True, all columns except the given columns are taken. In that case an unknown name does not result in an exception.
casacore::ROTableRow::ROTableRow | ( | const ROTableRow & | ) |
Copy constructor (copy semantics).
casacore::ROTableRow::~ROTableRow | ( | ) |
|
private |
Add a column to the record.
When skipOther is True, columns with a non-standard data type will be silently skipped.
Get a vector consisting of all columns names.
This can, for instance, be used to construct a TableRow object with the same columns in another table.
|
protected |
Copy that object to this object.
The writable flag determines if writable or readonly TableColumn objects will be created.
|
protected |
Create the record, column, and field objects for all columns in the table.
The writable flag determines if writable or readonly TableColumn objects will be created.
|
protected |
Create the record, column, and field objects for the given columns.
The writable flag determines if writable or readonly TableColumn objects will be created.
|
private |
Delete all objects.
const TableRecord& casacore::ROTableRow::get | ( | uInt | rownr, |
Bool | alwaysRead = False |
||
) | const |
Get the values of all columns used from the given row.
When the given row number equals the current one, nothing will be read unless the alwaysRead flag is set to True.
The TableRecord& returned is the same one as returned by the record() function. So one can ignore the return value of get().
Get the block telling for each column if its value in the row was indefined in the table.
Note that array values might be undefined in the table, but in the record they will be represented as empty arrays.
Definition at line 514 of file TableRow.h.
References itsDefined.
|
private |
Initialize the object.
|
inline |
Test if a Table is attached to this object.
Definition at line 498 of file TableRow.h.
References itsRecord.
|
private |
Make a RecordDesc from the table with some excluded column names.
|
private |
Make the required objects.
These are the TableRecord and for each column a TableColumn and RecordFieldPtr.
ROTableRow& casacore::ROTableRow::operator= | ( | const ROTableRow & | ) |
Assignment (copy semantics).
|
protected |
Put a value in the given field in the TableRecord into the given row and column.
This is a helper function for class TableRow.
|
protected |
Put the values found in the internal TableRecord at the given row.
This is a helper function for class TableRow.
Referenced by casacore::TableRow::put().
|
inline |
Get the record containing all fields.
Definition at line 510 of file TableRow.h.
References itsRecord.
|
inline |
Get the number of the last row read.
-1 is returned when no Table is attached or no row has been read yet.
Definition at line 506 of file TableRow.h.
References itsLastRow.
|
protected |
Set the switch to reread when the current row has been put.
|
inline |
|
protected |
Definition at line 256 of file TableRow.h.
Definition at line 261 of file TableRow.h.
Referenced by getDefined().
|
protected |
Definition at line 259 of file TableRow.h.
|
mutableprotected |
Definition at line 265 of file TableRow.h.
Referenced by rowNumber().
|
protected |
Definition at line 263 of file TableRow.h.
|
protected |
Definition at line 248 of file TableRow.h.
Referenced by isAttached(), record(), and casacore::TableRow::record().
|
mutableprotected |
Definition at line 268 of file TableRow.h.
|
protected |
Definition at line 254 of file TableRow.h.
|
protected |
Definition at line 250 of file TableRow.h.
Referenced by table().