casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Attributes | Friends
casa::ValueHolder Class Reference

A holder for a value of any basic AIPS++ data type. More...

#include <ValueHolder.h>

List of all members.

Public Member Functions

 ValueHolder ()
 Construct a null object.
 ValueHolder (Bool value)
 Create the object for the given value.
 ValueHolder (uChar value)
 ValueHolder (Short value)
 ValueHolder (uShort value)
 ValueHolder (Int value)
 ValueHolder (uInt value)
 ValueHolder (Int64 value)
 ValueHolder (Float value)
 ValueHolder (Double value)
 ValueHolder (const Complex &value)
 ValueHolder (const DComplex &value)
 ValueHolder (const Char *value)
 ValueHolder (const String &value)
 ValueHolder (const Array< Bool > &value)
 ValueHolder (const Array< uChar > &value)
 ValueHolder (const Array< Short > &value)
 ValueHolder (const Array< uShort > &value)
 ValueHolder (const Array< Int > &value)
 ValueHolder (const Array< uInt > &value)
 ValueHolder (const Array< Int64 > &value)
 ValueHolder (const Array< Float > &value)
 ValueHolder (const Array< Double > &value)
 ValueHolder (const Array< Complex > &value)
 ValueHolder (const Array< DComplex > &value)
 ValueHolder (const Array< String > &value)
 ValueHolder (const Record &value)
 ValueHolder (uInt ndim, Bool dummy)
 Create an empty N-dim array.
 ValueHolder (ValueHolderRep *rep)
 Create a ValueHolder from a ValueHolderRep.
 ValueHolder (const ValueHolder &)
 Copy constructor (reference semantics).
 ~ValueHolder ()
 Destructor.
ValueHolderoperator= (const ValueHolder &)
 Assignment (reference semantics).
Bool isNull () const
 Is this a null object?
DataType dataType () const
 Get the data type (as defined in DataType.h).
Bool asBool () const
 Get the value.
uChar asuChar () const
Short asShort () const
uShort asuShort () const
Int asInt () const
uInt asuInt () const
Int64 asInt64 () const
Float asFloat () const
Double asDouble () const
Complex asComplex () const
DComplex asDComplex () const
const StringasString () const
const Array< BoolasArrayBool () const
const Array< uCharasArrayuChar () const
const Array< ShortasArrayShort () const
const Array< uShortasArrayuShort () const
const Array< IntasArrayInt () const
const Array< uIntasArrayuInt () const
const Array< Int64asArrayInt64 () const
const Array< FloatasArrayFloat () const
const Array< DoubleasArrayDouble () const
const Array< Complex > asArrayComplex () const
const Array< DComplex > asArrayDComplex () const
const Array< StringasArrayString () const
const RecordasRecord () const
void getValue (Bool &value) const
 Get the data in a way useful for templates.
void getValue (uChar &value) const
void getValue (Short &value) const
void getValue (uShort &value) const
void getValue (Int &value) const
void getValue (uInt &value) const
void getValue (Int64 &value) const
void getValue (Float &value) const
void getValue (Double &value) const
void getValue (Complex &value) const
void getValue (DComplex &value) const
void getValue (String &value) const
void getValue (Array< Bool > &value) const
void getValue (Array< uChar > &value) const
void getValue (Array< Short > &value) const
void getValue (Array< uShort > &value) const
void getValue (Array< Int > &value) const
void getValue (Array< uInt > &value) const
void getValue (Array< Int64 > &value) const
void getValue (Array< Float > &value) const
void getValue (Array< Double > &value) const
void getValue (Array< Complex > &value) const
void getValue (Array< DComplex > &value) const
void getValue (Array< String > &value) const
void toRecord (Record &, const RecordFieldId &) const
 Put the value as a field in a record.

Static Public Member Functions

static ValueHolder fromRecord (const Record &, const RecordFieldId &)
 Construct the object from the value in a record.

Private Attributes

CountedPtr< ValueHolderRepitsRep

Friends

std::ostream & operator<< (std::ostream &os, const ValueHolder &vh)
 Write the ValueHolder to an output stream.

Detailed Description

A holder for a value of any basic AIPS++ data type.

Intended use:

Public interface

Review Status

Test programs:
tValueHolder

Synopsis

Class ValueHolder is meant to be used for holding a single AIPS++ value. The value can be scalar or an array of any basic type (including complex and string). Also a Record value is possible. In this way varying typed data (e.g. the result of getCell in the table DO) can be packed in a strongly typed variable.
All unsigned integer type values are kept as signed 32-bit integers because scripting languages usually only support those types.

ValueHolder is an envelope class that holds a counted-referenced letter object ValueHolderRep .

Motivation

This class comes handy in passing arbitrary values from a DO to its environment.

Definition at line 66 of file ValueHolder.h.


Constructor & Destructor Documentation

Construct a null object.

Definition at line 70 of file ValueHolder.h.

Referenced by fromRecord().

casa::ValueHolder::ValueHolder ( Bool  value) [explicit]

Create the object for the given value.

casa::ValueHolder::ValueHolder ( uChar  value) [explicit]
casa::ValueHolder::ValueHolder ( Short  value) [explicit]
casa::ValueHolder::ValueHolder ( uShort  value) [explicit]
casa::ValueHolder::ValueHolder ( Int  value) [explicit]
casa::ValueHolder::ValueHolder ( uInt  value) [explicit]
casa::ValueHolder::ValueHolder ( Int64  value) [explicit]
casa::ValueHolder::ValueHolder ( Float  value) [explicit]
casa::ValueHolder::ValueHolder ( Double  value) [explicit]
casa::ValueHolder::ValueHolder ( const Complex &  value) [explicit]
casa::ValueHolder::ValueHolder ( const DComplex &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Char value) [explicit]
casa::ValueHolder::ValueHolder ( const String value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Bool > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< uChar > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Short > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< uShort > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Int > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< uInt > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Int64 > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Float > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Double > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< Complex > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< DComplex > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Array< String > &  value) [explicit]
casa::ValueHolder::ValueHolder ( const Record value) [explicit]
casa::ValueHolder::ValueHolder ( uInt  ndim,
Bool  dummy 
)

Create an empty N-dim array.

casa::ValueHolder::ValueHolder ( ValueHolderRep rep) [inline, explicit]

Create a ValueHolder from a ValueHolderRep.

It takes over the pointer and deletes it in the destructor.

Definition at line 109 of file ValueHolder.h.

Copy constructor (reference semantics).

Destructor.

Definition at line 117 of file ValueHolder.h.


Member Function Documentation

const Array< Bool > casa::ValueHolder::asArrayBool ( ) const [inline]

Definition at line 248 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayBool(), and itsRep.

Referenced by getValue().

const Array< Complex > casa::ValueHolder::asArrayComplex ( ) const [inline]

Definition at line 266 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayComplex(), and itsRep.

Referenced by getValue().

const Array< DComplex > casa::ValueHolder::asArrayDComplex ( ) const [inline]

Definition at line 268 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayDComplex(), and itsRep.

Referenced by getValue().

const Array< Double > casa::ValueHolder::asArrayDouble ( ) const [inline]

Definition at line 264 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayDouble(), and itsRep.

Referenced by getValue().

const Array< Float > casa::ValueHolder::asArrayFloat ( ) const [inline]

Definition at line 262 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayFloat(), and itsRep.

Referenced by getValue().

const Array< Int > casa::ValueHolder::asArrayInt ( ) const [inline]

Definition at line 256 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayInt(), and itsRep.

Referenced by getValue().

const Array< Int64 > casa::ValueHolder::asArrayInt64 ( ) const [inline]

Definition at line 260 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayInt64(), and itsRep.

Referenced by getValue().

const Array< Short > casa::ValueHolder::asArrayShort ( ) const [inline]

Definition at line 252 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayShort(), and itsRep.

Referenced by getValue().

const Array< String > casa::ValueHolder::asArrayString ( ) const [inline]

Definition at line 270 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayString(), and itsRep.

Referenced by getValue().

const Array< uChar > casa::ValueHolder::asArrayuChar ( ) const [inline]

Definition at line 250 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayuChar(), and itsRep.

Referenced by getValue().

const Array< uInt > casa::ValueHolder::asArrayuInt ( ) const [inline]

Definition at line 258 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayuInt(), and itsRep.

Referenced by getValue().

const Array< uShort > casa::ValueHolder::asArrayuShort ( ) const [inline]

Definition at line 254 of file ValueHolder.h.

References casa::ValueHolderRep::asArrayuShort(), and itsRep.

Referenced by getValue().

Bool casa::ValueHolder::asBool ( ) const [inline]

Get the value.

It throws an exception if the data type is incorrect.

Definition at line 224 of file ValueHolder.h.

References casa::ValueHolderRep::asBool(), and itsRep.

Referenced by getValue().

Complex casa::ValueHolder::asComplex ( ) const [inline]

Definition at line 242 of file ValueHolder.h.

References casa::ValueHolderRep::asComplex(), and itsRep.

Referenced by getValue().

DComplex casa::ValueHolder::asDComplex ( ) const [inline]

Definition at line 244 of file ValueHolder.h.

References casa::ValueHolderRep::asDComplex(), and itsRep.

Referenced by getValue().

Double casa::ValueHolder::asDouble ( ) const [inline]

Definition at line 240 of file ValueHolder.h.

References casa::ValueHolderRep::asDouble(), and itsRep.

Referenced by getValue().

Float casa::ValueHolder::asFloat ( ) const [inline]

Definition at line 238 of file ValueHolder.h.

References casa::ValueHolderRep::asFloat(), and itsRep.

Referenced by getValue().

Int casa::ValueHolder::asInt ( ) const [inline]

Definition at line 232 of file ValueHolder.h.

References casa::ValueHolderRep::asInt(), and itsRep.

Referenced by getValue().

Int64 casa::ValueHolder::asInt64 ( ) const [inline]

Definition at line 236 of file ValueHolder.h.

References casa::ValueHolderRep::asInt64(), and itsRep.

Referenced by getValue().

const Record & casa::ValueHolder::asRecord ( ) const [inline]

Definition at line 272 of file ValueHolder.h.

References casa::ValueHolderRep::asRecord(), and itsRep.

Short casa::ValueHolder::asShort ( ) const [inline]

Definition at line 228 of file ValueHolder.h.

References casa::ValueHolderRep::asShort(), and itsRep.

Referenced by getValue().

const String & casa::ValueHolder::asString ( ) const [inline]

Definition at line 246 of file ValueHolder.h.

References casa::ValueHolderRep::asString(), and itsRep.

Referenced by getValue().

uChar casa::ValueHolder::asuChar ( ) const [inline]

Definition at line 226 of file ValueHolder.h.

References casa::ValueHolderRep::asuChar(), and itsRep.

Referenced by getValue().

uInt casa::ValueHolder::asuInt ( ) const [inline]

Definition at line 234 of file ValueHolder.h.

References casa::ValueHolderRep::asuInt(), and itsRep.

Referenced by getValue().

uShort casa::ValueHolder::asuShort ( ) const [inline]

Definition at line 230 of file ValueHolder.h.

References casa::ValueHolderRep::asuShort(), and itsRep.

Referenced by getValue().

DataType casa::ValueHolder::dataType ( ) const [inline]

Get the data type (as defined in DataType.h).

Definition at line 217 of file ValueHolder.h.

References casa::ValueHolderRep::dataType(), and itsRep.

ValueHolder casa::ValueHolder::fromRecord ( const Record rec,
const RecordFieldId id 
) [inline, static]

Construct the object from the value in a record.

Definition at line 221 of file ValueHolder.h.

References casa::ValueHolderRep::fromRecord(), and ValueHolder().

void casa::ValueHolder::getValue ( Bool value) const [inline]

Get the data in a way useful for templates.

Definition at line 162 of file ValueHolder.h.

References asBool().

void casa::ValueHolder::getValue ( uChar value) const [inline]

Definition at line 163 of file ValueHolder.h.

References asuChar().

void casa::ValueHolder::getValue ( Short value) const [inline]

Definition at line 164 of file ValueHolder.h.

References asShort().

void casa::ValueHolder::getValue ( uShort value) const [inline]

Definition at line 165 of file ValueHolder.h.

References asuShort().

void casa::ValueHolder::getValue ( Int value) const [inline]

Definition at line 166 of file ValueHolder.h.

References asInt().

void casa::ValueHolder::getValue ( uInt value) const [inline]

Definition at line 167 of file ValueHolder.h.

References asuInt().

void casa::ValueHolder::getValue ( Int64 value) const [inline]

Definition at line 168 of file ValueHolder.h.

References asInt64().

void casa::ValueHolder::getValue ( Float value) const [inline]

Definition at line 169 of file ValueHolder.h.

References asFloat().

void casa::ValueHolder::getValue ( Double value) const [inline]

Definition at line 170 of file ValueHolder.h.

References asDouble().

void casa::ValueHolder::getValue ( Complex &  value) const [inline]

Definition at line 171 of file ValueHolder.h.

References asComplex().

void casa::ValueHolder::getValue ( DComplex &  value) const [inline]

Definition at line 172 of file ValueHolder.h.

References asDComplex().

void casa::ValueHolder::getValue ( String value) const [inline]

Definition at line 173 of file ValueHolder.h.

References asString().

void casa::ValueHolder::getValue ( Array< Bool > &  value) const [inline]

Definition at line 174 of file ValueHolder.h.

References asArrayBool(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< uChar > &  value) const [inline]

Definition at line 176 of file ValueHolder.h.

References asArrayuChar(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Short > &  value) const [inline]

Definition at line 178 of file ValueHolder.h.

References asArrayShort(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< uShort > &  value) const [inline]

Definition at line 180 of file ValueHolder.h.

References asArrayuShort(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Int > &  value) const [inline]

Definition at line 182 of file ValueHolder.h.

References asArrayInt(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< uInt > &  value) const [inline]

Definition at line 184 of file ValueHolder.h.

References asArrayuInt(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Int64 > &  value) const [inline]

Definition at line 186 of file ValueHolder.h.

References asArrayInt64(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Float > &  value) const [inline]

Definition at line 188 of file ValueHolder.h.

References asArrayFloat(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Double > &  value) const [inline]

Definition at line 190 of file ValueHolder.h.

References asArrayDouble(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< Complex > &  value) const [inline]

Definition at line 192 of file ValueHolder.h.

References asArrayComplex(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< DComplex > &  value) const [inline]

Definition at line 194 of file ValueHolder.h.

References asArrayDComplex(), and casa::Array< T >::reference().

void casa::ValueHolder::getValue ( Array< String > &  value) const [inline]

Definition at line 196 of file ValueHolder.h.

References asArrayString(), and casa::Array< T >::reference().

Bool casa::ValueHolder::isNull ( ) const [inline]

Is this a null object?

Definition at line 124 of file ValueHolder.h.

References itsRep, and casa::SimpleCountedConstPtr< t >::null().

ValueHolder& casa::ValueHolder::operator= ( const ValueHolder )

Assignment (reference semantics).

void casa::ValueHolder::toRecord ( Record rec,
const RecordFieldId id 
) const [inline]

Put the value as a field in a record.

Definition at line 219 of file ValueHolder.h.

References itsRep, and casa::ValueHolderRep::toRecord().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ValueHolder vh 
) [friend]

Write the ValueHolder to an output stream.

Arrays are written as normal arrays using ArrayIO.h.

Definition at line 208 of file ValueHolder.h.


Member Data Documentation


The documentation for this class was generated from the following file: