1 #if !defined( TIMEFRAME_INCLUDED ) /* Include this file only once */ 2 #define TIMEFRAME_INCLUDED 3 /* 4 *+ 5 * Name: 6 * timeframe.h 7 8 * Type: 9 * C include file. 10 11 * Purpose: 12 * Define the interface to the TimeFrame class. 13 14 * Invocation: 15 * #include "timeframe.h" 16 17 * Description: 18 * This include file defines the interface to the TimeFrame class 19 * and provides the type definitions, function prototypes and 20 * macros, etc. needed to use this class. 21 22 * Copyright: 23 * Copyright (C) 1997-2006 Council for the Central Laboratory of the 24 * Research Councils 25 26 * Licence: 27 * This program is free software: you can redistribute it and/or 28 * modify it under the terms of the GNU Lesser General Public 29 * License as published by the Free Software Foundation, either 30 * version 3 of the License, or (at your option) any later 31 * version. 32 * 33 * This program is distributed in the hope that it will be useful, 34 * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 * GNU Lesser General Public License for more details. 37 * 38 * You should have received a copy of the GNU Lesser General 39 * License along with this program. If not, see 40 * <http://www.gnu.org/licenses/>. 41 42 * Authors: 43 * DSB: David S. Berry (Starlink) 44 45 * History: 46 * 20-MAY-2005 (DSB): 47 * Original version. 48 *- 49 */ 50 51 /* Include files. */ 52 /* ============== */ 53 /* Interface definitions. */ 54 /* ---------------------- */ 55 #include "object.h" /* Base Object class */ 56 #include "frame.h" /* Parent Frame class */ 57 #include "skyframe.h" /* Celestial coordinate systems */ 58 59 /* Macros. */ 60 /* ======= */ 61 #if defined(astCLASS) || defined(astFORTRAN77) 62 #define STATUS_PTR status 63 #else 64 #define STATUS_PTR astGetStatusPtr 65 #endif 66 67 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */ 68 #ifndef __GNUC__ 69 # define __attribute__(x) /*NOTHING*/ 70 #endif 71 72 #if defined(astCLASS) /* Protected */ 73 74 /* Values used to represent different System attribute values. */ 75 #define AST__MJD 1 76 #define AST__JD 2 77 #define AST__JEPOCH 3 78 #define AST__BEPOCH 4 79 80 /* Values used to represent different TimeScale attribute values. */ 81 #define AST__BADTS 0 82 #define AST__TAI 1 83 #define AST__UTC 2 84 #define AST__UT1 3 85 #define AST__GMST 4 86 #define AST__LAST 5 87 #define AST__LMST 6 88 #define AST__TT 7 89 #define AST__TDB 8 90 #define AST__TCB 9 91 #define AST__TCG 10 92 #define AST__LT 11 93 94 /* Define constants used to size global arrays in this module. */ 95 #define AST__TIMEFRAME_FORMAT_BUFF_LEN 200 96 #define AST__TIMEFRAME_GETATTRIB_BUFF_LEN 50 97 #define AST__TIMEFRAME_GETLABEL_BUFF_LEN 200 98 #define AST__TIMEFRAME_GETSYMBOL_BUFF_LEN 20 99 #define AST__TIMEFRAME_GETTITLE_BUFF_LEN 200 100 101 #endif 102 103 /* Type Definitions. */ 104 /* ================= */ 105 106 /* Integer type used to store the TimeScale attribute. */ 107 typedef int AstTimeScaleType; 108 109 /* TimeFrame structure. */ 110 /* ------------------- */ 111 /* This structure contains all information that is unique to each object in 112 the class (e.g. its instance variables). */ 113 typedef struct AstTimeFrame { 114 115 /* Attributes inherited from the parent class. */ 116 AstFrame frame; /* Parent class structure */ 117 118 /* Attributes specific to objects in this class. */ 119 double ltoffset; /* Offset from UTC to Local Time */ 120 double timeorigin; /* Zero point for time axis */ 121 AstTimeScaleType timescale; /* Time scale */ 122 AstTimeScaleType aligntimescale; /* Alignment time scale */ 123 } AstTimeFrame; 124 125 /* Virtual function table. */ 126 /* ----------------------- */ 127 /* This table contains all information that is the same for all objects in the 128 class (e.g. pointers to its virtual functions). */ 129 #if defined(astCLASS) /* Protected */ 130 typedef struct AstTimeFrameVtab { 131 132 /* Properties (e.g. methods) inherited from the parent class. */ 133 AstFrameVtab frame_vtab; /* Parent class virtual function table */ 134 135 /* A Unique identifier to determine class membership. */ 136 AstClassIdentifier id; 137 138 /* Properties (e.g. methods) specific to this class. */ 139 double (* CurrentTime)( AstTimeFrame *, int * ); 140 141 double (* GetLTOffset)( AstTimeFrame *, int * ); 142 int (* TestLTOffset)( AstTimeFrame *, int * ); 143 void (* ClearLTOffset)( AstTimeFrame *, int * ); 144 void (* SetLTOffset)( AstTimeFrame *, double, int * ); 145 146 double (* GetTimeOrigin)( AstTimeFrame *, int * ); 147 int (* TestTimeOrigin)( AstTimeFrame *, int * ); 148 void (* ClearTimeOrigin)( AstTimeFrame *, int * ); 149 void (* SetTimeOrigin)( AstTimeFrame *, double, int * ); 150 151 AstTimeScaleType (* GetTimeScale)( AstTimeFrame *, int * ); 152 int (* TestTimeScale)( AstTimeFrame *, int * ); 153 void (* ClearTimeScale)( AstTimeFrame *, int * ); 154 void (* SetTimeScale)( AstTimeFrame *, AstTimeScaleType, int * ); 155 156 AstTimeScaleType (* GetAlignTimeScale)( AstTimeFrame *, int * ); 157 int (* TestAlignTimeScale)( AstTimeFrame *, int * ); 158 void (* ClearAlignTimeScale)( AstTimeFrame *, int * ); 159 void (* SetAlignTimeScale)( AstTimeFrame *, AstTimeScaleType, int * ); 160 161 } AstTimeFrameVtab; 162 163 #if defined(THREAD_SAFE) 164 165 /* Define a structure holding all data items that are global within this 166 class. */ 167 typedef struct AstTimeFrameGlobals { 168 AstTimeFrameVtab Class_Vtab; 169 int Class_Init; 170 char Format_Buff[ AST__TIMEFRAME_FORMAT_BUFF_LEN + 1 ]; 171 char GetAttrib_Buff[ AST__TIMEFRAME_GETATTRIB_BUFF_LEN + 1 ]; 172 char GetLabel_Buff[ AST__TIMEFRAME_GETLABEL_BUFF_LEN + 1 ]; 173 char GetSymbol_Buff[ AST__TIMEFRAME_GETSYMBOL_BUFF_LEN + 1 ]; 174 char GetTitle_Buff[ AST__TIMEFRAME_GETTITLE_BUFF_LEN + 1 ]; 175 } AstTimeFrameGlobals; 176 177 #endif 178 179 #endif 180 181 /* Function prototypes. */ 182 /* ==================== */ 183 /* Prototypes for standard class functions. */ 184 /* ---------------------------------------- */ 185 astPROTO_CHECK(TimeFrame) /* Check class membership */ 186 astPROTO_ISA(TimeFrame) /* Test class membership */ 187 188 /* Constructor. */ 189 #if defined(astCLASS) /* Protected */ 190 AstTimeFrame *astTimeFrame_( const char *, int *, ...); 191 #else 192 AstTimeFrame *astTimeFrameId_( const char *, ... )__attribute__((format(printf,1,2))); 193 #endif 194 195 #if defined(astCLASS) /* Protected */ 196 197 /* Initialiser. */ 198 AstTimeFrame *astInitTimeFrame_( void *, size_t, int, AstTimeFrameVtab *, 199 const char *, int * ); 200 201 /* Vtab initialiser. */ 202 void astInitTimeFrameVtab_( AstTimeFrameVtab *, const char *, int * ); 203 204 /* Loader. */ 205 AstTimeFrame *astLoadTimeFrame_( void *, size_t, AstTimeFrameVtab *, 206 const char *, AstChannel *channel, int * ); 207 208 /* Thread-safe initialiser for all global data used by this module. */ 209 #if defined(THREAD_SAFE) 210 void astInitTimeFrameGlobals_( AstTimeFrameGlobals * ); 211 #endif 212 213 #endif 214 215 /* Prototypes for member functions. */ 216 /* -------------------------------- */ 217 double astCurrentTime_( AstTimeFrame *, int * ); 218 219 #if defined(astCLASS) /* Protected */ 220 221 double astGetLTOffset_( AstTimeFrame *, int * ); 222 int astTestLTOffset_( AstTimeFrame *, int * ); 223 void astClearLTOffset_( AstTimeFrame *, int * ); 224 void astSetLTOffset_( AstTimeFrame *, double, int * ); 225 226 double astGetTimeOrigin_( AstTimeFrame *, int * ); 227 int astTestTimeOrigin_( AstTimeFrame *, int * ); 228 void astClearTimeOrigin_( AstTimeFrame *, int * ); 229 void astSetTimeOrigin_( AstTimeFrame *, double, int * ); 230 231 AstTimeScaleType astGetTimeScale_( AstTimeFrame *, int * ); 232 int astTestTimeScale_( AstTimeFrame *, int * ); 233 void astClearTimeScale_( AstTimeFrame *, int * ); 234 void astSetTimeScale_( AstTimeFrame *, AstTimeScaleType, int * ); 235 236 AstTimeScaleType astGetAlignTimeScale_( AstTimeFrame *, int * ); 237 int astTestAlignTimeScale_( AstTimeFrame *, int * ); 238 void astClearAlignTimeScale_( AstTimeFrame *, int * ); 239 void astSetAlignTimeScale_( AstTimeFrame *, AstTimeScaleType, int * ); 240 #endif 241 242 /* Function interfaces. */ 243 /* ==================== */ 244 /* These macros are wrap-ups for the functions defined by this class 245 to make them easier to invoke (e.g. to avoid type mis-matches when 246 passing pointers to objects from derived classes). */ 247 248 /* Interfaces to standard class functions. */ 249 /* --------------------------------------- */ 250 /* Some of these functions provide validation, so we cannot use them 251 to validate their own arguments. We must use a cast when passing 252 object pointers (so that they can accept objects from derived 253 classes). */ 254 255 /* Check class membership. */ 256 #define astCheckTimeFrame(this) astINVOKE_CHECK(TimeFrame,this,0) 257 #define astVerifyTimeFrame(this) astINVOKE_CHECK(TimeFrame,this,1) 258 259 /* Test class membership. */ 260 #define astIsATimeFrame(this) astINVOKE_ISA(TimeFrame,this) 261 262 /* Constructor. */ 263 #if defined(astCLASS) /* Protected */ 264 #define astTimeFrame astINVOKE(F,astTimeFrame_) 265 #else 266 #define astTimeFrame astINVOKE(F,astTimeFrameId_) 267 #endif 268 269 #if defined(astCLASS) /* Protected */ 270 271 /* Initialiser. */ 272 #define astInitTimeFrame(mem,size,init,vtab,name) \ 273 astINVOKE(O,astInitTimeFrame_(mem,size,init,vtab,name,STATUS_PTR)) 274 275 /* Vtab Initialiser. */ 276 #define astInitTimeFrameVtab(vtab,name) astINVOKE(V,astInitTimeFrameVtab_(vtab,name,STATUS_PTR)) 277 /* Loader. */ 278 #define astLoadTimeFrame(mem,size,vtab,name,channel) \ 279 astINVOKE(O,astLoadTimeFrame_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR)) 280 281 #endif 282 283 /* Interfaces to public member functions. */ 284 /* -------------------------------------- */ 285 286 /* None. */ 287 288 /* Interfaces to protected member functions. */ 289 /* ----------------------------------------- */ 290 /* Here we make use of astCheckTimeFrame to validate TimeFrame pointers 291 before use. This provides a contextual error report if a pointer to 292 the wrong sort of object is supplied. */ 293 294 #define astCurrentTime(this) astINVOKE(V,astCurrentTime_(astCheckTimeFrame(this),STATUS_PTR)) 295 296 #if defined(astCLASS) /* Protected */ 297 298 #define astGetTimeOrigin(this) astINVOKE(V,astGetTimeOrigin_(astCheckTimeFrame(this),STATUS_PTR)) 299 #define astTestTimeOrigin(this) astINVOKE(V,astTestTimeOrigin_(astCheckTimeFrame(this),STATUS_PTR)) 300 #define astClearTimeOrigin(this) astINVOKE(V,astClearTimeOrigin_(astCheckTimeFrame(this),STATUS_PTR)) 301 #define astSetTimeOrigin(this,value) astINVOKE(V,astSetTimeOrigin_(astCheckTimeFrame(this),value,STATUS_PTR)) 302 303 #define astGetLTOffset(this) astINVOKE(V,astGetLTOffset_(astCheckTimeFrame(this),STATUS_PTR)) 304 #define astTestLTOffset(this) astINVOKE(V,astTestLTOffset_(astCheckTimeFrame(this),STATUS_PTR)) 305 #define astClearLTOffset(this) astINVOKE(V,astClearLTOffset_(astCheckTimeFrame(this),STATUS_PTR)) 306 #define astSetLTOffset(this,value) astINVOKE(V,astSetLTOffset_(astCheckTimeFrame(this),value,STATUS_PTR)) 307 308 #define astGetTimeScale(this) astINVOKE(V,astGetTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 309 #define astTestTimeScale(this) astINVOKE(V,astTestTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 310 #define astClearTimeScale(this) astINVOKE(V,astClearTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 311 #define astSetTimeScale(this,value) astINVOKE(V,astSetTimeScale_(astCheckTimeFrame(this),value,STATUS_PTR)) 312 313 #define astGetAlignTimeScale(this) astINVOKE(V,astGetAlignTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 314 #define astTestAlignTimeScale(this) astINVOKE(V,astTestAlignTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 315 #define astClearAlignTimeScale(this) astINVOKE(V,astClearAlignTimeScale_(astCheckTimeFrame(this),STATUS_PTR)) 316 #define astSetAlignTimeScale(this,value) astINVOKE(V,astSetAlignTimeScale_(astCheckTimeFrame(this),value,STATUS_PTR)) 317 318 #endif 319 #endif 320 321 322 323 324 325