LeapSeconds.h
Go to the documentation of this file.
1 #ifndef _utl_LeapSeconds_h_
2 #define _utl_LeapSeconds_h_
3 
4 #include <string>
5 #include <map>
6 #include <ctime>
7 #include <utl/Singleton.h>
8 
9 
10 namespace utl {
11 
28  class LeapSeconds : public Singleton<LeapSeconds> {
29  private:
30  // pair contains leap and accumulated leaps
31  typedef std::map<unsigned long, std::pair<int, int> > GPSToUnixMap;
32  typedef GPSToUnixMap::const_iterator GPSToUnixIterator;
33 
34  typedef std::map<std::time_t, long> UnixToGPSMap;
35  typedef UnixToGPSMap::const_iterator UnixToGPSIterator;
36 
37  public:
38  LeapSeconds() : fTZ(0) { Init(); SetUTC(); }
40 
42  bool ConvertGPSToUnix(const unsigned long gpsSecond, time_t& unixSecond) const;
43 
44  void ConvertUnixToGPS(const time_t unixSecond, unsigned long& gpsSecond) const;
45 
46  void Dump() const;
47 
48  private:
49  void Init();
50 
51  void SetUTC();
52 
53  void UnsetUTC();
54 
56 
59  std::string* fTZ;
60  };
61 
62 }
63 
64 
65 #endif
GPSToUnixMap fGPSToUnixLeaps
Definition: LeapSeconds.h:57
UnixToGPSMap::const_iterator UnixToGPSIterator
Definition: LeapSeconds.h:35
std::map< std::time_t, long > UnixToGPSMap
Definition: LeapSeconds.h:34
std::string * fTZ
Definition: LeapSeconds.h:59
bool ConvertGPSToUnix(const unsigned long gpsSecond, time_t &unixSecond) const
returns true if the GPS second is an UTC leap second
Definition: LeapSeconds.cc:11
UnixToGPSMap fUnixToGPSLeaps
Definition: LeapSeconds.h:58
GPSToUnixMap::const_iterator GPSToUnixIterator
Definition: LeapSeconds.h:32
void Dump() const
Definition: LeapSeconds.cc:90
std::time_t fGPSEpochInUnixSeconds
Definition: LeapSeconds.h:55
void ConvertUnixToGPS(const time_t unixSecond, unsigned long &gpsSecond) const
Definition: LeapSeconds.cc:25
Curiously Recurring Template Pattern (CRTP) for Meyers singleton.
Definition: Singleton.h:36
std::map< unsigned long, std::pair< int, int > > GPSToUnixMap
Definition: LeapSeconds.h:31

, generated on Tue Sep 26 2023.