AttValBase.h

Classes

AttValue -- Provision of type identification services for Attribute classes. (full description)
AttributeValueBase -- Base class for values of Attributes used in the display classes. (full description)

class AttValue

Types

enum ValueType

AtuInt
AtInt
AtFloat
AtDouble
AtBool
AtString
AtQuantity
AtInvalid

Interface

Public Members
static AttValue::ValueType whatType(uInt *)
static AttValue::ValueType whatType(Vector<uInt> *)
static AttValue::ValueType whatType(Int *)
static AttValue::ValueType whatType(Vector<Int> *)
static AttValue::ValueType whatType(Float *)
static AttValue::ValueType whatType(Vector<Float> *)
static AttValue::ValueType whatType(Double *)
static AttValue::ValueType whatType(Vector<Double> *)
static AttValue::ValueType whatType(Bool *)
static AttValue::ValueType whatType(Vector<Bool> *)
static AttValue::ValueType whatType(String *)
static AttValue::ValueType whatType(Vector<String> *)
static AttValue::ValueType whatType(Quantity *)
static AttValue::ValueType whatType(Vector<Quantity> *)
static AttValue::ValueType whatType(void *)

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Tests:

Etymology

"AttValue" is a contraction of "Attribute Value"

Synopsis

AttValue provides type identification services for use in the Attribute classes.

Example

AttValue can be used to provide an enumeration which identifies the type of a variable, for example:
    Int i;
    if (AttValue::whatType(&i) != AttValue::AtInt) {
      throw(AipsError(String("Incorrect type identification in AttValue")));
    }
    

Motivation

This is a support class to unify type identification for the various Attribute classes.

To Do

Member Description

enum ValueType

The possible value types.

static AttValue::ValueType whatType(uInt *)
static AttValue::ValueType whatType(Vector<uInt> *)
static AttValue::ValueType whatType(Int *)
static AttValue::ValueType whatType(Vector<Int> *)
static AttValue::ValueType whatType(Float *)
static AttValue::ValueType whatType(Vector<Float> *)
static AttValue::ValueType whatType(Double *)
static AttValue::ValueType whatType(Vector<Double> *)
static AttValue::ValueType whatType(Bool *)
static AttValue::ValueType whatType(Vector<Bool> *)
static AttValue::ValueType whatType(String *)
static AttValue::ValueType whatType(Vector<String> *)
static AttValue::ValueType whatType(Quantity *)
static AttValue::ValueType whatType(Vector<Quantity> *)
static AttValue::ValueType whatType(void *)

Determine the type of a scalar or Array variable.

class AttributeValueBase

Interface

AttributeValueBase(AttValue::ValueType type, Bool strict)
AttributeValueBase(const AttributeValueBase &other)
virtual ~AttributeValueBase()
const AttributeValueBase& operator=(const AttributeValueBase &other)
AttValue::ValueType getType() const
Bool operator==(const AttributeValueBase &other) const
Bool operator!=(const AttributeValueBase &other) const
virtual AttributeValueBase* clone() const = 0
virtual void setStrictness(const Bool &newStrict)
virtual Bool getStrictness() const
virtual void operator+=(const AttributeValueBase& other) = 0
virtual String className() const
virtual void print(ostream& os) = 0
Protected Members
virtual Bool matches(const AttributeValueBase &other) const = 0
virtual void setType(const AttValue::ValueType &newType)
Bool myMatch(const AttributeValueBase &other) const

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Tests:
  • tAttribute

Etymology

"AttributeValueBase" is a concatenation, representing a "Base" class for "Attribute Values."

Synopsis

This class is the base for storing Attribute values. Attributes are simple name-value pairs, where the name is a String, and the value can be a scalar or Array.

This class defines the type-independent interface for Attribute values, and the type-dependent interface and implementation is provided in AttributeValue . This type independent interface allows comparison of Attributes of different types.

Motivation

To provide the non-templated (ie. type-independent) interface of AttributeValues in a single place, thus enabling the hiding of the templated aspect of Attributes from the end-user. In particular it allows implementation of the comparison operators in the base class, regardless of type.

To Do

Member Description

AttributeValueBase(AttValue::ValueType type, Bool strict)

Constructor.

AttributeValueBase(const AttributeValueBase &other)

Copy constructor.

virtual ~AttributeValueBase()

Destructor.

const AttributeValueBase& operator=(const AttributeValueBase &other)

Copy assignment.

AttValue::ValueType getType() const

Get the type of the value stored.

Bool operator==(const AttributeValueBase &other) const
Bool operator!=(const AttributeValueBase &other) const

Check for equality (and inequality) of two objects derived from AttributeValueBase. It is implemented in terms of the pure virtual method matches, which must be implemented in derived classes. The operator== only returns True if this->matches(other) and other.matches(*this) are both True. This guarantees that if a == b it follows that b == a (this is enforced this way because a and b can be classes derived differently from AttributeValueBase which can therefore have a different implementation of match()).

virtual AttributeValueBase* clone() const = 0

Return a new copy of the AttributeValueBase

virtual void setStrictness(const Bool &newStrict)
virtual Bool getStrictness() const

Set/get the strictness state of this AttributeValue.

virtual void operator+=(const AttributeValueBase& other) = 0

Add other to *this.

virtual String className() const

Return class name

virtual void print(ostream& os) = 0

virtual Bool matches(const AttributeValueBase &other) const = 0

Calculate whether *this matches other. Since the meaning of "match" can be different for different types, it is left to the derived class to define this method.

virtual void setType(const AttValue::ValueType &newType)

Set the type of the value stored.

Bool myMatch(const AttributeValueBase &other) const

Check that private data match