casacore::QuantumHolder Class Reference
A holder for Quantums to enable record conversions.
More...
#include <QuantumHolder.h>
List of all members.
Detailed Description
A holder for Quantums to enable record conversions.
Intended use:
Public interface
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
- Test programs:
- tQuantumHolder
Prerequisite
Etymology
A Holder of general Quantums
Synopsis
This class can be used to handle a heterogeneous list of Quantums, and can handle toRecord() and fromRecord() conversions. A QuantumHolder is created empty, from a Quantum (e.g. a Quantum<Double>
) or a Quantum<Vector<Float> >
).
The accepted range of Quantums is:
Scalars in the same group can be converted to any in the same group (e.g. Int to Double); Vectors of length 1 can be converted to scalars in the corresponding group; Scalars can always be converted to Vectors in the corresponding group. Real scalar values can be converted to Complex values. Vectors cannot be converted to other type vectors.
Checks on the contents can be made with functions like isQuantity
and the contents can be obtained with functions like asQuantity
. It is an error to try and retrieve a Quantum of the wrong type and doing so will generate an exception (AipsError).
Example
Motivation
To make general conversions between Quantums and records, without knowing the actual Quantum being converted.
Definition at line 117 of file QuantumHolder.h.
Constructor & Destructor Documentation
casacore::QuantumHolder::QuantumHolder |
( |
|
) |
|
casacore::QuantumHolder::QuantumHolder |
( |
const QBase & |
in |
) |
|
Create from a Quantum (copy semantics).
casacore::QuantumHolder::QuantumHolder |
( |
const QuantumHolder & |
other |
) |
|
Copy a holder (copy semantics).
casacore::QuantumHolder::~QuantumHolder |
( |
|
) |
|
Member Function Documentation
const QBase& casacore::QuantumHolder::asQuantum |
( |
|
) |
const |
Get a Quantum from the holder (with lifetime as long as holder exists).
Conversions done if necessary and as described in introduction.
Thrown Exceptions
-
AipsError if holder empty or no conversion possible
const Quantum<Array<Complex> >& casacore::QuantumHolder::asQuantumArrayComplex |
( |
|
) |
|
const Quantum<Array<DComplex> >& casacore::QuantumHolder::asQuantumArrayDComplex |
( |
|
) |
|
const Quantum<Complex>& casacore::QuantumHolder::asQuantumComplex |
( |
|
) |
|
const Quantum<DComplex>& casacore::QuantumHolder::asQuantumDComplex |
( |
|
) |
|
const Quantum<Double>& casacore::QuantumHolder::asQuantumDouble |
( |
|
) |
|
const Quantum<Float>& casacore::QuantumHolder::asQuantumFloat |
( |
|
) |
|
const Quantum<Int>& casacore::QuantumHolder::asQuantumInt |
( |
|
) |
|
const Quantum<Vector<Complex> >& casacore::QuantumHolder::asQuantumVectorComplex |
( |
|
) |
|
const Quantum<Vector<DComplex> >& casacore::QuantumHolder::asQuantumVectorDComplex |
( |
|
) |
|
Create a Quantum from a record or a string.
A valid record will contain the following fields:
-
value: contains a numeric value of Int, Float, Double, Complex, DComplex or a vector thereof
-
unit: a string with a valid unit string.
A valid string will be one of the special time/angle formats or a value with a valid unit string. Illegal values or units will return False and write an error message.
Implements casacore::RecordTransformable.
virtual Bool casacore::QuantumHolder::fromString |
( |
String & |
error, |
|
|
const String & |
inString | |
|
) |
| | [virtual] |
Initialise the class from a String representation.
A string cannot contain enough information for many objects. Hence the default implementation of this class returns False, indicating that the class could not be initialised and an error message is appended to the supplied string. If the class can be initialised from a string then this function should be overridden.
Reimplemented from casacore::RecordTransformable.
virtual const String& casacore::QuantumHolder::ident |
( |
|
) |
const [virtual] |
Bool casacore::QuantumHolder::isArray |
( |
|
) |
const |
Bool casacore::QuantumHolder::isComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isEmpty |
( |
|
) |
const |
Check if it holds a Quantity.
Note that a Vector of length 1 will give True to scalar questions.
Bool casacore::QuantumHolder::isQuantity |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantum |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumArrayComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumArrayDComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumArrayDouble |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumArrayFloat |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumArrayInt |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumDComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumDouble |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumFloat |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumInt |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumVectorComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumVectorDComplex |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumVectorDouble |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumVectorFloat |
( |
|
) |
const |
Bool casacore::QuantumHolder::isQuantumVectorInt |
( |
|
) |
const |
Bool casacore::QuantumHolder::isReal |
( |
|
) |
const |
Bool casacore::QuantumHolder::isScalar |
( |
|
) |
const |
Bool casacore::QuantumHolder::isVector |
( |
|
) |
const |
Int casacore::QuantumHolder::ndim |
( |
|
) |
const |
Int casacore::QuantumHolder::nelements |
( |
|
) |
const |
Get number of numeric elements (1 if scalar, else vector length) or dimensions (0 if scalar).
Thrown Exceptions
Assignment (copy semantics).
void casacore::QuantumHolder::toArray |
( |
|
) |
[private] |
void casacore::QuantumHolder::toComplex |
( |
const uInt & |
tp |
) |
[private] |
Convert to a different complex scalar quantum.
void casacore::QuantumHolder::toReal |
( |
const uInt & |
tp |
) |
[private] |
Convert to a different real scalar quantum.
virtual Record casacore::QuantumHolder::toRecord |
( |
|
) |
const [virtual] |
this version throws an exception or returns the result Record.
virtual void casacore::QuantumHolder::toRecord |
( |
RecordInterface & |
out |
) |
const [virtual] |
this version throws an exception rather than returning false
void casacore::QuantumHolder::toVector |
( |
|
) |
[private] |
Member Data Documentation
The documentation for this class was generated from the following file: