summaryrefslogtreecommitdiffstats
path: root/ast/specframe.h
blob: 34d8eac8bcf6dc7f96d31c5c111625ff78d55c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
#if !defined( SPECFRAME_INCLUDED ) /* Include this file only once */
#define SPECFRAME_INCLUDED
/*
*+
*  Name:
*     specframe.h

*  Type:
*     C include file.

*  Purpose:
*     Define the interface to the SpecFrame class.

*  Invocation:
*     #include "specframe.h"

*  Description:
*     This include file defines the interface to the SpecFrame class
*     and provides the type definitions, function prototypes and
*     macros, etc. needed to use this class.

*  Copyright:
*     Copyright (C) 1997-2006 Council for the Central Laboratory of the
*     Research Councils

*  Licence:
*     This program is free software: you can redistribute it and/or
*     modify it under the terms of the GNU Lesser General Public
*     License as published by the Free Software Foundation, either
*     version 3 of the License, or (at your option) any later
*     version.
*     
*     This program is distributed in the hope that it will be useful,
*     but WITHOUT ANY WARRANTY; without even the implied warranty of
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*     GNU Lesser General Public License for more details.
*     
*     You should have received a copy of the GNU Lesser General
*     License along with this program.  If not, see
*     <http://www.gnu.org/licenses/>.

*  Authors:
*     DSB: David S. Berry (Starlink)

*  History:
*     12-NOV-2002 (DSB):
*        Original version.
*     18-OCT-2006 (DSB):
*        Added SpecOrigin.
*-
*/

/* Include files. */
/* ============== */
/* Interface definitions. */
/* ---------------------- */
#include "object.h"              /* Base Object class */
#include "frame.h"               /* Parent Frame class */
#include "skyframe.h"            /* Celestial coordinate systems */

/* Macros. */
/* ======= */
#if defined(astCLASS) || defined(astFORTRAN77)
#define STATUS_PTR status
#else
#define STATUS_PTR astGetStatusPtr
#endif

/* Define a dummy __attribute__ macro for use on non-GNU compilers. */
#ifndef __GNUC__
#  define  __attribute__(x)  /*NOTHING*/
#endif


#if defined(astCLASS)            /* Protected */

/* Values used to represent different System attribute values. */
#define AST__FREQ          1
#define AST__ENERGY        2
#define AST__WAVENUM       3
#define AST__WAVELEN       4
#define AST__AIRWAVE       5
#define AST__VRADIO        6
#define AST__VOPTICAL      7
#define AST__REDSHIFT      8
#define AST__BETA          9
#define AST__VREL          10

/* Values used to represent different StdOfRest attribute values. */
#define AST__BADSOR        0
#define AST__TPSOR         1
#define AST__GESOR         2
#define AST__BYSOR         3
#define AST__HLSOR         4
#define AST__LDSOR         5
#define AST__LKSOR         6
#define AST__LGSOR         7
#define AST__GLSOR         8
#define AST__SCSOR         9
#endif

/* Type Definitions. */
/* ================= */

/* Integer type used to store the spectral StdOfRest attribute. */
typedef int AstStdOfRestType;

/* SpecFrame structure. */
/* ------------------- */
/* This structure contains all information that is unique to each object in
   the class (e.g. its instance variables). */
typedef struct AstSpecFrame {

/* Attributes inherited from the parent class. */
   AstFrame frame;               /* Parent class structure */

/* Attributes specific to objects in this class. */
   AstStdOfRestType alignstdofrest;/* Code identifying alignment StdOfRest */
   AstStdOfRestType stdofrest;   /* Standard of rest */
   double refdec;                /* Dec (FK5 J2000) of source */
   double refra;                 /* RA (FK5 J2000) of source */
   double restfreq;              /* Rest frequency (Hz)*/
   double sourcevel;             /* Source velocity (heliocentric, m/s) */
   AstStdOfRestType sourcevrf;   /* Code identifying source vel. StdOfRest */
   AstSystemType sourcesys;      /* Code identifying source vel. system */
   int nuunits;                  /* Size of usedunits array */
   char **usedunits;             /* Last used units for each system */
   double specorigin;            /* Origin for sectral values */
   int alignspecoffset;          /* Align SpecFrame in offset coords? */
} AstSpecFrame;

/* Virtual function table. */
/* ----------------------- */
/* This table contains all information that is the same for all objects in the
   class (e.g. pointers to its virtual functions). */
#if defined(astCLASS)            /* Protected */
typedef struct AstSpecFrameVtab {

/* Properties (e.g. methods) inherited from the parent class. */
   AstFrameVtab frame_vtab;      /* Parent class virtual function table */

/* A Unique identifier to determine class membership. */
   AstClassIdentifier id;

/* Properties (e.g. methods) specific to this class. */
   void (* GetRefPos)( AstSpecFrame *, AstSkyFrame *, double *, double *, int * );
   void (* SetRefPos)( AstSpecFrame *, AstSkyFrame *, double, double, int * );

   AstStdOfRestType (* GetStdOfRest)( AstSpecFrame *, int * );
   int (* TestStdOfRest)( AstSpecFrame *, int * );
   void (* ClearStdOfRest)( AstSpecFrame *, int * );
   void (* SetStdOfRest)( AstSpecFrame *, AstStdOfRestType, int * );

   AstStdOfRestType (* GetAlignStdOfRest)( AstSpecFrame *, int * );
   int (* TestAlignStdOfRest)( AstSpecFrame *, int * );
   void (* ClearAlignStdOfRest)( AstSpecFrame *, int * );
   void (* SetAlignStdOfRest)( AstSpecFrame *, AstStdOfRestType, int * );

   AstStdOfRestType (* GetSourceVRF)( AstSpecFrame *, int * );
   int (* TestSourceVRF)( AstSpecFrame *, int * );
   void (* ClearSourceVRF)( AstSpecFrame *, int * );
   void (* SetSourceVRF)( AstSpecFrame *, AstStdOfRestType, int * );

   AstSystemType (* GetSourceSys)( AstSpecFrame *, int * );
   int (* TestSourceSys)( AstSpecFrame *, int * );
   void (* ClearSourceSys)( AstSpecFrame *, int * );
   void (* SetSourceSys)( AstSpecFrame *, AstSystemType, int * );

   double (* GetRestFreq)( AstSpecFrame *, int * );
   int (* TestRestFreq)( AstSpecFrame *, int * );
   void (* ClearRestFreq)( AstSpecFrame *, int * );
   void (* SetRestFreq)( AstSpecFrame *, double, int * );

   double (* GetRefRA)( AstSpecFrame *, int * );
   int (* TestRefRA)( AstSpecFrame *, int * );
   void (* ClearRefRA)( AstSpecFrame *, int * );
   void (* SetRefRA)( AstSpecFrame *, double, int * );

   double (* GetRefDec)( AstSpecFrame *, int * );
   int (* TestRefDec)( AstSpecFrame *, int * );
   void (* ClearRefDec)( AstSpecFrame *, int * );
   void (* SetRefDec)( AstSpecFrame *, double, int * );

   double (* GetSourceVel)( AstSpecFrame *, int * );
   int (* TestSourceVel)( AstSpecFrame *, int * );
   void (* ClearSourceVel)( AstSpecFrame *, int * );
   void (* SetSourceVel)( AstSpecFrame *, double, int * );

   double (* GetSpecOrigin)( AstSpecFrame *, int * );
   int (* TestSpecOrigin)( AstSpecFrame *, int * );
   void (* ClearSpecOrigin)( AstSpecFrame *, int * );
   void (* SetSpecOrigin)( AstSpecFrame *, double, int * );

   int (* GetAlignSpecOffset)( AstSpecFrame *, int * );
   int (* TestAlignSpecOffset)( AstSpecFrame *, int * );
   void (* ClearAlignSpecOffset)( AstSpecFrame *, int * );
   void (* SetAlignSpecOffset)( AstSpecFrame *, int, int * );


} AstSpecFrameVtab;


#if defined(THREAD_SAFE)

/* Define a structure holding all data items that are global within this
   class. */
typedef struct AstSpecFrameGlobals {
   AstSpecFrameVtab Class_Vtab;
   int Class_Init;
   char GetAttrib_Buff[ 51 ];
   char GetLabel_Buff[ 201 ];
   char GetSymbol_Buff[ 21 ];
   char GetTitle_Buff[ 201 ];
} AstSpecFrameGlobals;

#endif

#endif

/* Function prototypes. */
/* ==================== */
/* Prototypes for standard class functions. */
/* ---------------------------------------- */
astPROTO_CHECK(SpecFrame)         /* Check class membership */
astPROTO_ISA(SpecFrame)           /* Test class membership */

/* Constructor. */
#if defined(astCLASS)            /* Protected */
AstSpecFrame *astSpecFrame_( const char *, int *, ...);
#else
AstSpecFrame *astSpecFrameId_( const char *, ... )__attribute__((format(printf,1,2)));
#endif

#if defined(astCLASS)            /* Protected */

/* Initialiser. */
AstSpecFrame *astInitSpecFrame_( void *, size_t, int,
                                         AstSpecFrameVtab *,
                                         const char *, int * );

/* Vtab initialiser. */
void astInitSpecFrameVtab_( AstSpecFrameVtab *, const char *, int * );

/* Loader. */
AstSpecFrame *astLoadSpecFrame_( void *, size_t,
                                         AstSpecFrameVtab *,
                                         const char *, AstChannel *channel, int * );

/* Thread-safe initialiser for all global data used by this module. */
#if defined(THREAD_SAFE)
void astInitSpecFrameGlobals_( AstSpecFrameGlobals * );
#endif

#endif

/* Prototypes for member functions. */
/* -------------------------------- */
void astGetRefPos_( AstSpecFrame *, AstSkyFrame *, double *, double *, int * );
void astSetRefPos_( AstSpecFrame *, AstSkyFrame *, double, double, int * );

#if defined(astCLASS)            /* Protected */

AstStdOfRestType astGetStdOfRest_( AstSpecFrame *, int * );
int astTestStdOfRest_( AstSpecFrame *, int * );
void astClearStdOfRest_( AstSpecFrame *, int * );
void astSetStdOfRest_( AstSpecFrame *, AstStdOfRestType, int * );

AstStdOfRestType astGetAlignStdOfRest_( AstSpecFrame *, int * );
int astTestAlignStdOfRest_( AstSpecFrame *, int * );
void astClearAlignStdOfRest_( AstSpecFrame *, int * );
void astSetAlignStdOfRest_( AstSpecFrame *, AstStdOfRestType, int * );

AstStdOfRestType astGetSourceVRF_( AstSpecFrame *, int * );
int astTestSourceVRF_( AstSpecFrame *, int * );
void astClearSourceVRF_( AstSpecFrame *, int * );
void astSetSourceVRF_( AstSpecFrame *, AstStdOfRestType, int * );

AstSystemType astGetSourceSys_( AstSpecFrame *, int * );
int astTestSourceSys_( AstSpecFrame *, int * );
void astClearSourceSys_( AstSpecFrame *, int * );
void astSetSourceSys_( AstSpecFrame *, AstSystemType, int * );

double astGetRestFreq_( AstSpecFrame *, int * );
int astTestRestFreq_( AstSpecFrame *, int * );
void astClearRestFreq_( AstSpecFrame *, int * );
void astSetRestFreq_( AstSpecFrame *, double, int * );

double astGetRefRA_( AstSpecFrame *, int * );
int astTestRefRA_( AstSpecFrame *, int * );
void astClearRefRA_( AstSpecFrame *, int * );
void astSetRefRA_( AstSpecFrame *, double, int * );

double astGetRefDec_( AstSpecFrame *, int * );
int astTestRefDec_( AstSpecFrame *, int * );
void astClearRefDec_( AstSpecFrame *, int * );
void astSetRefDec_( AstSpecFrame *, double, int * );

double astGetSourceVel_( AstSpecFrame *, int * );
int astTestSourceVel_( AstSpecFrame *, int * );
void astClearSourceVel_( AstSpecFrame *, int * );
void astSetSourceVel_( AstSpecFrame *, double, int * );

double astGetSpecOrigin_( AstSpecFrame *, int * );
int astTestSpecOrigin_( AstSpecFrame *, int * );
void astClearSpecOrigin_( AstSpecFrame *, int * );
void astSetSpecOrigin_( AstSpecFrame *, double, int * );

int astGetAlignSpecOffset_( AstSpecFrame *, int * );
int astTestAlignSpecOffset_( AstSpecFrame *, int * );
void astClearAlignSpecOffset_( AstSpecFrame *, int * );
void astSetAlignSpecOffset_( AstSpecFrame *, int, int * );

#endif

/* Function interfaces. */
/* ==================== */
/* These macros are wrap-ups for the functions defined by this class
   to make them easier to invoke (e.g. to avoid type mis-matches when
   passing pointers to objects from derived classes). */

/* Interfaces to standard class functions. */
/* --------------------------------------- */
/* Some of these functions provide validation, so we cannot use them
   to validate their own arguments. We must use a cast when passing
   object pointers (so that they can accept objects from derived
   classes). */

/* Check class membership. */
#define astCheckSpecFrame(this) astINVOKE_CHECK(SpecFrame,this,0)
#define astVerifySpecFrame(this) astINVOKE_CHECK(SpecFrame,this,1)

/* Test class membership. */
#define astIsASpecFrame(this) astINVOKE_ISA(SpecFrame,this)

/* Constructor. */
#if defined(astCLASS)            /* Protected */
#define astSpecFrame astINVOKE(F,astSpecFrame_)
#else
#define astSpecFrame astINVOKE(F,astSpecFrameId_)
#endif

#if defined(astCLASS)            /* Protected */

/* Initialiser. */
#define astInitSpecFrame(mem,size,init,vtab,name) \
astINVOKE(O,astInitSpecFrame_(mem,size,init,vtab,name,STATUS_PTR))

/* Vtab Initialiser. */
#define astInitSpecFrameVtab(vtab,name) astINVOKE(V,astInitSpecFrameVtab_(vtab,name,STATUS_PTR))
/* Loader. */
#define astLoadSpecFrame(mem,size,vtab,name,channel) \
astINVOKE(O,astLoadSpecFrame_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))

#endif

/* Interfaces to public member functions. */
/* -------------------------------------- */

/* None. */

/* Interfaces to protected member functions. */
/* ----------------------------------------- */
/* Here we make use of astCheckSpecFrame to validate SpecFrame pointers
   before use. This provides a contextual error report if a pointer to
   the wrong sort of object is supplied. */

#define astGetRefPos(this,frm,lon,lat) astINVOKE(V,astGetRefPos_(astCheckSpecFrame(this),(frm==NULL?NULL:astCheckSkyFrame(frm)),lon,lat,STATUS_PTR))
#define astSetRefPos(this,frm,lon,lat) astINVOKE(V,astSetRefPos_(astCheckSpecFrame(this),(frm==NULL?NULL:astCheckSkyFrame(frm)),lon,lat,STATUS_PTR))

#if defined(astCLASS)            /* Protected */

#define astGetStdOfRest(this) astINVOKE(V,astGetStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestStdOfRest(this) astINVOKE(V,astTestStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearStdOfRest(this) astINVOKE(V,astClearStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetStdOfRest(this,value) astINVOKE(V,astSetStdOfRest_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetAlignStdOfRest(this) astINVOKE(V,astGetAlignStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestAlignStdOfRest(this) astINVOKE(V,astTestAlignStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearAlignStdOfRest(this) astINVOKE(V,astClearAlignStdOfRest_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetAlignStdOfRest(this,value) astINVOKE(V,astSetAlignStdOfRest_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetSourceVRF(this) astINVOKE(V,astGetSourceVRF_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestSourceVRF(this) astINVOKE(V,astTestSourceVRF_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearSourceVRF(this) astINVOKE(V,astClearSourceVRF_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetSourceVRF(this,value) astINVOKE(V,astSetSourceVRF_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetSourceSys(this) astINVOKE(V,astGetSourceSys_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestSourceSys(this) astINVOKE(V,astTestSourceSys_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearSourceSys(this) astINVOKE(V,astClearSourceSys_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetSourceSys(this,value) astINVOKE(V,astSetSourceSys_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetRestFreq(this) astINVOKE(V,astGetRestFreq_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestRestFreq(this) astINVOKE(V,astTestRestFreq_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearRestFreq(this) astINVOKE(V,astClearRestFreq_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetRestFreq(this,value) astINVOKE(V,astSetRestFreq_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetRefRA(this) astINVOKE(V,astGetRefRA_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestRefRA(this) astINVOKE(V,astTestRefRA_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearRefRA(this) astINVOKE(V,astClearRefRA_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetRefRA(this,value) astINVOKE(V,astSetRefRA_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetRefDec(this) astINVOKE(V,astGetRefDec_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestRefDec(this) astINVOKE(V,astTestRefDec_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearRefDec(this) astINVOKE(V,astClearRefDec_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetRefDec(this,value) astINVOKE(V,astSetRefDec_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetSourceVel(this) astINVOKE(V,astGetSourceVel_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestSourceVel(this) astINVOKE(V,astTestSourceVel_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearSourceVel(this) astINVOKE(V,astClearSourceVel_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetSourceVel(this,value) astINVOKE(V,astSetSourceVel_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astGetSpecOrigin(this) astINVOKE(V,astGetSpecOrigin_(astCheckSpecFrame(this),STATUS_PTR))
#define astTestSpecOrigin(this) astINVOKE(V,astTestSpecOrigin_(astCheckSpecFrame(this),STATUS_PTR))
#define astClearSpecOrigin(this) astINVOKE(V,astClearSpecOrigin_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetSpecOrigin(this,value) astINVOKE(V,astSetSpecOrigin_(astCheckSpecFrame(this),value,STATUS_PTR))

#define astClearAlignSpecOffset(this) astINVOKE(V,astClearAlignSpecOffset_(astCheckSpecFrame(this),STATUS_PTR))
#define astGetAlignSpecOffset(this) astINVOKE(V,astGetAlignSpecOffset_(astCheckSpecFrame(this),STATUS_PTR))
#define astSetAlignSpecOffset(this,value) astINVOKE(V,astSetAlignSpecOffset_(astCheckSpecFrame(this),value,STATUS_PTR))
#define astTestAlignSpecOffset(this) astINVOKE(V,astTestAlignSpecOffset_(astCheckSpecFrame(this),STATUS_PTR))



#endif
#endif