casacore
|
Read/write access to a table row. More...
#include <TableRow.h>
Public Member Functions | |
TableRow () | |
Create a detached TableRow object. More... | |
TableRow (const Table &table, Bool storedColumnsOnly=True) | |
Create a TableRow object for the given Table. More... | |
TableRow (const Table &table, const Vector< String > &columnNames, Bool exclude=False) | |
Create a TableRow object for the given Table. More... | |
TableRow (const TableRow &) | |
Copy constructor (copy semantics). More... | |
~TableRow () | |
TableRow & | operator= (const TableRow &) |
Assignment (copy semantics). More... | |
TableRecord & | record () |
Get non-const access to the TableRecord in this object. More... | |
void | put () |
Put into the last row read. More... | |
void | put (rownr_t rownr) |
Put into the given row. More... | |
void | put (rownr_t rownr, const TableRecord &record, Bool checkConformance=True) |
Put the values found in the TableRecord in the appropriate columns in the given row. More... | |
void | put (rownr_t rownr, const TableRecord &record, const Block< Bool > &valuesDefined, Bool checkConformance=True) |
void | putMatchingFields (rownr_t rownr, const TableRecord &record) |
Put the values found in the TableRecord. More... | |
Public Member Functions inherited from casacore::ROTableRow | |
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 (rownr_t 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... | |
Private Member Functions | |
Bool | namesConform (const TableRecord &that) const |
Check if the names of the given record match this row. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from casacore::ROTableRow | |
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 (rownr_t rownr) |
Put the values found in the internal TableRecord at the given row. More... | |
void | putField (rownr_t 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 (rownr_t rownr) |
Set the switch to reread when the current row has been put. More... | |
Protected Attributes inherited from casacore::ROTableRow | |
TableRecord * | itsRecord |
Table | itsTable |
Block< void * > | itsTabCols |
Block< void * > | itsColumns |
Block< void * > | itsFields |
Block< Bool > | itsDefined |
uInt | itsNrused |
Int64 | itsLastRow |
Bool | itsReread |
Read/write access to a table row.
Public interface
The class TableRow is derived from ROTableRow and as an extra it provides write-access to a row in a table. With the put function, all values in the TableRecord object will be put in the corresponding columns in the table row. There is, however, an extra consideration:
There are effectively 3 ways of writing data.
record
and put
. It is possible to use RecordFieldPtr objects to get direct access to the fields in the record (provided the structure of the record is known). E.g. Definition at line 389 of file TableRow.h.
casacore::TableRow::TableRow | ( | ) |
Create a detached TableRow object.
This means that no Table, etc. is contained in it. Function isAttached (in the base class) 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 TableRow object for the given Table.
Its TableRecord will contain all columns except columns with datatype TpOther and columns which are not writable.
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 next constructor which works selectively;
casacore::TableRow::TableRow | ( | const Table & | table, |
const Vector< String > & | columnNames, | ||
Bool | exclude = False |
||
) |
Create a TableRow 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 or if a column is given which is not writable.
When exclude=True, all columns except the given columns are taken. In that case an unknown name does not result in an exception and non-writable columns are simply skipped.
casacore::TableRow::TableRow | ( | const TableRow & | ) |
Copy constructor (copy semantics).
casacore::TableRow::~TableRow | ( | ) |
|
private |
Check if the names of the given record match this row.
void casacore::TableRow::put | ( | ) |
Put into the last row read.
An exception is thrown if no row has been read yet. The values in the TableRecord contained in this object are put. This TableRecord can be accessed and updated using the function record
.
|
inline |
Put into the given row.
The values in the TableRecord contained in this object are put. This TableRecord can be accessed and updated using the function record
.
Definition at line 521 of file TableRow.h.
References casacore::ROTableRow::putRecord().
void casacore::TableRow::put | ( | rownr_t | rownr, |
const TableRecord & | record, | ||
Bool | checkConformance = True |
||
) |
Put the values found in the TableRecord in the appropriate columns in the given row.
The names and order of the fields in the TableRecord must conform those of the description of the TableRow. The data types of numeric values do not need to conform exactly; they can be promoted (e.g. an Int value in the record may correspond to a float column). If not conforming, an exception is thrown.
Note: For performance reasons it is optional to check the name order conformance;
The valuesDefined
block tells if the value in the corresponding field in the record is actually defined. If not, nothing will be written. It is meant for array values which might be undefined in a table.
void casacore::TableRow::put | ( | rownr_t | rownr, |
const TableRecord & | record, | ||
const Block< Bool > & | valuesDefined, | ||
Bool | checkConformance = True |
||
) |
void casacore::TableRow::putMatchingFields | ( | rownr_t | rownr, |
const TableRecord & | record | ||
) |
Put the values found in the TableRecord.
Only fields with a matching name in the TableRow object will be put. This makes it possible to put fields in a selective way.
E.g.: If the TableRow contains columns A and B, and the record contains fields B and C, only field B will be put.
In principle the data types of the matching fields must match, but data type promotion of numeric values will be applied.
|
inline |
Get non-const access to the TableRecord in this object.
This can be used to change values in it which can thereafter be put using the function put(rownr)
.
Note: The returned TableRecord has a fixed structure, so it is not possible to add or remove fields; It is only possible to change values;
Definition at line 517 of file TableRow.h.
References casacore::ROTableRow::itsRecord.