Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1RecordTransformable.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 23:16:56 2011
Кодировка:

Поисковые слова: m 13
casacore: casa::RecordTransformable Class Reference
Public Member Functions

casa::RecordTransformable Class Reference
[Utilities_module]

Interface class for converting to/from records. More...

#include <RecordTransformable.h>

Inheritance diagram for casa::RecordTransformable:
casa::ComponentShape casa::FunctionHolder< T > casa::FunctionOrder< T > casa::ImageInfo casa::LSQMatrix casa::MeasureHolder casa::ObsInfo casa::QuantumHolder casa::SkyCompBase casa::SpectralElement casa::SpectralModel

List of all members.

Public Member Functions

virtual ~RecordTransformable ()
 The destructor must be virtual so that the destructor of derived classes is actually used.
virtual Bool toRecord (String &error, RecordInterface &outRecord) const =0
 Convert the class to an Record representation.
virtual Bool fromRecord (String &error, const RecordInterface &inRecord)=0
 Initialise the class from a Record representation.
virtual Bool fromString (String &error, const String &inString)
 Initialise the class from a String representation.
virtual const Stringident () const
 Specify the identification of the record (e.g.

Detailed Description

Interface class for converting to/from records.

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tRecordTransformable

Prerequisite

Etymology

This class defines the interface that a class should use if the can be transformed into a record representation.

Synopsis

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;

Example

The following example prints out a class using its record representation. This example is in the file tRecordTransformable.cc

    void printAsRecord(const RecordTransformable & myClass) {
      String errorMessage;
      Record rec;
      if (!myClass.toRecord(errorMessage, rec)) {
        cout << "Cannot convert class to a Record. The reason is:" << endl; 
        cout << errorMessage << endl;
      } else {
        cout << rec.ndefined() << endl;
      }
    }

Motivation

This class was designed to standardise the function interface for converting between an object and its record representation.

To Do

Definition at line 106 of file RecordTransformable.h.


Constructor & Destructor Documentation

virtual casa::RecordTransformable::~RecordTransformable (  )  [virtual]

The destructor must be virtual so that the destructor of derived classes is actually used.


Member Function Documentation

virtual Bool casa::RecordTransformable::fromRecord ( String error,
const RecordInterface inRecord 
) [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::QuantumHolder, casa::ComponentShape, casa::ConstantSpectrum, casa::PointShape, casa::SkyCompBase, casa::SkyComponent, casa::SkyCompRep, casa::SpectralIndex, casa::SpectralModel, casa::TwoSidedShape, casa::SpectralElement, casa::ObsInfo, casa::ImageInfo, casa::MeasureHolder, casa::LSQMatrix, casa::FunctionHolder< T >, casa::FunctionOrder< T >, casa::FunctionHolder< Double >, and casa::FunctionHolder< DComplex >.

virtual Bool casa::RecordTransformable::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 in casa::QuantumHolder, casa::SpectralElement, casa::MeasureHolder, casa::FunctionHolder< T >, casa::FunctionOrder< T >, casa::FunctionHolder< Double >, and casa::FunctionHolder< DComplex >.

virtual const String& casa::RecordTransformable::ident (  )  const [virtual]

Specify the identification of the record (e.g.

'meas', 'quant'). The default implementation returns a empty string.

Reimplemented in casa::QuantumHolder, casa::ComponentShape, casa::SpectralModel, casa::SpectralElement, casa::MeasureHolder, casa::LSQMatrix, casa::FunctionHolder< T >, casa::FunctionOrder< T >, casa::FunctionHolder< Double >, and casa::FunctionHolder< DComplex >.

virtual Bool casa::RecordTransformable::toRecord ( String error,
RecordInterface outRecord 
) const [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::QuantumHolder, casa::ComponentShape, casa::ConstantSpectrum, casa::PointShape, casa::SkyCompBase, casa::SkyComponent, casa::SkyCompRep, casa::SpectralIndex, casa::SpectralModel, casa::TwoSidedShape, casa::SpectralElement, casa::ObsInfo, casa::ImageInfo, casa::MeasureHolder, casa::LSQMatrix, casa::FunctionHolder< T >, casa::FunctionOrder< T >, casa::FunctionHolder< Double >, and casa::FunctionHolder< DComplex >.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines