Loading...
Searching...
No Matches
casacore::ValueHolder Class Reference
casa package (libcasa_casa) » Containers_module

More...

`#include <ValueHolder.h>`

## 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 (gets type TpOther).
| ValueHolder (ValueHolderRep *rep)
| Create a ValueHolder from a ValueHolderRep.
| ValueHolder (const ValueHolder &)
| Copy constructor (reference semantics).
| ~ValueHolder ()
| Destructor.
ValueHolder & | operator= (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 String & | asString () const
const Array< Bool > | asArrayBool () const
const Array< uChar > | asArrayuChar () const
const Array< Short > | asArrayShort () const
const Array< uShort > | asArrayuShort () const
const Array< Int > | asArrayInt () const
const Array< uInt > | asArrayuInt () const
const Array< Int64 > | asArrayInt64 () const
const Array< Float > | asArrayFloat () const
const Array< Double > | asArrayDouble () const
const Array< Complex > | asArrayComplex () const
const Array< DComplex > | asArrayDComplex () const
const Array< String > | asArrayString () const
const Record & | asRecord () 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.
bool | operator< (const ValueHolder &right) const
| Compare two ValueHolder objects.

## Static Public Member Functions

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

## Private Attributes

std::shared_ptr< ValueHolderRep > | itsRep

## 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 Casacore data type.

### Intended use:

Public interface

### Review Status

Test programs:
  tValueHolder

### Synopsis

Class ValueHolder is meant to be used for holding a single Casacore 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 65 of file ValueHolder.h.

## Constructor & Destructor Documentation

## ValueHolder() [1/30]

casacore::ValueHolder::ValueHolder | ( |  | ) |

inline

Construct a null object.

Definition at line 69 of file ValueHolder.h.

Referenced by fromRecord(), operator<(), operator<<, operator=(), and ValueHolder().

## ValueHolder() [2/30]

casacore::ValueHolder::ValueHolder | ( | Bool | value | ) |

explicit

Create the object for the given value.

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [3/30]

casacore::ValueHolder::ValueHolder | ( | uChar | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [4/30]

casacore::ValueHolder::ValueHolder | ( | Short | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [5/30]

casacore::ValueHolder::ValueHolder | ( | uShort | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [6/30]

casacore::ValueHolder::ValueHolder | ( | Int | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [7/30]

casacore::ValueHolder::ValueHolder | ( | uInt | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [8/30]

casacore::ValueHolder::ValueHolder | ( | Int64 | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [9/30]

casacore::ValueHolder::ValueHolder | ( | Float | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [10/30]

casacore::ValueHolder::ValueHolder | ( | Double | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [11/30]

casacore::ValueHolder::ValueHolder | ( | const Complex & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [12/30]

casacore::ValueHolder::ValueHolder | ( | const DComplex & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [13/30]

casacore::ValueHolder::ValueHolder | ( | const Char * | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [14/30]

casacore::ValueHolder::ValueHolder | ( | const String & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [15/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Bool > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [16/30]

casacore::ValueHolder::ValueHolder | ( | const Array< uChar > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [17/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Short > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [18/30]

casacore::ValueHolder::ValueHolder | ( | const Array< uShort > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [19/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Int > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [20/30]

casacore::ValueHolder::ValueHolder | ( | const Array< uInt > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [21/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Int64 > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [22/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Float > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [23/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Double > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [24/30]

casacore::ValueHolder::ValueHolder | ( | const Array< Complex > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [25/30]

casacore::ValueHolder::ValueHolder | ( | const Array< DComplex > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [26/30]

casacore::ValueHolder::ValueHolder | ( | const Array< String > & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value.

## ValueHolder() [27/30]

casacore::ValueHolder::ValueHolder | ( | const Record & | value | ) |

explicit

References casacore::NewDelAllocator< T >::value, and casacore::Record().

## ValueHolder() [28/30]

casacore::ValueHolder::ValueHolder | ( | uInt | ndim,
|  | Bool | dummy )

Create an empty N-dim array (gets type TpOther).

References casacore::ndim().

## ValueHolder() [29/30]

casacore::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 107 of file ValueHolder.h.

References itsRep.

## ValueHolder() [30/30]

casacore::ValueHolder::ValueHolder | ( | const ValueHolder & |  | ) |

Copy constructor (reference semantics).

References ValueHolder().

## ~ValueHolder()

casacore::ValueHolder::~ValueHolder | ( |  | ) |

inline

Destructor.

Definition at line 115 of file ValueHolder.h.

## Member Function Documentation

## asArrayBool()

const Array< Bool > casacore::ValueHolder::asArrayBool | ( |  | ) | const

inline

Definition at line 253 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayComplex()

const Array< Complex > casacore::ValueHolder::asArrayComplex | ( |  | ) | const

inline

Definition at line 271 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayDComplex()

const Array< DComplex > casacore::ValueHolder::asArrayDComplex | ( |  | ) | const

inline

Definition at line 273 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayDouble()

const Array< Double > casacore::ValueHolder::asArrayDouble | ( |  | ) | const

inline

Definition at line 269 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayFloat()

const Array< Float > casacore::ValueHolder::asArrayFloat | ( |  | ) | const

inline

Definition at line 267 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayInt()

const Array< Int > casacore::ValueHolder::asArrayInt | ( |  | ) | const

inline

Definition at line 261 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayInt64()

const Array< Int64 > casacore::ValueHolder::asArrayInt64 | ( |  | ) | const

inline

Definition at line 265 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayShort()

const Array< Short > casacore::ValueHolder::asArrayShort | ( |  | ) | const

inline

Definition at line 257 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayString()

const Array< String > casacore::ValueHolder::asArrayString | ( |  | ) | const

inline

Definition at line 275 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayuChar()

const Array< uChar > casacore::ValueHolder::asArrayuChar | ( |  | ) | const

inline

Definition at line 255 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayuInt()

const Array< uInt > casacore::ValueHolder::asArrayuInt | ( |  | ) | const

inline

Definition at line 263 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asArrayuShort()

const Array< uShort > casacore::ValueHolder::asArrayuShort | ( |  | ) | const

inline

Definition at line 259 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asBool()

Bool casacore::ValueHolder::asBool | ( |  | ) | const

inline

Get the value.

If possible, it converts the data as needed.

Definition at line 229 of file ValueHolder.h.

References itsRep.

Referenced by getValue(), and casacore::python::numpy::ArrayCopy< DComplex >::toPy().

## asComplex()

Complex casacore::ValueHolder::asComplex | ( |  | ) | const

inline

Definition at line 247 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::getScalar(), and getValue().

## asDComplex()

DComplex casacore::ValueHolder::asDComplex | ( |  | ) | const

inline

Definition at line 249 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::getScalar(), and getValue().

## asDouble()

Double casacore::ValueHolder::asDouble | ( |  | ) | const

inline

Definition at line 245 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::getScalar(), and getValue().

## asFloat()

Float casacore::ValueHolder::asFloat | ( |  | ) | const

inline

Definition at line 243 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::getScalar(), and getValue().

## asInt()

Int casacore::ValueHolder::asInt | ( |  | ) | const

inline

Definition at line 237 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::ArrayCopyUnicode_toArray(), casacore::python::numpy::getScalar(), getValue(), and casacore::python::numpy::ArrayCopy< String >::toArray().

## asInt64()

Int64 casacore::ValueHolder::asInt64 | ( |  | ) | const

inline

Definition at line 241 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asRecord()

const Record & casacore::ValueHolder::asRecord | ( |  | ) | const

inline

Definition at line 277 of file ValueHolder.h.

References itsRep, and casacore::Record().

## asShort()

Short casacore::ValueHolder::asShort | ( |  | ) | const

inline

Definition at line 233 of file ValueHolder.h.

References itsRep.

Referenced by getValue(), and casacore::python::numpy::ArrayCopy< DComplex >::toArray().

## asString()

const String & casacore::ValueHolder::asString | ( |  | ) | const

inline

Definition at line 251 of file ValueHolder.h.

References itsRep.

Referenced by getValue().

## asuChar()

uChar casacore::ValueHolder::asuChar | ( |  | ) | const

inline

Definition at line 231 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::getScalar(), and getValue().

## asuInt()

uInt casacore::ValueHolder::asuInt | ( |  | ) | const

inline

Definition at line 239 of file ValueHolder.h.

References itsRep.

Referenced by casacore::python::numpy::ArrayCopyStr_toArray(), casacore::python::numpy::getScalar(), and getValue().

## asuShort()

uShort casacore::ValueHolder::asuShort | ( |  | ) | const

inline

Definition at line 235 of file ValueHolder.h.

References itsRep.

Referenced by getValue(), and casacore::python::numpy::ArrayCopy< String >::toPy().

## dataType()

DataType casacore::ValueHolder::dataType | ( |  | ) | const

inline

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

Note that TpOther is returned for an empty untyped array.

Definition at line 222 of file ValueHolder.h.

References itsRep.

## fromRecord()

ValueHolder casacore::ValueHolder::fromRecord | ( | const Record & | rec,
|  | const RecordFieldId & | id )

inline static

Construct the object from the value in a record.

Definition at line 226 of file ValueHolder.h.

References casacore::ValueHolderRep::fromRecord(), casacore::Record(), and ValueHolder().

## getValue() [1/24]

void casacore::ValueHolder::getValue | ( | Array< Bool > & | value | ) | const

inline

Definition at line 174 of file ValueHolder.h.

References asArrayBool(), and casacore::NewDelAllocator< T >::value.

## getValue() [2/24]

void casacore::ValueHolder::getValue | ( | Array< Complex > & | value | ) | const

inline

Definition at line 192 of file ValueHolder.h.

References asArrayComplex(), and casacore::NewDelAllocator< T >::value.

## getValue() [3/24]

void casacore::ValueHolder::getValue | ( | Array< DComplex > & | value | ) | const

inline

Definition at line 194 of file ValueHolder.h.

References asArrayDComplex(), and casacore::NewDelAllocator< T >::value.

## getValue() [4/24]

void casacore::ValueHolder::getValue | ( | Array< Double > & | value | ) | const

inline

Definition at line 190 of file ValueHolder.h.

References asArrayDouble(), and casacore::NewDelAllocator< T >::value.

## getValue() [5/24]

void casacore::ValueHolder::getValue | ( | Array< Float > & | value | ) | const

inline

Definition at line 188 of file ValueHolder.h.

References asArrayFloat(), and casacore::NewDelAllocator< T >::value.

## getValue() [6/24]

void casacore::ValueHolder::getValue | ( | Array< Int > & | value | ) | const

inline

Definition at line 182 of file ValueHolder.h.

References asArrayInt(), and casacore::NewDelAllocator< T >::value.

## getValue() [7/24]

void casacore::ValueHolder::getValue | ( | Array< Int64 > & | value | ) | const

inline

Definition at line 186 of file ValueHolder.h.

References asArrayInt64(), and casacore::NewDelAllocator< T >::value.

## getValue() [8/24]

void casacore::ValueHolder::getValue | ( | Array< Short > & | value | ) | const

inline

Definition at line 178 of file ValueHolder.h.

References asArrayShort(), and casacore::NewDelAllocator< T >::value.

## getValue() [9/24]

void casacore::ValueHolder::getValue | ( | Array< String > & | value | ) | const

inline

Definition at line 196 of file ValueHolder.h.

References asArrayString(), and casacore::NewDelAllocator< T >::value.

## getValue() [10/24]

void casacore::ValueHolder::getValue | ( | Array< uChar > & | value | ) | const

inline

Definition at line 176 of file ValueHolder.h.

References asArrayuChar(), and casacore::NewDelAllocator< T >::value.

## getValue() [11/24]

void casacore::ValueHolder::getValue | ( | Array< uInt > & | value | ) | const

inline

Definition at line 184 of file ValueHolder.h.

References asArrayuInt(), and casacore::NewDelAllocator< T >::value.

## getValue() [12/24]

void casacore::ValueHolder::getValue | ( | Array< uShort > & | value | ) | const

inline

Definition at line 180 of file ValueHolder.h.

References asArrayuShort(), and casacore::NewDelAllocator< T >::value.

## getValue() [13/24]

void casacore::ValueHolder::getValue | ( | Bool & | value | ) | const

inline

Get the data in a way useful for templates.

If possible, it converts the the data as needed.

Definition at line 162 of file ValueHolder.h.

References asBool(), and casacore::NewDelAllocator< T >::value.

## getValue() [14/24]

void casacore::ValueHolder::getValue | ( | Complex & | value | ) | const

inline

Definition at line 171 of file ValueHolder.h.

References asComplex(), and casacore::NewDelAllocator< T >::value.

## getValue() [15/24]

void casacore::ValueHolder::getValue | ( | DComplex & | value | ) | const

inline

Definition at line 172 of file ValueHolder.h.

References asDComplex(), and casacore::NewDelAllocator< T >::value.

## getValue() [16/24]

void casacore::ValueHolder::getValue | ( | Double & | value | ) | const

inline

Definition at line 170 of file ValueHolder.h.

References asDouble(), and casacore::NewDelAllocator< T >::value.

## getValue() [17/24]

void casacore::ValueHolder::getValue | ( | Float & | value | ) | const

inline

Definition at line 169 of file ValueHolder.h.

References asFloat(), and casacore::NewDelAllocator< T >::value.

## getValue() [18/24]

void casacore::ValueHolder::getValue | ( | Int & | value | ) | const

inline

Definition at line 166 of file ValueHolder.h.

References asInt(), and casacore::NewDelAllocator< T >::value.

## getValue() [19/24]

void casacore::ValueHolder::getValue | ( | Int64 & | value | ) | const

inline

Definition at line 168 of file ValueHolder.h.

References asInt64(), and casacore::NewDelAllocator< T >::value.

## getValue() [20/24]

void casacore::ValueHolder::getValue | ( | Short & | value | ) | const

inline

Definition at line 164 of file ValueHolder.h.

References asShort(), and casacore::NewDelAllocator< T >::value.

## getValue() [21/24]

void casacore::ValueHolder::getValue | ( | String & | value | ) | const

inline

Definition at line 173 of file ValueHolder.h.

References asString(), and casacore::NewDelAllocator< T >::value.

## getValue() [22/24]

void casacore::ValueHolder::getValue | ( | uChar & | value | ) | const

inline

Definition at line 163 of file ValueHolder.h.

References asuChar(), and casacore::NewDelAllocator< T >::value.

## getValue() [23/24]

void casacore::ValueHolder::getValue | ( | uInt & | value | ) | const

inline

Definition at line 167 of file ValueHolder.h.

References asuInt(), and casacore::NewDelAllocator< T >::value.

## getValue() [24/24]

void casacore::ValueHolder::getValue | ( | uShort & | value | ) | const

inline

Definition at line 165 of file ValueHolder.h.

References asuShort(), and casacore::NewDelAllocator< T >::value.

## isNull()

Bool casacore::ValueHolder::isNull | ( |  | ) | const

inline

Is this a null object?

Definition at line 122 of file ValueHolder.h.

References itsRep.

## operator<()

bool casacore::ValueHolder::operator< | ( | const ValueHolder & | right | ) | const

inline

Compare two ValueHolder objects.

They must have the same data type.

Definition at line 208 of file ValueHolder.h.

References itsRep, and ValueHolder().

## operator=()

ValueHolder & casacore::ValueHolder::operator= | ( | const ValueHolder & |  | ) |

Assignment (reference semantics).

References ValueHolder().

## toRecord()

void casacore::ValueHolder::toRecord | ( | Record & | rec,
|  | const RecordFieldId & | id ) const

inline

Put the value as a field in a record.

Definition at line 224 of file ValueHolder.h.

References itsRep, and casacore::Record().

## Friends And Related Symbol Documentation

## operator<<

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 213 of file ValueHolder.h.

References itsRep, and ValueHolder().

## Member Data Documentation

## itsRep

std::shared_ptr<ValueHolderRep> casacore::ValueHolder::itsRep

private

Definition at line 218 of file ValueHolder.h.

Referenced by asArrayBool(), asArrayComplex(), asArrayDComplex(), asArrayDouble(), asArrayFloat(), asArrayInt(), asArrayInt64(), asArrayShort(), asArrayString(), asArrayuChar(), asArrayuInt(), asArrayuShort(), asBool(), asComplex(), asDComplex(), asDouble(), asFloat(), asInt(), asInt64(), asRecord(), asShort(), asString(), asuChar(), asuInt(), asuShort(), dataType(), isNull(), operator<(), operator<<, toRecord(), and ValueHolder().

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

- casa/Containers/ValueHolder.h