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.h"
AstZoomMap *zoommap;

...

zoommap = astZoomMap( 2, 5.0, "" )

The first step is to include the header file ``ast.h'' which declares the interface to the AST library. We then declare a pointer of type AstZoomMap$*$ to receive the result and invoke the function astZoomMap 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 and prefix ``Ast'' to obtain the type of the returned pointer.

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.0 as the Zoom factor to be applied. Note that this is a C double value. We will return to the final argument, an empty string, shortly ([*]).

The value returned by the constructor is termed an Object pointer or, in this case, a ZoomMap pointer and is used to refer to the Object. You perform all subsequent operations on the Object by passing this pointer to other AST functions.


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 211
R.F. Warren-Smith & D.S. Berry
25th February 2013
E-mail:starlink@jiscmail.ac.uk

Copyright (C) 2014 Science \& Technology Facilities Council