casa
$Rev:20696$
|
Type-dependent interface for values of Attributes. More...
#include <AttVal.h>
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 AttributeValueBase * | clone () 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. |
Type-dependent interface for values of Attributes.
Public interface
An AttributeValue stores the value of an Attribute
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.
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
.
and Attribute .
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
).
casa::AttributeValue< T >::AttributeValue | ( | const Vector< T > & | value, |
const Bool | strict | ||
) |
virtual casa::AttributeValue< T >::~AttributeValue | ( | ) | [virtual] |
Destructor.
casa::AttributeValue< T >::AttributeValue | ( | const AttributeValue< T > & | other | ) |
Copy constructor.
casa::AttributeValue< T >::AttributeValue | ( | ) | [private] |
Default constructor.
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.
virtual AttributeValueBase* casa::AttributeValue< T >::clone | ( | ) | const [virtual] |
Returns a new copy of the AttributeValue.
Implements casa::AttributeValueBase.
Reimplemented in casa::AttributeValuePoi< T >, casa::AttributeValueTol< T >, and casa::AttributeValuePoiTol< 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.
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 >.
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 >.
Bool casa::AttributeValue< T >::myMatch | ( | const AttributeValue< T > & | other | ) | const [private] |
Do actual matching.
Reimplemented in casa::AttributeValueTol< 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 >.
const AttributeValue<T>& casa::AttributeValue< T >::operator= | ( | const AttributeValue< T > & | other | ) |
Assignment (copy semantics)
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.
void casa::AttributeValue< T >::setType | ( | ) | [private] |
Sett T type in base class.
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 >.
virtual void casa::AttributeValue< T >::setValue | ( | const Vector< T > & | value | ) | [virtual] |
Reimplemented in casa::AttributeValuePoi< T >, and casa::AttributeValuePoiTol< 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().