casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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 >

Public Member Functions

 AttributeValue (const T &value, const casacore::Bool strict)
 Construct from a scalar value. More...
 
 AttributeValue (const casacore::Vector< T > &value, const casacore::Bool strict)
 Construct from a casacore::Vector. More...
 
virtual ~AttributeValue ()
 Destructor. More...
 
 AttributeValue (const AttributeValue< T > &other)
 Copy constructor. More...
 
const AttributeValue< T > & operator= (const AttributeValue< T > &other)
 Assignment (copy semantics) More...
 
virtual void setValue (const T &value)
 Set/get the value of the AttributeValue. More...
 
virtual void setValue (const casacore::Vector< T > &value)
 
virtual casacore::Vector< T > getValue () const
 
virtual AttributeValueBaseclone () const
 Returns a new copy of the AttributeValue. More...
 
virtual void operator+= (const AttributeValueBase &other)
 Add other to *this. More...
 
virtual casacore::String className () const
 Return class name. More...
 
virtual void print (std::ostream &os)
 
- Public Member Functions inherited from casa::AttributeValueBase
 AttributeValueBase (AttValue::ValueType type, casacore::Bool strict)
 Constructor. More...
 
 AttributeValueBase (const AttributeValueBase &other)
 Copy constructor. More...
 
virtual ~AttributeValueBase ()
 Destructor. More...
 
const AttributeValueBaseoperator= (const AttributeValueBase &other)
 Copy assignment. More...
 
AttValue::ValueType getType () const
 Get the type of the value stored. More...
 
casacore::Bool operator== (const AttributeValueBase &other) const
 Check for equality (and inequality) of two objects derived from AttributeValueBase. More...
 
casacore::Bool operator!= (const AttributeValueBase &other) const
 
virtual void setStrictness (const casacore::Bool &newStrict)
 Set/get the strictness state of this AttributeValue. More...
 
virtual casacore::Bool getStrictness () const
 

Protected Member Functions

virtual casacore::Bool matches (const AttributeValueBase &other) const
 Implements when the values of two Attributes match or not. More...
 
const AttributeValue< T > & myCast (const AttributeValueBase &other) const
 Cast from Base class. More...
 
- Protected Member Functions inherited from casa::AttributeValueBase
virtual void setType (const AttValue::ValueType &newType)
 Set the type of the value stored. More...
 
casacore::Bool myMatch (const AttributeValueBase &other) const
 Check that private data match. More...
 

Private Member Functions

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

Private Attributes

casacore::Vector< T > itsValue
 The attribute value. More...
 

Additional Inherited Members

- Protected Attributes inherited from casa::AttributeValueBase
AttValue::ValueType itsValueType
 The type of what is stored. More...
 
casacore::Bool itsStrictness
 Whether the match is strict or not. More...
 

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 casacore::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 casacore::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 casacore::Vector of that scalar type.

Example

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

AttributeValue<casacore::Int> intAtt1(3, false);
AttributeValue<casacore::Int> intAtt2(3, false);
AttributeValue<casacore::Int> intAtt3(2, false);

At this point, intAtt1==intAtt2 will return true, and intAtt1==intAtt3 will return false.

vec(0) = 1;
vec(1) = 3;
AttributeValue<casacore::Vector<casacore::Int> > vecAtt1(vec, false);

and now vecAtt1==intAtt1 is true, and vecAtt1==intAtt3 returns false.

Finally,

AttributeValue<casacore::Vector<casacore::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 casacore::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 casacore::Vector of length one), or whether AttributeValues match if any one element of one casacore::Vector is equal to any other element of the other casacore::Vector (strict == false).

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

Construct from a casacore::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 casacore::Vector is equal to any other element of the other casacore::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 casacore::String casa::AttributeValue< T >::className ( ) const
inlinevirtual

Return class name.

Reimplemented from casa::AttributeValueBase.

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

Definition at line 163 of file AttVal.h.

template<class T>
virtual AttributeValueBase* casa::AttributeValue< T >::clone ( ) const
virtual
template<class T>
virtual casacore::Vector<T> casa::AttributeValue< T >::getValue ( ) const
inlinevirtual

Definition at line 151 of file AttVal.h.

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

template<class T>
virtual casacore::Bool casa::AttributeValue< T >::matches ( const AttributeValueBase other) const
protectedvirtual

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 casacore::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.

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

Do actual matching.

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 ( std::ostream &  os)
inlinevirtual

Implements casa::AttributeValueBase.

Definition at line 167 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 casacore::Vector< T > &  value)
virtual

Member Data Documentation

template<class T>
casacore::Vector<T> casa::AttributeValue< T >::itsValue
private

The attribute value.

Definition at line 185 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: