next up previous
Next: Transforming Coordinates
Up: An AST Object Primer
Previous: Setting Attribute Values

Testing, Clearing and Defaulting Attributes  

You can use the astGetX family of functions ([*]) to get a value for any Object attribute at any time, regardless of whether a value has previously been set for it. If no value has been set, the AST library will generate a suitable default value.

Often, the default value of an attribute will not simply be trivial (zero or blank) but may involve considerable processing to calculate. Wherever possible, defaults are designed to be real-life, sensible values that convey information about the state of the Object. In particular, they may often be based on the values of other attributes, so their values may change in response to changes in these other attributes. The ZoomMap class that we have studied so far is a little too simple to show this behaviour, but we will meet it later on.

An attribute that returns a default value in this way is said to be un-set. Conversely, once an explicit value has been assigned to an attribute, it becomes set and will always return precisely that value, never a default.

The distinction between set and un-set attributes is important and affects the behaviour of several key routines in the AST library. You can test if an attribute is set using the function astTest, which returns a boolean (integer) result, as in:

if ( astTest( zoommap, "Report" ) ) {
   <the Report attribute is set>
}

Once an attribute is set, you can return it to its un-set state using astClear. The effect is as if it had never been set in the first place. For example:

astClear( zoommap, "Report" );

would ensure that the default value of the Report attribute is used subsequently.



next up previous
Next: Transforming Coordinates
Up: An AST Object Primer
Previous: Setting Attribute Values

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
30th April 2003
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2003 Central Laboratory of the Research Councils