Occasionally, you may want to store a number of Objects and later
retrieve them and use each for a different purpose. If the Objects are
of the same class, you cannot use the Class attribute to distinguish
them when you read them back
(c.f. ). Although relying on the
order in which they are stored is a possible solution, this becomes
complicated if some of the Objects are optional and may not always be
present. It also makes extending your data format in future more
difficult.
To help with this, every AST Object has an ID attribute and an Ident attribute, both of which allows you, in effect, to attach a textual identification label to it. You simply set the ID or Ident attribute before writing the Object:
astSet( object, "ID=Calibration" ); nobj = astWrite( channel, object );
You can then test its value after you read the Object back:
object = astRead( channel ); if ( !strcmp( astGetC( object, "ID" ), "Calibration" ) ) { <the Calibration Object has been read> } else { <some other Object has been read> }
The only difference between the ID and Ident attributes is that the ID attribute is unique to a particular Object and is lost if, for example, you make a copy of the Object. The Ident attrubute, on the other hand, is transferred to the new Object when a copy is made. Consequently, it is safest to set the value of the ID attribute immediately before you perform the write.
AST A Library for Handling World Coordinate Systems in Astronomy