casa
5.7.0-16
|
Class to provide option parsing routines for display classes. More...
#include <DisplayOptions.h>
Public Member Functions | |
DisplayOptions () | |
Constructor. More... | |
virtual | ~DisplayOptions () |
Destructor. More... | |
template<class T > | |
casacore::Bool | readOptionRecord (casacore::Vector< T > &target, casacore::Bool &error, const casacore::Record &rec, const casacore::String &fieldname) const |
Find the field fieldname in casacore::Record rec , containing the requested type (casacore::Bool, casacore::String, casacore::Float, casacore::Int) in itself or its "value" sub-field, and return the value in target . More... | |
template<class T > | |
casacore::Bool | readOptionRecord (T &target, casacore::Bool &error, const casacore::Record &rec, const casacore::String &fieldname) const |
virtual casacore::Bool | readOptionRecord (casacore::String &target, casacore::Bool &unsetTarget, casacore::Bool &error, const casacore::Record &rec, const casacore::String &fieldname) const |
Find the field fieldname in casacore::Record rec , containing the requested type (casacore::String) in itself or its "value" sub-field, and return the value in target . More... | |
casacore::Record | unset () const |
Return a casacore::Record which is an "unset" casacore::Record, ie. More... | |
casacore::Bool | isUnset (const casacore::Record &rec) const |
Return true or false indicating if the provided casacore::Record is equal to an "unset" Record. More... | |
Protected Member Functions | |
DisplayOptions (const DisplayOptions &other) | |
(Required) copy constructor. More... | |
void | operator= (const DisplayOptions &other) |
(Required) copy assignment. More... | |
Private Member Functions | |
casacore::Bool | compatible (const casacore::DataType &compareme, const casacore::DataType &tome) const |
A utility to check if two types are compatible. More... | |
Private Attributes | |
casacore::Record | itsUnsetRecord |
An unset record to return with protected unset() function. More... | |
Class to provide option parsing routines for display classes.
Internal
DisplayOptions contains methods for parsing "Options" for various "Display" classes.
DisplayOptions is a simple class which provides methods for parsing Records containing fields which conform to "options" as used in the Display Library classes. Consider a record having the following structure:
The DisplayOptions methods can be used to extract the values of the minimum
and maximum
fields of the Record rec
, regardless of whether the value itself is stored in a value
sub-field, or at the next higher level. The DisplayOptions methods also offer the capability to detect "unset" casacore::Record values.
This class can be used as-is, or inherited from by higher-level classes.
The following example shows the use of DisplayOptions as a stand-alone class.
Options are used prolifically throughout the display classes, so some unified processing of options is desirable.
.
Definition at line 116 of file DisplayOptions.h.
casa::DisplayOptions::DisplayOptions | ( | ) |
Constructor.
|
inlinevirtual |
Destructor.
Definition at line 124 of file DisplayOptions.h.
|
protected |
(Required) copy constructor.
|
private |
A utility to check if two types are compatible.
(I.e. double is "compatible" with int. Used by readOptionRecord.
casacore::Bool casa::DisplayOptions::isUnset | ( | const casacore::Record & | rec | ) | const |
Return true or false indicating if the provided casacore::Record is equal to an "unset" Record.
|
protected |
(Required) copy assignment.
casacore::Bool casa::DisplayOptions::readOptionRecord | ( | casacore::Vector< T > & | target, |
casacore::Bool & | error, | ||
const casacore::Record & | rec, | ||
const casacore::String & | fieldname | ||
) | const |
Find the field fieldname
in casacore::Record rec
, containing the requested type (casacore::Bool, casacore::String, casacore::Float, casacore::Int) in itself or its "value" sub-field, and return the value in target
.
If the field doesn't exist, or does not contain the requested type, or a "value" sub-field containing the requested type, then error
is set true. When error
is false, the return value indicates whether target
was modified. The casacore::Float version will also read records containing Ints or Doubles, and cast their value to Float.
casacore::Bool casa::DisplayOptions::readOptionRecord | ( | T & | target, |
casacore::Bool & | error, | ||
const casacore::Record & | rec, | ||
const casacore::String & | fieldname | ||
) | const |
|
virtual |
Find the field fieldname
in casacore::Record rec
, containing the requested type (casacore::String) in itself or its "value" sub-field, and return the value in target
.
If the field (or "value" sub-field) instead contains an "unset" casacore::Record, then unsetTarget
is set true. If the field doesn't exist, or does not contain the requested type (casacore::String) or an "unset" casacore::Record, or a "value" sub-field containing either of these, then error
is set true. When error
is false, the return value indicates whether target
(or unsetTarget
) was modified.
|
inline |
Return a casacore::Record which is an "unset" casacore::Record, ie.
has a field with name casacore::String("i_am_unset")
whose value is casacore::String("i_am_unset")
.
Definition at line 163 of file DisplayOptions.h.
References itsUnsetRecord.
|
private |
An unset record to return with protected unset()
function.
Definition at line 186 of file DisplayOptions.h.
Referenced by unset().