Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSystem/JTime.hh
Go to the documentation of this file.
1 #ifndef __JSYSTEM__JTIME__
2 #define __JSYSTEM__JTIME__
3 
4 #include <time.h>
5 #include <sys/time.h>
6 
7 
8 /**
9  * \file
10  * System time information.
11  * \author mdejong
12  */
13 namespace JSYSTEM {}
14 namespace JPP { using namespace JSYSTEM; }
15 
16 namespace JSYSTEM {
17 
18  /**
19  * Type definition of local time.
20  */
21  typedef long long int localtime_t;
22 
23 
24  /**
25  * Auxililary class to local get time in micro seconds.
26  */
27  struct JLocalTime {
28  /**
29  * Default constructor.
30  */
32  {}
33 
34 
35  /**
36  * Get local time in micro seconds.
37  *
38  * \return time [us]
39  */
41  {
42  gettimeofday(&t, &tz);
43 
44  usec = t.tv_sec;
45  usec *= 1000000ULL;
46  usec += t.tv_usec;
47 
48  return usec;
49  }
50 
51  private:
52  mutable localtime_t usec;
53  mutable struct timeval t;
54  mutable struct timezone tz;
55  };
56 
57 
58  /**
59  * Function object to get local time in micro seconds.
60  */
61  static const JLocalTime getLocalTime;
62 }
63 
64 #endif
struct timezone tz
Auxililary class to local get time in micro seconds.
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
struct timeval t
JLocalTime()
Default constructor.
long long int localtime_t
Type definition of local time.
localtime_t operator()() const
Get local time in micro seconds.