next up previous 264
Next: The Object Hierarchy
Up: An AST Object Primer
Previous: AST Objects


Object Creation and Pointers

Let us first consider how to create a ZoomMap. This is done very simply as follows:

      INCLUDE 'AST_PAR'
      INTEGER STATUS, ZOOMMAP

      STATUS = 0

      ...

      ZOOMMAP = AST_ZOOMMAP( 2, 5.0D0, ' ', STATUS )

The first step is to include the file AST_PAR which defines the interface to the AST library and, amongst other things, declares AST_ZOOMMAP to be an integer function. We then declare an integer variable ZOOMMAP to receive the result and an integer STATUS variable to hold the error status, which we initialise to zero. Next, we invoke AST_ZOOMMAP to create the ZoomMap. The pattern is the same for all other classes of AST Object--you simply prefix ``AST_'' to the class name to obtain the function that creates the Object.

These functions are called constructor functions, or simply constructors (you can find an individual description of all AST functions in [*]) and the arguments passed to the constructor are used to initialise the new Object. In this case, we specify 2 as the number of coordinates (i.e. we are going to work in a 2-dimensional space) and 5.0D0 as the Zoom factor to be applied. Note that this is a Fortran double precision value. We will return to the final two arguments, a blank string and the error status, shortly ([*] and [*]).

The integer value returned by the constructor is termed an Object pointer or, in this case, a ZoomMap pointer. This pointer is not an Object itself, but is a value used to refer to the Object. You should be careful not to modify any Object pointer yourself, as this may render it invalid. Instead, you perform all subsequent operations on the Object by passing this pointer to other AST routines.


next up previous 264
Next: The Object Hierarchy
Up: An AST Object Primer
Previous: AST Objects

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

Copyright (C) 2009 Science \& Technology Facilities Council