timer++.h
1 /***************************************************************************
2  *
3  * Copyright (C) 1999 by Willem van Straten
4  * Licensed under the Academic Free License version 2.1
5  *
6  ***************************************************************************/
7 // psrchive/Base/Formats/Timer/timer++.h
8 
9 #ifndef __TIMER_PLUSPLUS_H
10 #define __TIMER_PLUSPLUS_H
11 
12 // ////////////////////////////////////////////////////////////////////
13 // C++ methods that perform operations on the timer struct
14 // or calculations with the timer struct
15 //
16 // call these functions like: Timer::load, etc.
17 //
18 // ////////////////////////////////////////////////////////////////////
19 
20 #include <stdio.h>
21 #include "timer.h"
22 #include "MJD.h"
23 
24 namespace Timer {
25 
26  extern bool verbose;
27 
28  const int nbackends = 2;
29 
30  // returns the size of the additional backend information, or 0 if none
31  unsigned long backend_data_size(const struct timer& hdr);
32 
33  // returns index of code in 'backends' or -1 if not recognized
34  int backend_recognized (const char* backend);
35 
36  // sets the name of the backend in 'hdr' to 'backend'
37  // returns 0 if successful, -1 otherwise
38  int set_backend (struct timer* hdr, const char* backend);
39 
40  // returns a string containing the backend code, or "un-recognized" if so
41  std::string get_backend (const struct timer& hdr);
42 
43  // may be used to receive soft error messages
44  extern std::string reason;
45 
46  // loads a timer struct, givent a file name
47  int fload (const char* fname, struct timer* hdr, bool big_endian=true);
48 
49  // loads a timer struct from a file pointer
50  int load (FILE* fptr, struct timer* hdr, bool big_endian=true);
51 
52  // unloads a timer struct to a file (always big endian)
53  int unload (FILE* fptr, const struct timer& hdr);
54 
55  // returns the MJD from a timer struct
56  MJD get_MJD (const struct timer& hdr);
57 
58  // sets the MJD in a mini struct
59  void set_MJD (struct timer& hdr, const MJD& mjd);
60 
61  // returns the number of polarizations
62  int get_npol (const struct timer& hdr);
63  void set_npol (struct timer& hdr, int npol);
64 
65  // returns true if two archives can be mixed (tadded, for instance)
66  // set max_freq_sep if you wish to alter the action of this function
67  bool mixable (const timer& hdr1, const timer& arch2,
68  double max_freq_sep = 0.10 /* 100kHz */,
69  bool allow_opposite_sideband = false);
70 
71  bool cal_mixable (const timer& hdr1, const timer& arch2,
72  double max_freq_sep = 0.10 /* 100kHz */,
73  bool allow_opposite_sideband = false);
74 
75  // a function to set most of timer struct to NULL values.
76  void init (struct timer * hdr);
77 
78  // return true if timer struct seems valid enough
79  bool is_timer (const struct timer& hdr, std::string* reason = 0);
80 
81 }
82 
83 #endif // __TIMER_PLUSPLUS_H
bool verbose
Definition: timer++.C:25

Generated using doxygen 1.8.17