AnitaVersion.h
1 #ifndef _ANITA_VERSION_H
2 #define _ANITA_VERSION_H
3 
4 /******************************************************************************
5  *
6  * AnitaVersion.h
7  *
8  * Cosmin Deaconu <cozzyd@kicp.uchicago.edu> Jan 2017
9  *
10  * INTRODUCTION
11  *
12  * This file is part of an attempt at allowing multiple ANITA versions with
13  * the same code base.
14  *
15  * In this header the interface for setting and querying the ANITA version is
16  * exposed. This header file will also serve as the documentation for the
17  * versioning implementation progress
18  *
19  * Initially 3 and 4 will be supported. 2 Could also be made to be supported
20  * with a bit more work.
21  *
22  *
23  * USAGE
24  *
25  * You can always set the current anita version by using AnitaVersion::set()
26  * (but keep in mind that it might get set again automatically). Use
27  * AnitaVersion::get() to find out what the current version is set to.
28  *
29  * In some cases (e.g. when using AnitaDataset, or constructing a
30  * UsefulAnitaEvent from a header), the ANITA version may be automatically
31  * detected and set appropriately.
32  *
33  *
34  * Some singleton classes have been converted to one instance per anita version
35  * (i.e. AnitaEventCalibrator, AnitaGeomTool). One must beware of reusing the
36  * pointer to the instance if one is switch between ANITA versions within the
37  * same context. It is always safe to call e.g. AnitaGeomTool::Instance() and
38  * that will dispatch the currently set version, albeit perhaps at the cost of
39  * a performance penalty.
40  *
41  * By default, the implementation is not thread-safe. If you plan on processing
42  * different ANITA verisons in different threads you may define the
43  * THREADSAFE_ANITA_VERSION compile-time-flag. Note that this requires compiler
44  * and standard library support for thread-specific-storage and may impose a
45  * small performance penalty.
46  *
47  *
48  * PROGRESS MADE SO FAR
49  *
50  * AnitaGeomTool dispatches Instances based on version, also checks for correct constants
51  *
52  * AnitaEventCalibrator dispatches Instances based on version, also checks for correct constants
53  *
54  * AnitaDataset sets version based on header each time.
55  *
56  * UsefulAnitaEvent sets version sometimes (if constructed with something that has a time). Also AlfaFilterFlag set based on version.
57  *
58  * RawAnitaHeader manual schema migration
59  *
60  * TurfRate manual schema migration and compatibility structure.
61  *
62  * SurfHK added methods for both A3 and A4 for l1 scalers.
63  *
64  *
65  * TODO
66  *
67  * Need phase centers and such for A4
68  *
69  * Many of the constants in AnitaConventions need to be dispatched according to version.
70  *
71  * Handle the following, which are not currently backward's compatible:
72  *
73  * CalibratedHk
74  * Probably other stuff...
75  *
76  ******************************************************************************/
77 
78 
79 
81 #ifndef DEFAULT_ANITA_VERSION
82 #define DEFAULT_ANITA_VERSION 4
83 #endif
84 
85 
87 #define MULTIVERSION_ANITA_ENABLED 1
88 
89 
90 namespace AnitaVersion
91 {
92 
98  void set(int anitaVersion);
99 
101  int get();
102 
103 
106  int getVersionFromUnixTime(unsigned time);
107 
112  int setVersionFromUnixTime(unsigned time);
113 
114 
115 }
116 
117 
118 
119 #endif