1 #if !defined( CMPREGION_INCLUDED ) /* Include this file only once */ 2 #define CMPREGION_INCLUDED 3 /* 4 *+ 5 * Name: 6 * cmpregion.h 7 8 * Type: 9 * C include file. 10 11 * Purpose: 12 * Define the interface to the CmpRegion class. 13 14 * Invocation: 15 * #include "cmpregion.h" 16 17 * Description: 18 * This include file defines the interface to the CmpRegion class and 19 * provides the type definitions, function prototypes and macros, 20 * etc. needed to use this class. 21 * 22 * The CmpRegion class implement a Region which represents a simple interval 23 * on each axis of the encapsulated Frame 24 25 * Inheritance: 26 * The CmpRegion class inherits from the Region class. 27 28 * Feature Test Macros: 29 * astCLASS 30 * If the astCLASS macro is undefined, only public symbols are 31 * made available, otherwise protected symbols (for use in other 32 * class implementations) are defined. This macro also affects 33 * the reporting of error context information, which is only 34 * provided for external calls to the AST library. 35 36 * Copyright: 37 * Copyright (C) 1997-2006 Council for the Central Laboratory of the 38 * Research Councils 39 40 * Licence: 41 * This program is free software: you can redistribute it and/or 42 * modify it under the terms of the GNU Lesser General Public 43 * License as published by the Free Software Foundation, either 44 * version 3 of the License, or (at your option) any later 45 * version. 46 * 47 * This program is distributed in the hope that it will be useful, 48 * but WITHOUT ANY WARRANTY; without even the implied warranty of 49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 50 * GNU Lesser General Public License for more details. 51 * 52 * You should have received a copy of the GNU Lesser General 53 * License along with this program. If not, see 54 * <http://www.gnu.org/licenses/>. 55 56 * Authors: 57 * DSB: David S. Berry (Starlink) 58 59 * History: 60 * 11-OCT-2004 (DSB): 61 * Original version. 62 *- 63 */ 64 65 /* Include files. */ 66 /* ============== */ 67 /* Interface definitions. */ 68 /* ---------------------- */ 69 #include "region.h" /* Coordinate regions (parent class) */ 70 71 #if defined(astCLASS) /* Protected */ 72 #include "channel.h" /* I/O channels */ 73 #endif 74 75 /* C header files. */ 76 /* --------------- */ 77 #if defined(astCLASS) /* Protected */ 78 #include <stddef.h> 79 #endif 80 81 /* Macros. */ 82 /* ------- */ 83 /* Boolean operators */ 84 85 #if defined(astCLASS) || defined(astFORTRAN77) 86 #define STATUS_PTR status 87 #else 88 #define STATUS_PTR astGetStatusPtr 89 #endif 90 #define AST__AND 1 91 #define AST__OR 2 92 #define AST__XOR 3 93 94 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */ 95 #ifndef __GNUC__ 96 # define __attribute__(x) /*NOTHING*/ 97 #endif 98 99 /* Type Definitions. */ 100 /* ================= */ 101 /* CmpRegion structure. */ 102 /* ------------------ */ 103 /* This structure contains all information that is unique to each object in 104 the class (e.g. its instance variables). */ 105 typedef struct AstCmpRegion { 106 107 /* Attributes inherited from the parent class. */ 108 AstRegion region; /* Parent class structure */ 109 110 /* Attributes specific to objects in this class. */ 111 AstRegion *region1; /* First component Region */ 112 AstRegion *region2; /* Second component Region */ 113 int oper; /* Boolean operator */ 114 double *rvals[ 2 ]; /* Used boundary length at each break */ 115 double *offs[ 2 ]; /* Jump at each break */ 116 int nbreak[ 2 ]; /* Number of breaks */ 117 double d0[ 2 ]; /* Total used boundary length */ 118 double dtot[ 2 ]; /* Total boundary length */ 119 AstRegion *xor1; /* First XORed Region */ 120 AstRegion *xor2; /* Second XORed Region */ 121 int bounded; /* Is this CmpRegion bounded? */ 122 } AstCmpRegion; 123 124 /* Virtual function table. */ 125 /* ----------------------- */ 126 /* This table contains all information that is the same for all 127 objects in the class (e.g. pointers to its virtual functions). */ 128 #if defined(astCLASS) /* Protected */ 129 typedef struct AstCmpRegionVtab { 130 131 /* Properties (e.g. methods) inherited from the parent class. */ 132 AstRegionVtab region_vtab; /* Parent class virtual function table */ 133 134 /* A Unique identifier to determine class membership. */ 135 AstClassIdentifier id; 136 137 /* Properties (e.g. methods) specific to this class. */ 138 int (* CmpRegionList)( AstCmpRegion *, int *, AstRegion ***, int * ); 139 140 } AstCmpRegionVtab; 141 142 #if defined(THREAD_SAFE) 143 144 /* Define a structure holding all data items that are global within the 145 object.c file. */ 146 147 typedef struct AstCmpRegionGlobals { 148 AstCmpRegionVtab Class_Vtab; 149 int Class_Init; 150 } AstCmpRegionGlobals; 151 152 153 /* Thread-safe initialiser for all global data used by this module. */ 154 void astInitCmpRegionGlobals_( AstCmpRegionGlobals * ); 155 156 #endif 157 158 159 #endif 160 161 /* Function prototypes. */ 162 /* ==================== */ 163 /* Prototypes for standard class functions. */ 164 /* ---------------------------------------- */ 165 astPROTO_CHECK(CmpRegion) /* Check class membership */ 166 astPROTO_ISA(CmpRegion) /* Test class membership */ 167 168 /* Constructor. */ 169 #if defined(astCLASS) /* Protected. */ 170 AstCmpRegion *astCmpRegion_( void *, void *, int, const char *, int *, ...); 171 #else 172 AstCmpRegion *astCmpRegionId_( void *, void *, int, const char *, ... )__attribute__((format(printf,4,5))); 173 #endif 174 175 #if defined(astCLASS) /* Protected */ 176 177 /* Initialiser. */ 178 AstCmpRegion *astInitCmpRegion_( void *, size_t, int, AstCmpRegionVtab *, 179 const char *, AstRegion *, AstRegion *, int, int * ); 180 181 /* Vtab initialiser. */ 182 void astInitCmpRegionVtab_( AstCmpRegionVtab *, const char *, int * ); 183 184 /* Loader. */ 185 AstCmpRegion *astLoadCmpRegion_( void *, size_t, AstCmpRegionVtab *, 186 const char *, AstChannel *, int * ); 187 188 #endif 189 190 /* Prototypes for member functions. */ 191 /* -------------------------------- */ 192 # if defined(astCLASS) /* Protected */ 193 int astCmpRegionList_( AstCmpRegion *, int *, AstRegion ***, int * ); 194 #endif 195 196 /* Function interfaces. */ 197 /* ==================== */ 198 /* These macros are wrap-ups for the functions defined by this class 199 to make them easier to invoke (e.g. to avoid type mis-matches when 200 passing pointers to objects from derived classes). */ 201 202 /* Interfaces to standard class functions. */ 203 /* --------------------------------------- */ 204 /* Some of these functions provide validation, so we cannot use them 205 to validate their own arguments. We must use a cast when passing 206 object pointers (so that they can accept objects from derived 207 classes). */ 208 209 /* Check class membership. */ 210 #define astCheckCmpRegion(this) astINVOKE_CHECK(CmpRegion,this,0) 211 #define astVerifyCmpRegion(this) astINVOKE_CHECK(CmpRegion,this,1) 212 213 /* Test class membership. */ 214 #define astIsACmpRegion(this) astINVOKE_ISA(CmpRegion,this) 215 216 /* Constructor. */ 217 #if defined(astCLASS) /* Protected. */ 218 #define astCmpRegion astINVOKE(F,astCmpRegion_) 219 #else 220 #define astCmpRegion astINVOKE(F,astCmpRegionId_) 221 #endif 222 223 #if defined(astCLASS) /* Protected */ 224 225 /* Initialiser. */ 226 #define astInitCmpRegion(mem,size,init,vtab,name,reg1,reg2,oper) \ 227 astINVOKE(O,astInitCmpRegion_(mem,size,init,vtab,name,reg1,reg2,oper,STATUS_PTR)) 228 229 /* Vtab Initialiser. */ 230 #define astInitCmpRegionVtab(vtab,name) astINVOKE(V,astInitCmpRegionVtab_(vtab,name,STATUS_PTR)) 231 /* Loader. */ 232 #define astLoadCmpRegion(mem,size,vtab,name,channel) \ 233 astINVOKE(O,astLoadCmpRegion_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR)) 234 #endif 235 236 /* Interfaces to public member functions. */ 237 /* -------------------------------------- */ 238 /* Here we make use of astCheckCmpRegion to validate CmpRegion pointers 239 before use. This provides a contextual error report if a pointer 240 to the wrong sort of Object is supplied. */ 241 242 #if defined(astCLASS) /* Protected */ 243 #define astCmpRegionList(this,nreg,reg_list) \ 244 astINVOKE(V,astCmpRegionList_(this,nreg,reg_list,STATUS_PTR)) 245 #endif 246 #endif 247 248 249 250 251 252