Before a column can be accessed it must have previously been defined as a Measure column by use of the TableMeasDesc object.
The (RO)ScalarMeasColumn class is templated on Measure type. Typedefs exist in the various Measure classes (e.g. MEpoch) to make declaration less long winded. Constructing scalar Measure column objects using these typedefs looks like this:
MEpoch::ScalarMeasColumn ec(table, "ColumnName); MDoppler::ROScalarMeasColumn dc(table, "DopplerCol");
The reading and writing of Measures columns is very similar to reading and writing of "ordinary" Table columns. get() and operator() exist for reading Measures and the put() member for adding Measures to a column. (put() is obviously not defined for ROScalarMeasColumn objects.) Each of these members accepts a row number as an argument. The get() function gets the measure with the reference and offset as it is stored in the column. Furthermore the convert() function is available to get the measure with the given reference, possible offset, and possible frame
When a Measure is put, the reference and possible offset are converted if the measure column is defined with a fixed reference and/or offset. If the column's reference and offset are variable, the reference and offset of the measure as put are written into the appropriate reference and offset columns.
// This creates a Scalar MEpoch column for read/write access. Column // "Time1" must exist in Table "tab" and must have previously been // defined as a MEpoch column using a TableMeasDesc. MEpoch::ScalarMeasColumn timeCol(tab, "Time1"); // print some details about the column if (timeCol.isRefVariable()) { cout << "The column has variable references." << endl; } else { cout << "The fixed MeasRef for the column is: " << timeCol.getMeasRef() << endl; } // Add tab.nrow() measures to the column. MEpoch tm(Quantity(MeasData::MJD2000, "d"), MEpoch::TAI); for (uInt i=0; i<tab.nrow(); i++) { timeCol.put(i, tm); } // We could read from the column using timeCol but instead a read // only column object is created. MEpoch::ROScalarMeasColumn timeColRead(tab, "Time1"); for (i=0; i<tab.nrow(); i++) { cout << timeColRead(i) << endl; }
Create the ScalarMeasColumn from the table and column Name.
Copy constructor (copy semantics).
Change the reference to another column.
Attach a column to the object.
Get the Measure contained in the specified row.
It returns the Measure as found in the table.
Get the Measure contained in the specified row and convert
it to the reference and offset found in the given measure.
Get the Measure contained in the specified row and convert
it to the given reference.
Returns the column's fixed reference or the reference of the last
read Measure if references are variable.
Assignment makes no sense in a readonly class.
Declaring this operator private makes it unusable.
Create the ScalarMeasColumn from the table and column Name.
Copy constructor (copy semantics).
Change the column reference to another column.
Attach a column to the object.
Reset the refCode, offset, or units.
It overwrites the value used when defining the TableMeasDesc.
Resetting the refCode and offset can only be done if they were
defined as fixed in the description.
Put a Measure into the given row.
Declaring this operator private makes it unusable.
See class ScalarColumn for an
explanation as to why this operation is disallowed. Use the reference
function instead.
Check if refs have the same value (as opposed to being the same object).
void get (uInt rownr, M& meas) const
M operator() (uInt rownr) const
M convert (uInt rownr, const M& meas) const
M convert (uInt rownr, const MeasRef<M>& measRef) const
M convert (uInt rownr, uInt refCode) const
const MeasRef<M>& getMeasRef() const
MeasRef<M> makeMeasRef (uInt rownr) const
Make a MeasRef for the given row.
ROScalarMeasColumn& operator= (const ROScalarMeasColumn<M>& that)
void cleanUp()
template <class M> class ScalarMeasColumn : public ROScalarMeasColumn<M>
Interface
Description
Review Status
Synopsis
See description for
ROScalarMeasColumn.
Member Description
ScalarMeasColumn()
The default constructor creates a null object. Useful for creating
arrays of ScalarMeasColumn objects. Attempting to use a null object
will produce a segmentation fault so care needs to be taken when
initializing a null object by using the attach() member before any
attempt is made to use it. A ScalarMeasColumn object can be
tested if it is null by using the isNull() member.
ScalarMeasColumn (const Table& tab, const String& columnName)
ScalarMeasColumn (const ScalarMeasColumn<M>& that)
virtual ~ScalarMeasColumn()
void reference (const ScalarMeasColumn<M>& that)
void attach (const Table& tab, const String& columnName)
void setDescRefCode (uInt refCode, Bool tableMustBeEmpty=True)
void setDescOffset (const Measure& offset, Bool tableMustBeEmpty=True)
void setDescUnits (const Vector<Unit>& units, Bool tableMustBeEmpty=True)
In principle the functions can only be used if the table is empty,
otherwise already written values have thereafter the incorrect
reference, offset, or unit.
However, it is possible that part of the table is already
written and that the entire measure column is filled in later.
In that case the reference, offset, or units can be set by using
a False tableMustBeEmpty argument.
void put (uInt rownr, const M& meas)
ScalarMeasColumn& operator= (const ScalarMeasColumn<M>& that)
Bool equalRefs (const MRBase& r1, const MRBase& r2) const
void cleanUp()