casa
5.7.0-16
|
Arbitrary name-value pairs used in the display classes. More...
#include <Attribute.h>
Public Member Functions | |
Attribute (const casacore::String &name, const AttributeValueBase &value) | |
Constructor taking an AttributeValueBase. More... | |
Attribute (const Attribute &other) | |
Copy constructor. More... | |
Attribute (const casacore::String &name, const casacore::uInt value, const casacore::uInt tolerance=0, const casacore::Bool strict=false) | |
Constructors that take a single value. More... | |
Attribute (const casacore::String &name, const casacore::Int value, const casacore::Int tolerance=0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Float value, const casacore::Float tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Double value, const casacore::Double tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Quantity value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Quantity value, const casacore::Quantity tolerance, casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Bool value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::String value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::uInt > value, const casacore::uInt tolerance=0, const casacore::Bool strict=false) | |
Contructors that take a casacore::Vector of the various types. More... | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Int > value, const casacore::Int tolerance=0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Float > value, const casacore::Float tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Double > value, const casacore::Double tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Quantity > value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Quantity > value, const casacore::Quantity tolerance, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::Bool > value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, const casacore::Vector< casacore::String > value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::uInt *value, const casacore::uInt tolerance=0, const casacore::Bool strict=false) | |
Constructors that take a pointer to a variable. More... | |
Attribute (const casacore::String &name, casacore::Int *value, const casacore::Int tolerance=0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Float *value, const casacore::Float tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Double *value, const casacore::Double tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Bool *value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::String *value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Quantity *value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Quantity *value, const casacore::Quantity tolerance, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::uInt > *value, const casacore::uInt tolerance=0, const casacore::Bool strict=false) | |
Constructors that take a pointer to a Vector. More... | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Int > *value, const casacore::Int tolerance=0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Float > *value, const casacore::Float tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Double > *value, const casacore::Double tolerance=0.0, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Quantity > *value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Quantity > *value, const casacore::Quantity tolerance, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::Bool > *value, const casacore::Bool strict=false) | |
Attribute (const casacore::String &name, casacore::Vector< casacore::String > *value, const casacore::Bool strict=false) | |
virtual | ~Attribute () |
Destructor. More... | |
virtual Attribute * | clone () const |
Create a new copy of the Attribute and return a pointer to the copy (virtual constructor). More... | |
virtual casacore::Bool | operator== (const Attribute &other) const |
Attribute matching: returns true if *this and other match, otherwise returns false . More... | |
casacore::Bool | operator!= (const Attribute &other) const |
The opposite of the Attribute matching. More... | |
virtual void | operator+= (const Attribute &other) |
Attribute addition... More... | |
virtual void | setValue (const Attribute &other) |
Set the value of this Attribute to that of the other Attribute, if, and only if, they have the same value type; <note role="caution"> This method makes an important assumption, namely that all AttributeValues that return AttValue::AtInt, AttValue::AtFloat or AttValue::AtDouble are derived from AttributeValueTol and that return AttValue::AtBool, AttValue::AtString or AttValue::AtQuantity are derived from AttributeValue (ie they are like they are created by Attribute); This is ok for *this , but there is no guarantee that it is correct for other ; This assumption was not needed until the AttributeValuePoi class was written; AttributeValues were not supposed to change but were supposed to be replaced; Now this is very ugly and should be rewritten; Indeed, it fails now for Quantities, since both with and without tols are used at the moment; More... | |
AttributeValueBase * | getAttributeValue () const |
Returns a pointer to the AttributeValue base class object. More... | |
casacore::String | getName () const |
Return the name of the Attribute. More... | |
AttValue::ValueType | getType () const |
Return the DataType of the value of the Attribute. More... | |
Private Member Functions | |
Attribute () | |
(Required) default constructor. More... | |
virtual const Attribute & | operator= (const Attribute &other) |
Copy assignment; Caution: This allows the type of the AttributeValue to change, so it is private; More... | |
Private Attributes | |
casacore::String | itsAttributeName |
The name of the Attribute. More... | |
AttributeValueBase * | itsAttributeValue |
Pointer to the attribute base class. More... | |
Arbitrary name-value pairs used in the display classes.
Public interface
An Attribute characterises something by associating a value with a name.
An Attribute is the combination of a name and a value. The name is a casacore::String, while the value can be of any of the types casacore::Int, casacore::Float, casacore::Double, casacore::Bool, casacore::String or Quantum, or a Vector of any of these types.
Attributes can be compared to see if they match. They can also be made "fuzzy" by providing a user-specified tolerance, and then matching means abs(val1-val2) <= tol
. An Attribute can also be "strict" if required: if so, then Attributes with Vector values are deemed to match if their values match element-wise. Otherwise, the Attributes match if any one element in one Attribute's value matches any one element in the other Attribute's value. In the latter case, the Attribute casacore::Vector values do not have to be conformant.
The following example shows the construction and retrieval of an Attribute.
The following example uses the Attribute equality operator to determine some state.
A more complete example, exhibiting the Attribute interface to a specific display class, the WorldCanvas, follows.
The main motivation for introducing Attributes is to be able to attach arbitrary name-value pairs to various objects in the display classes. This allows the storage, retrieval and comparison of arbitrary information from the various display objects.
setValue
function. Definition at line 144 of file Attribute.h.
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const AttributeValueBase & | value | ||
) |
Constructor taking an AttributeValueBase.
By inheriting from AttributeValueBase, additional types of Attributes can be supported.
casa::Attribute::Attribute | ( | const Attribute & | other | ) |
Copy constructor.
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::uInt | value, | ||
const casacore::uInt | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
Constructors that take a single value.
The value stored in an Attribute can be made fuzzy by giving some tolerance tol
, and when the values can be compared to see if they match, the tolerance is taken into account where it makes sense. The parameter strict
determines how the matching is done for the values. If strict == true
, the values have to match elementwise (a single value is considered a casacore::Vector of length 1). If strict == false
, the values match if any one element in one value matches any one elemnt in the other value.
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Int | value, | ||
const casacore::Int | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Float | value, | ||
const casacore::Float | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Double | value, | ||
const casacore::Double | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Quantity | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Quantity | value, | ||
const casacore::Quantity | tolerance, | ||
casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Bool | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::String | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::uInt > | value, | ||
const casacore::uInt | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
Contructors that take a casacore::Vector
of the various types.
Once again, the value stored in an Attribute can be made fuzzy by specifying tol
or strict by putting strict = true
.
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Int > | value, | ||
const casacore::Int | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Float > | value, | ||
const casacore::Float | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Double > | value, | ||
const casacore::Double | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Quantity > | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Quantity > | value, | ||
const casacore::Quantity | tolerance, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::Bool > | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
const casacore::Vector< casacore::String > | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::uInt * | value, | ||
const casacore::uInt | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Int * | value, | ||
const casacore::Int | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Float * | value, | ||
const casacore::Float | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Double * | value, | ||
const casacore::Double | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Bool * | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::String * | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Quantity * | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Quantity * | value, | ||
const casacore::Quantity | tolerance, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::uInt > * | value, | ||
const casacore::uInt | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
Constructors that take a pointer to a Vector.
This again makes the Attribute an alias for the casacore::Vector: changing the Vector changes the value of the Attribute, and vice versa. Other functionality is the same as for the non-aliasing constructors.
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Int > * | value, | ||
const casacore::Int | tolerance = 0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Float > * | value, | ||
const casacore::Float | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Double > * | value, | ||
const casacore::Double | tolerance = 0.0 , |
||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Quantity > * | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Quantity > * | value, | ||
const casacore::Quantity | tolerance, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::Bool > * | value, | ||
const casacore::Bool | strict = false |
||
) |
casa::Attribute::Attribute | ( | const casacore::String & | name, |
casacore::Vector< casacore::String > * | value, | ||
const casacore::Bool | strict = false |
||
) |
|
virtual |
Destructor.
|
private |
(Required) default constructor.
|
virtual |
Create a new copy of the Attribute and return a pointer to the copy (virtual constructor).
AttributeValueBase* casa::Attribute::getAttributeValue | ( | ) | const |
Returns a pointer to the AttributeValue base class object.
You must cast it to AttributeValue<T> and invoke function getValue
to get the value of the attribute
casacore::String casa::Attribute::getName | ( | ) | const |
Return the name of the Attribute.
Referenced by casa::WorldCanvasHolder::setRestriction().
AttValue::ValueType casa::Attribute::getType | ( | ) | const |
Return the DataType of the value of the Attribute.
Referenced by casa::WorldCanvasHolder::setRestriction().
casacore::Bool casa::Attribute::operator!= | ( | const Attribute & | other | ) | const |
The opposite of the Attribute matching.
|
virtual |
Attribute addition...
add the value of other
to the value of *this
.
Copy assignment;
Caution: This allows the type of the AttributeValue to change, so it is private;
|
virtual |
Attribute matching: returns true
if *this
and other
match, otherwise returns false
.
Caution: Two Attributes match if their names are different; If two Attributes have the same name, but the values stored in the Attributes have different types, they do not match; An Attribute of a single value and an Attribute of a casacore::Vector of values of the same type are considered to have the same type, so under certain circumstances (based on the strictness of the Attributes) two such Attributes may match;
|
virtual |
Set the value of this Attribute to that of the other
Attribute, if, and only if, they have the same value type; <note role="caution"> This method makes an important assumption, namely that all AttributeValues that return AttValue::AtInt, AttValue::AtFloat or AttValue::AtDouble are derived from AttributeValueTol and that return AttValue::AtBool, AttValue::AtString or AttValue::AtQuantity are derived from AttributeValue (ie they are like they are created by Attribute); This is ok for *this
, but there is no guarantee that it is correct for other
; This assumption was not needed until the AttributeValuePoi class was written; AttributeValues were not supposed to change but were supposed to be replaced; Now this is very ugly and should be rewritten; Indeed, it fails now for Quantities, since both with and without tols are used at the moment;
|
private |
The name of the Attribute.
Definition at line 310 of file Attribute.h.
|
private |
Pointer to the attribute base class.
Definition at line 313 of file Attribute.h.