Remove dynamic exceptions
[anna.git] / include / anna / time / functions.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_time_functions_hpp
10 #define anna_time_functions_hpp
11
12 #include <string>
13
14
15 namespace anna {
16
17 namespace time {
18
19 class Timezone;
20
21 class functions {
22 public:
23
24   // sets
25
26   /**
27      Initializes global data used on time module. It must be firstly invoked on this module
28   */
29   static void initialize() ;
30
31   /**
32      Initializes reference timestamp used for statistics purposes and neccessary on limited 32-bits architectures
33      in order to avoid overflow for unix timestamps. Time module initizalization timestamp remains if this is not called.
34
35      @param secondsTimestamp Reference timestamp in seconds. By default current is set.
36   */
37   static void setControlPoint(unsigned long long int secondsTimestamp = 0) ;
38
39   /**
40      Gets the seconds reference established by mean #setControlPoint
41   */
42   static unsigned long long int getSecondsReference() ;
43
44
45
46   // gets
47
48   /**
49      Gets initialization state
50   */
51   static bool initialized(void) ;
52
53   /**
54      Gets the host user-supplied timezone configuration
55   */
56   static const Timezone & getSystemTimezone(void) ;
57
58
59   /**
60      Get unix timestamp in seconds
61   */
62   static unsigned long long int unixSeconds() ;
63
64
65   /**
66      Get unix timestamp in milliseconds
67   */
68   static unsigned long long int unixMilliseconds() ;
69
70   /**
71      Get the lapsed milliseconds from the last control point (#setControlPoint) or time module initialization.
72      Used for statistics purposes (performance analysis), specially on 32-bits limited architectures in order
73      to avoid overflow on timestamp structures.
74   */
75   static unsigned long long int lapsedMilliseconds() ;
76
77   /**
78      Get unix timestamp in microseconds
79   */
80   static unsigned long long int unixMicroseconds() ;
81
82
83   /**
84      Get string time representation in format 'HH:mm:ss \<usecs\>'
85      Useful for trace accurated time for events.
86   */
87   static std::string currentTimeAsString(void) ;
88 };
89
90 }
91 }
92
93 #endif
94