1 #if !defined( CMPMAP_INCLUDED )  /* Include this file only once */
2 #define CMPMAP_INCLUDED
3 /*
4 *+
5 *  Name:
6 *     cmpmap.h
7 
8 *  Type:
9 *     C include file.
10 
11 *  Purpose:
12 *     Define the interface to the CmpMap class.
13 
14 *  Invocation:
15 *     #include "cmpmap.h"
16 
17 *  Description:
18 *     This include file defines the interface to the CmpMap class and
19 *     provides the type definitions, function prototypes and macros,
20 *     etc. needed to use this class.
21 *
22 *     A CmpMap is a compound Mapping which allows two component
23 *     Mappings (of any class) to be connected together to form a more
24 *     complex Mapping. This connection may either be "in series"
25 *     (where the first Mapping is used to transform the coordinates of
26 *     each point and the second mapping is then applied to the
27 *     result), or "in parallel" (where one Mapping transforms the
28 *     earlier coordinates for each point and the second Mapping
29 *     simultaneously transforms the later coordinates).
30 *
31 *     Since a CmpMap is itself a Mapping, it can be used as a
32 *     component in forming further CmpMaps. Mappings of arbitrary
33 *     complexity may be built from simple individual Mappings in this
34 *     way.
35 
36 *  Inheritance:
37 *     The CmpMap class inherits from the Mapping class.
38 
39 *  Attributes Over-Ridden:
40 *     None.
41 
42 *  New Attributes Defined:
43 *     None.
44 
45 *  Methods Over-Ridden:
46 *     Public:
47 *        astSimplify
48 *           Simplify a CmpMap.
49 *
50 *     Protected:
51 *        astMapList
52 *           Decompose a CmpMap into a sequence of simpler Mappings.
53 *        astTransform
54 *           Transform a set of points.
55 
56 *  New Methods Defined:
57 *     Public:
58 *        None.
59 *
60 *     Protected:
61 *        None.
62 
63 *  Other Class Functions:
64 *     Public:
65 *        astIsACmpMap
66 *           Test class membership.
67 *        astCmpMap
68 *           Create a CmpMap.
69 *
70 *     Protected:
71 *        astCheckCmpMap
72 *           Validate class membership.
73 *        astInitCmpMap
74 *           Initialise a CmpMap.
75 *        astInitCmpMapVtab
76 *           Initialise the virtual function table for the CmpMap class.
77 *        astLoadCmpMap
78 *           Load a CmpMap.
79 
80 *  Macros:
81 *     None.
82 
83 *  Type Definitions:
84 *     Public:
85 *        AstCmpMap
86 *           CmpMap object type.
87 *
88 *     Protected:
89 *        AstCmpMapVtab
90 *           CmpMap virtual function table type.
91 
92 *  Feature Test Macros:
93 *     astCLASS
94 *        If the astCLASS macro is undefined, only public symbols are
95 *        made available, otherwise protected symbols (for use in other
96 *        class implementations) are defined. This macro also affects
97 *        the reporting of error context information, which is only
98 *        provided for external calls to the AST library.
99 
100 *  Copyright:
101 *     Copyright (C) 1997-2006 Council for the Central Laboratory of the
102 *     Research Councils
103 
104 *  Licence:
105 *     This program is free software: you can redistribute it and/or
106 *     modify it under the terms of the GNU Lesser General Public
107 *     License as published by the Free Software Foundation, either
108 *     version 3 of the License, or (at your option) any later
109 *     version.
110 *
111 *     This program is distributed in the hope that it will be useful,
112 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
113 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
114 *     GNU Lesser General Public License for more details.
115 *
116 *     You should have received a copy of the GNU Lesser General
117 *     License along with this program.  If not, see
118 *     <http://www.gnu.org/licenses/>.
119 
120 *  Authors:
121 *     RFWS: R.F. Warren-Smith (Starlink)
122 
123 *  History:
124 *     6-FEB-1996 (RFWS):
125 *        Original version.
126 *     25-SEP-1996 (RFWS):
127 *        Implemented external interface and I/O facilities.
128 *     13-DEC-1996 (RFWS):
129 *        Over-ride the astSimplify method.
130 *     8-JAN-2003 (DSB):
131 *        Added protected astInitCmpMapVtab method.
132 *-
133 */
134 
135 /* Include files. */
136 /* ============== */
137 /* Interface definitions. */
138 /* ---------------------- */
139 #include "mapping.h"             /* Coordinate Mappings (parent class) */
140 
141 #if defined(astCLASS)            /* Protected */
142 #include "pointset.h"            /* Sets of points/coordinates */
143 #include "channel.h"             /* I/O channels */
144 #endif
145 
146 /* C header files. */
147 /* --------------- */
148 #if defined(astCLASS)            /* Protected */
149 #include <stddef.h>
150 #endif
151 
152 /* Macros */
153 /* ====== */
154 
155 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */
156 #ifndef __GNUC__
157 #  define  __attribute__(x)  /*NOTHING*/
158 #endif
159 
160 /* Type Definitions. */
161 /* ================= */
162 /* CmpMap structure. */
163 /* ----------------- */
164 /* This structure contains all information that is unique to each
165    object in the class (e.g. its instance variables). */
166 typedef struct AstCmpMap {
167 
168 /* Attributes inherited from the parent class. */
169    AstMapping mapping;           /* Parent class structure */
170 
171 /* Attributes specific to objects in this class. */
172    AstMapping *map1;              /* Pointer to first Mapping */
173    AstMapping *map2;              /* Pointer to second Mapping */
174    char invert1;                  /* Inversion flag for first Mapping */
175    char invert2;                  /* Inversion flag for second Mapping */
176    char series;                   /* Connect in series (else in parallel)? */
177 } AstCmpMap;
178 
179 /* Virtual function table. */
180 /* ----------------------- */
181 /* This table contains all information that is the same for all
182    objects in the class (e.g. pointers to its virtual functions). */
183 #if defined(astCLASS)            /* Protected */
184 typedef struct AstCmpMapVtab {
185 
186 /* Properties (e.g. methods) inherited from the parent class. */
187    AstMappingVtab mapping_vtab;  /* Parent class virtual function table */
188 
189 /* A Unique identifier to determine class membership. */
190    AstClassIdentifier id;
191 
192 /* Properties (e.g. methods) specific to this class. */
193 /* None. */
194 } AstCmpMapVtab;
195 
196 #if defined(THREAD_SAFE)
197 
198 /* Define a structure holding all data items that are global within this
199    class. */
200 typedef struct AstCmpMapGlobals {
201    AstCmpMapVtab Class_Vtab;
202    int Class_Init;
203    int Simplify_Depth;
204    AstMapping **Simplify_Stackmaps;
205 } AstCmpMapGlobals;
206 
207 #endif
208 
209 #endif
210 
211 /* Function prototypes. */
212 /* ==================== */
213 /* Prototypes for standard class functions. */
214 /* ---------------------------------------- */
215 astPROTO_CHECK(CmpMap)           /* Check class membership */
216 astPROTO_ISA(CmpMap)             /* Test class membership */
217 
218 /* Constructor. */
219 #if defined(astCLASS)            /* Protected. */
220 AstCmpMap *astCmpMap_( void *, void *, int, const char *, int *, ...);
221 #else
222 AstCmpMap *astCmpMapId_( void *, void *, int, const char *, ... )__attribute__((format(printf,4,5)));
223 #endif
224 
225 #if defined(astCLASS)            /* Protected */
226 
227 /* Initialiser. */
228 AstCmpMap *astInitCmpMap_( void *, size_t, int, AstCmpMapVtab *,
229                            const char *, AstMapping *, AstMapping *, int, int * );
230 
231 /* Vtab initialiser. */
232 void astInitCmpMapVtab_( AstCmpMapVtab *, const char *, int * );
233 
234 /* Loader. */
235 AstCmpMap *astLoadCmpMap_( void *, size_t, AstCmpMapVtab *,
236                            const char *, AstChannel *, int * );
237 
238 /* Thread-safe initialiser for all global data used by this module. */
239 #if defined(THREAD_SAFE)
240 void astInitCmpMapGlobals_( AstCmpMapGlobals * );
241 #endif
242 
243 #endif
244 
245 /* Prototypes for member functions. */
246 /* -------------------------------- */
247 /* None. */
248 
249 /* Function interfaces. */
250 /* ==================== */
251 /* These macros are wrap-ups for the functions defined by this class
252    to make them easier to invoke (e.g. to avoid type mis-matches when
253    passing pointers to objects from derived classes). */
254 
255 /* Interfaces to standard class functions. */
256 /* --------------------------------------- */
257 /* Some of these functions provide validation, so we cannot use them
258    to validate their own arguments. We must use a cast when passing
259    object pointers (so that they can accept objects from derived
260    classes). */
261 
262 /* Check class membership. */
263 #define astCheckCmpMap(this) astINVOKE_CHECK(CmpMap,this,0)
264 #define astVerifyCmpMap(this) astINVOKE_CHECK(CmpMap,this,1)
265 
266 /* Test class membership. */
267 #define astIsACmpMap(this) astINVOKE_ISA(CmpMap,this)
268 
269 /* Constructor. */
270 #if defined(astCLASS)            /* Protected. */
271 #define astCmpMap astINVOKE(F,astCmpMap_)
272 #else
273 #define astCmpMap astINVOKE(F,astCmpMapId_)
274 #endif
275 
276 #if defined(astCLASS)            /* Protected */
277 
278 /* Initialiser. */
279 #define astInitCmpMap(mem,size,init,vtab,name,map1,map2,series) \
280 astINVOKE(O,astInitCmpMap_(mem,size,init,vtab,name,astCheckMapping(map1),astCheckMapping(map2),series,STATUS_PTR))
281 
282 /* Vtab Initialiser. */
283 #define astInitCmpMapVtab(vtab,name) astINVOKE(V,astInitCmpMapVtab_(vtab,name,STATUS_PTR))
284 /* Loader. */
285 #define astLoadCmpMap(mem,size,vtab,name,channel) \
286 astINVOKE(O,astLoadCmpMap_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))
287 #endif
288 
289 /* Interfaces to public member functions. */
290 /* -------------------------------------- */
291 /* Here we make use of astCheckCmpMap to validate CmpMap pointers
292    before use.  This provides a contextual error report if a pointer
293    to the wrong sort of Object is supplied. */
294 /* None. */
295 #endif
296 
297 
298 
299 
300 
301