1 #if !defined( SPECMAP_INCLUDED )  /* Include this file only once */
2 #define SPECMAP_INCLUDED
3 /*
4 *+
5 *  Name:
6 *     specmap.h
7 
8 *  Type:
9 *     C include file.
10 
11 *  Purpose:
12 *     Define the interface to the SpecMap class.
13 
14 *  Invocation:
15 *     #include "specmap.h"
16 
17 *  Description:
18 *     This include file defines the interface to the SpecMap class and
19 *     provides the type definitions, function prototypes and macros,
20 *     etc.  needed to use this class.
21 *
22 *     The SpecMap class encapsulates various ecptral coordinate
23 *     conversions. Since, typically, a sequence of these conversions is
24 *     required, a SpecMap can be used to accumulate a series of conversions
25 *     which it then applies in sequence.
26 
27 *  Inheritance:
28 *     The SpecMap class inherits from the Mapping class.
29 
30 *  Attributes Over-Ridden:
31 *     None.
32 
33 *  New Attributes Defined:
34 *     None.
35 
36 *  Methods Over-Ridden:
37 *     Public:
38 *        astTransform
39 *           Use an SpecMap to transform a set of points.
40 
41 *     Protected:
42 *        astMapMerge
43 *           Simplify a sequence of Mappings containing an SpecMap.
44 
45 *  New Methods Defined:
46 *     Public:
47 *        astSpecAdd
48 *           Add a coordinate conversion step to an SpecMap.
49 
50 *     Private:
51 *        None.
52 
53 *  Other Class Functions:
54 *     Public:
55 *        astIsASpecMap
56 *           Test class membership.
57 *        astSpecMap
58 *           Create an SpecMap.
59 
60 *     Protected:
61 *        astCheckSpecMap
62 *           Validate class membership.
63 *        astInitSpecMap
64 *           Initialise an SpecMap.
65 *        astLoadSpecMap
66 *           Load an SpecMap.
67 
68 *  Macros:
69 *     None.
70 
71 *  Type Definitions:
72 *     Public:
73 *        AstSpecMap
74 *           SpecMap object type.
75 
76 *     Protected:
77 *        AstSpecMapVtab
78 *           SpecMap virtual function table type.
79 
80 *  Feature Test Macros:
81 *     astCLASS
82 *        If the astCLASS macro is undefined, only public symbols are
83 *        made available, otherwise protected symbols (for use in other
84 *        class implementations) are defined. This macro also affects
85 *        the reporting of error context information, which is only
86 *        provided for external calls to the AST library.
87 
88 *  Copyright:
89 *     Copyright (C) 1997-2006 Council for the Central Laboratory of the
90 *     Research Councils
91 
92 *  Licence:
93 *     This program is free software: you can redistribute it and/or
94 *     modify it under the terms of the GNU Lesser General Public
95 *     License as published by the Free Software Foundation, either
96 *     version 3 of the License, or (at your option) any later
97 *     version.
98 *
99 *     This program is distributed in the hope that it will be useful,
100 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
101 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
102 *     GNU Lesser General Public License for more details.
103 *
104 *     You should have received a copy of the GNU Lesser General
105 *     License along with this program.  If not, see
106 *     <http://www.gnu.org/licenses/>.
107 
108 *  Authors:
109 *     DSB: David S. Berry (Starlink)
110 
111 *  History:
112 *     8-NOV-2002 (DSB):
113 *        Original version.
114 *-
115 */
116 
117 /* Include files. */
118 /* ============== */
119 /* Interface definitions. */
120 /* ---------------------- */
121 #include "mapping.h"             /* Coordinate mappings (parent class) */
122 
123 #if defined(astCLASS)            /* Protected */
124 #include "pointset.h"            /* Sets of points/coordinates */
125 #include "channel.h"             /* I/O channels */
126 #endif
127 
128 /* C header files. */
129 /* --------------- */
130 #if defined(astCLASS)            /* Protected */
131 #include <stddef.h>
132 #endif
133 
134 /* Macros */
135 /* ------ */
136 /* Physical constants taken from Chapter 15 of the "Explanatory Supplement
137    to the Astronomical Ephemeris". */
138 #define AST__C 2.99792458E8      /* Speed of light (metres per second) */
139 #define AST__H 6.6260755E-34     /* Plank constant (Joule.seconds) */
140 
141 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */
142 #ifndef __GNUC__
143 #  define  __attribute__(x)  /*NOTHING*/
144 #endif
145 
146 /* SpecMap structure. */
147 /* ----------------- */
148 /* This structure contains all information that is unique to each
149    object in the class (e.g. its instance variables). */
150 typedef struct AstSpecMap {
151 
152 /* Attributes inherited from the parent class. */
153    AstMapping mapping;           /* Parent class structure */
154 
155 /* Attributes specific to objects in this class. */
156    int *cvttype;                 /* Pointer to array of conversion types */
157    double **cvtargs;             /* Pointer to argument list pointer array */
158    int ncvt;                     /* Number of conversions to perform */
159 } AstSpecMap;
160 
161 /* Virtual function table. */
162 /* ----------------------- */
163 /* This table contains all information that is the same for all
164    objects in the class (e.g. pointers to its virtual functions). */
165 #if defined(astCLASS)            /* Protected */
166 typedef struct AstSpecMapVtab {
167 
168 /* Properties (e.g. methods) inherited from the parent class. */
169    AstMappingVtab mapping_vtab;  /* Parent class virtual function table */
170 
171 /* A Unique identifier to determine class membership. */
172    AstClassIdentifier id;
173 
174 /* Properties (e.g. methods) specific to this class. */
175    void (* SpecAdd)( AstSpecMap *, const char *, const double[], int * );
176 } AstSpecMapVtab;
177 
178 #if defined(THREAD_SAFE)
179 
180 /* Define a structure holding all data items that are global within the
181    object.c file. */
182 
183 typedef struct AstSpecMapGlobals {
184    AstSpecMapVtab Class_Vtab;
185    int Class_Init;
186 } AstSpecMapGlobals;
187 
188 
189 /* Thread-safe initialiser for all global data used by this module. */
190 void astInitSpecMapGlobals_( AstSpecMapGlobals * );
191 
192 #endif
193 
194 
195 #endif
196 
197 /* Function prototypes. */
198 /* ==================== */
199 /* Prototypes for standard class functions. */
200 /* ---------------------------------------- */
201 astPROTO_CHECK(SpecMap)           /* Check class membership */
202 astPROTO_ISA(SpecMap)             /* Test class membership */
203 
204 /* Constructor. */
205 #if defined(astCLASS)            /* Protected. */
206 AstSpecMap *astSpecMap_( int, int, const char *, int *, ...);
207 #else
208 AstSpecMap *astSpecMapId_( int, int, const char *, ... )__attribute__((format(printf,3,4)));
209 #endif
210 
211 #if defined(astCLASS)            /* Protected */
212 
213 /* Initialiser. */
214 AstSpecMap *astInitSpecMap_( void *, size_t, int, AstSpecMapVtab *,
215                              const char *, int, int, int * );
216 
217 /* Vtab initialiser. */
218 void astInitSpecMapVtab_( AstSpecMapVtab *, const char *, int * );
219 
220 /* Loader. */
221 AstSpecMap *astLoadSpecMap_( void *, size_t, AstSpecMapVtab *,
222                            const char *, AstChannel *, int * );
223 #endif
224 
225 /* Prototypes for member functions. */
226 /* -------------------------------- */
227 void astSpecAdd_( AstSpecMap *, const char *, const double[], int * );
228 
229 /* Function interfaces. */
230 /* ==================== */
231 /* These macros are wrap-ups for the functions defined by this class
232    to make them easier to invoke (e.g. to avoid type mis-matches when
233    passing pointers to objects from derived classes). */
234 
235 /* Interfaces to standard class functions. */
236 /* --------------------------------------- */
237 /* Some of these functions provide validation, so we cannot use them
238    to validate their own arguments. We must use a cast when passing
239    object pointers (so that they can accept objects from derived
240    classes). */
241 
242 /* Check class membership. */
243 #define astCheckSpecMap(this) astINVOKE_CHECK(SpecMap,this,0)
244 #define astVerifySpecMap(this) astINVOKE_CHECK(SpecMap,this,1)
245 
246 /* Test class membership. */
247 #define astIsASpecMap(this) astINVOKE_ISA(SpecMap,this)
248 
249 /* Constructor. */
250 #if defined(astCLASS)            /* Protected. */
251 #define astSpecMap astINVOKE(F,astSpecMap_)
252 #else
253 #define astSpecMap astINVOKE(F,astSpecMapId_)
254 #endif
255 
256 #if defined(astCLASS)            /* Protected */
257 
258 /* Initialiser. */
259 #define astInitSpecMap(mem,size,init,vtab,name,nin,flags) \
260 astINVOKE(O,astInitSpecMap_(mem,size,init,vtab,name,nin,flags,STATUS_PTR))
261 
262 /* Vtab Initialiser. */
263 #define astInitSpecMapVtab(vtab,name) astINVOKE(V,astInitSpecMapVtab_(vtab,name,STATUS_PTR))
264 /* Loader. */
265 #define astLoadSpecMap(mem,size,vtab,name,channel) \
266 astINVOKE(O,astLoadSpecMap_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))
267 #endif
268 
269 /* Interfaces to public member functions. */
270 /* -------------------------------------- */
271 /* Here we make use of astCheckSpecMap to validate SpecMap pointers
272    before use.  This provides a contextual error report if a pointer
273    to the wrong sort of Object is supplied. */
274 #define astSpecAdd(this,cvt,args) \
275 astINVOKE(V,astSpecAdd_(astCheckSpecMap(this),cvt,args,STATUS_PTR))
276 
277 #endif
278 
279 
280 
281 
282 
283