casa
5.7.0-16
|
Interface class for converting to/from records. More...
#include <RecordTransformable.h>
Public Member Functions | |
virtual | ~RecordTransformable () |
The destructor must be virtual so that the destructor of derived classes is actually used. More... | |
virtual Bool | toRecord (String &error, RecordInterface &outRecord) const =0 |
Convert the class to an Record representation. More... | |
virtual Bool | fromRecord (String &error, const RecordInterface &inRecord)=0 |
Initialise the class from a Record representation. More... | |
virtual Bool | fromString (String &error, const String &inString) |
Initialise the class from a String representation. More... | |
virtual const String & | ident () const |
Specify the identification of the record (e.g. More... | |
Interface class for converting to/from records.
Public interface
This class defines the interface that a class should use if the can be transformed into a record representation.
This abstract base class is intended to be publicly inherited by classes that contain functions which can represent the object as a record (these functions should be called toRecord
and fromRecord
). Examples of records are:
This interface defines two functions that convert between a RecordInterface and the class that inherits these functions. These functions are often used to parse input that is beyond the programs control e.g. user input from glish or Table records that may have been generated elsewhere. Hence exceptions should not thrown be thrown by these functions. Instead the function should return False and append an error message to the supplied String when the transformation cannot be accomplished.
Warning: Converting to/from a GlishRecord requires an extra step; First a Record should be used which can thereafter be converted to/from a GlishRecord using the appropriate GlishRecord functions;
The following example prints out a class using its record representation. This example is in the file tRecordTransformable.cc
This class was designed to standardise the function interface for converting between an object and its record representation.
Definition at line 106 of file RecordTransformable.h.
|
virtual |
The destructor must be virtual so that the destructor of derived classes is actually used.
|
pure virtual |
Initialise the class from a Record representation.
The input record should contain the fields that are required by the class. Other fields will be ignored. If the transformation succeeds then the error String is unchanged and the function returns True. Otherwise the function returns False and appends an error message to the supplied String giving the reason why the conversion failed.
Implemented in casa::TwoSidedShape, casa::SkyCompBase, casa::SpectralIndex, casa::SkyCompRep, casa::ComponentShape, casa::PointShape, casa::SpectralModel, casa::SkyComponent, casa::TabularSpectrum, casacore::QuantumHolder, casacore::MeasureHolder, casa::ConstantSpectrum, casacore::LSQMatrix, casacore::ObsInfo, casacore::FunctionHolder< T >, casacore::FunctionHolder< Double >, casacore::FunctionHolder< DComplex >, casacore::ImageInfo, and casacore::FunctionOrder< T >.
|
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 in casacore::QuantumHolder, casacore::MeasureHolder, casacore::FunctionHolder< T >, casacore::FunctionHolder< Double >, casacore::FunctionHolder< DComplex >, and casacore::FunctionOrder< T >.
|
virtual |
Specify the identification of the record (e.g.
'meas', 'quant'). The default implementation returns a empty string.
Reimplemented in casacore::QuantumHolder, casacore::MeasureHolder, casacore::LSQMatrix, casacore::FunctionHolder< T >, casacore::FunctionHolder< Double >, casacore::FunctionHolder< DComplex >, casa::SpectralModel, casa::ComponentShape, and casacore::FunctionOrder< T >.
|
pure virtual |
Convert the class to an Record representation.
The input record may already contain fields and these fields may be silently overridden. New fields may be added to the input Record. If the transformation succeeds then the error String is unchanged and the function returns True. Otherwise the function returns False and appends an error message to the supplied String giving the reason why the conversion failed.
Implemented in casa::TwoSidedShape, casa::SkyCompBase, casa::SpectralIndex, casa::SkyCompRep, casa::ComponentShape, casa::PointShape, casa::SpectralModel, casa::SkyComponent, casa::TabularSpectrum, casacore::QuantumHolder, casacore::MeasureHolder, casa::ConstantSpectrum, casacore::LSQMatrix, casacore::FunctionHolder< T >, casacore::FunctionHolder< Double >, casacore::FunctionHolder< DComplex >, casacore::ObsInfo, casacore::ImageInfo, and casacore::FunctionOrder< T >.