casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
casa::AttributeValue< T > Class Template Reference

Type-dependent interface for values of Attributes. More...

#include <AttVal.h>

Inheritance diagram for casa::AttributeValue< T >:
casa::AttributeValueBase casa::AttributeValuePoi< T > casa::AttributeValueTol< T > casa::AttributeValuePoiTol< T >

List of all members.

Public Member Functions

 AttributeValue (const T &value, const Bool strict)
 Construct from a scalar value.
 AttributeValue (const Vector< T > &value, const Bool strict)
 Construct from a Vector.
virtual ~AttributeValue ()
 Destructor.
 AttributeValue (const AttributeValue< T > &other)
 Copy constructor.
const AttributeValue< T > & operator= (const AttributeValue< T > &other)
 Assignment (copy semantics)
virtual void setValue (const T &value)
 Set/get the value of the AttributeValue.
virtual void setValue (const Vector< T > &value)
virtual Vector< T > getValue () const
virtual AttributeValueBaseclone () const
 Returns a new copy of the AttributeValue.
virtual void operator+= (const AttributeValueBase &other)
 Add other to *this.
virtual String className () const
 Return class name.
virtual void print (ostream &os)

Protected Member Functions

virtual Bool matches (const AttributeValueBase &other) const
 Implements when the values of two Attributes match or not.
const AttributeValue< T > & myCast (const AttributeValueBase &other) const
 Cast from Base class.

Private Member Functions

void setType ()
 Sett T type in base class.
Bool myMatch (const AttributeValue< T > &other) const
 Do actual matching.
 AttributeValue ()
 Default constructor.

Private Attributes

Vector< T > itsValue
 The attribute value.

Detailed Description

template<class T>
class casa::AttributeValue< T >

Type-dependent interface for values of Attributes.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd
Test programs:
tAttribute

Prerequisite

Etymology

An AttributeValue stores the value of an Attribute

Synopsis

An Attribute in the Display Library has a name and a value. In order to facilite easy use of Attributes in user code, the value of an Attribute has to be wrapped in a templated class, the AttributeValue, which itself is derived from a non-templated base class, AttributeValueBase . What is stored in the AttributeValue is a value and the type of that value. Only some types are supported; see AttributeValueBase for a list. The value is always stored as a Vector, even if the value used in the constructor is a single value. The operation needed for the AttributeValue is to be able to check whether it matches another AttributeValue. For two AttributeValues to match they must have the same value and be of the same type (with some tolerance, see below). AttributeValues of different types (through the base class AttributeValueBase), never match.

The parameter strict in some constructors defines whether matching has to be done for each element ( strict == True ), or whether AttributeValues match if any one element of one Vector is equal to any other element of the other Vector. An AttributeValue created with a scalar type can match an AttributeValue created with a Vector of that scalar type.

Example

A few simple examples of the use of the AttributeValue class follow.

    AttributeValue<Int> intAtt1(3, False);
    AttributeValue<Int> intAtt2(3, False);
    AttributeValue<Int> intAtt3(2, False);

At this point, intAtt1==intAtt2 will return True, and intAtt1==intAtt3 will return False.

    Vector<Int> vec(2);
    vec(0) = 1;
    vec(1) = 3;
    AttributeValue<Vector<Int> > vecAtt1(vec, False);

and now vecAtt1==intAtt1 is True, and vecAtt1==intAtt3 returns False.

Finally,

    AttributeValue<Vector<Int> > vecAtt2(vec, True);

gives False for vecAtt2==intAtt1, since they cannot match element wise because they have different lengths, and similarly vecAtt2==intAtt2 is also False.

Motivation

and Attribute .

Definition at line 119 of file AttVal.h.


Constructor & Destructor Documentation

template<class T>
casa::AttributeValue< T >::AttributeValue ( const T &  value,
const Bool  strict 
)

Construct from a scalar value.

The parameter strict defines whether whether matching has to be done for each element (strict == True) (a scalar value AttributeValue is considered a Vector of length one), or whether AttributeValues match if any one element of one Vector is equal to any other element of the other Vector (strict == False).

template<class T>
casa::AttributeValue< T >::AttributeValue ( const Vector< T > &  value,
const Bool  strict 
)

Construct from a Vector.

The parameter strict defines whether whether matching has to be done for each element (strict == True), or whether AttributeValues match if any one element of one Vector is equal to any other element of the other Vector (strict == False).

template<class T>
virtual casa::AttributeValue< T >::~AttributeValue ( ) [virtual]

Destructor.

template<class T>
casa::AttributeValue< T >::AttributeValue ( const AttributeValue< T > &  other)

Copy constructor.

template<class T>
casa::AttributeValue< T >::AttributeValue ( ) [private]

Default constructor.


Member Function Documentation

template<class T>
virtual String casa::AttributeValue< T >::className ( ) const [inline, virtual]

Return class name.

Reimplemented from casa::AttributeValueBase.

Reimplemented in casa::AttributeValuePoi< T >, casa::AttributeValueTol< T >, and casa::AttributeValuePoiTol< T >.

Definition at line 161 of file AttVal.h.

References String.

template<class T>
virtual AttributeValueBase* casa::AttributeValue< T >::clone ( ) const [virtual]
template<class T>
virtual Vector<T> casa::AttributeValue< T >::getValue ( void  ) const [inline, virtual]

Definition at line 151 of file AttVal.h.

References casa::AttributeValue< T >::itsValue.

template<class T>
virtual Bool casa::AttributeValue< T >::matches ( const AttributeValueBase other) const [protected, virtual]

Implements when the values of two Attributes match or not.

The state of strict determines whether whether matching has to be done for each element ( strict == True ), or whether AttributeValues match if any one element of one Vector is equal to any other element of the other Vector.

Implements casa::AttributeValueBase.

Reimplemented in casa::AttributeValueTol< T >.

template<class T>
const AttributeValue<T>& casa::AttributeValue< T >::myCast ( const AttributeValueBase other) const [protected]

Cast from Base class.

Reimplemented in casa::AttributeValuePoi< T >, and casa::AttributeValuePoiTol< T >.

template<class T>
Bool casa::AttributeValue< T >::myMatch ( const AttributeValue< T > &  other) const [private]

Do actual matching.

Reimplemented in casa::AttributeValueTol< T >.

template<class T>
virtual void casa::AttributeValue< T >::operator+= ( const AttributeValueBase other) [virtual]

Add other to *this.

Implements casa::AttributeValueBase.

Reimplemented in casa::AttributeValuePoi< T >, and casa::AttributeValuePoiTol< T >.

template<class T>
const AttributeValue<T>& casa::AttributeValue< T >::operator= ( const AttributeValue< T > &  other)

Assignment (copy semantics)

template<class T>
virtual void casa::AttributeValue< T >::print ( ostream &  os) [inline, virtual]

Implements casa::AttributeValueBase.

Definition at line 163 of file AttVal.h.

References casa::AttributeValue< T >::itsValue.

template<class T>
void casa::AttributeValue< T >::setType ( ) [private]

Sett T type in base class.

template<class T>
virtual void casa::AttributeValue< T >::setValue ( const T &  value) [virtual]

Set/get the value of the AttributeValue.

Reimplemented in casa::AttributeValuePoi< T >, and casa::AttributeValuePoiTol< T >.

template<class T>
virtual void casa::AttributeValue< T >::setValue ( const Vector< T > &  value) [virtual]

Member Data Documentation

template<class T>
Vector<T> casa::AttributeValue< T >::itsValue [private]

The attribute value.

Definition at line 179 of file AttVal.h.

Referenced by casa::AttributeValue< T >::getValue(), and casa::AttributeValue< T >::print().


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