TimeBase.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
29 //----------------------------------------------------------------------
30 #ifndef ICL_CORE_TIME_BASE_H_INCLUDED
31 #define ICL_CORE_TIME_BASE_H_INCLUDED
32 
33 #include "icl_core/BaseTypes.h"
34 #include "icl_core/ImportExport.h"
35 #include "icl_core/os.h"
36 
37 #ifdef _IC_BUILDER_HAS_TIME_H_
38 # include <time.h>
39 #endif
40 #ifdef _IC_BUILDER_HAS_SYS_TIME_H_
41 # include <sys/time.h>
42 #endif
43 
44 #ifdef _SYSTEM_DARWIN_
45 # include <mach/clock_types.h>
46 #endif
47 
48 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
49 # include "icl_core/Deprecate.h"
50 #endif
51 
52 namespace icl_core {
53 
55 
60 {
61 public:
63  TimeBase& operator += (const TimeBase& span);
64 
66  TimeBase& operator -= (const TimeBase& span);
67 
71  bool operator != (const TimeBase& other) const;
72 
76  bool operator == (const TimeBase& other) const;
77 
82  bool operator < (const TimeBase& other) const;
83 
87  bool operator > (const TimeBase& other) const;
88 
93  bool operator <= (const TimeBase& other) const;
94 
99  bool operator >= (const TimeBase& other) const;
100 
104  void normalizeTime();
105 
107  int64_t days() const
108  {
109  return secs / 86400;
110  }
111 
115  int64_t hours() const
116  {
117  return secs / 3600 % 24;
118  }
119 
123  int64_t minutes() const
124  {
125  return (secs % 3600) / 60;
126  }
127 
131  int64_t seconds() const
132  {
133  return (secs % 3600) % 60;
134  }
135 
140  {
141  return nsecs / 1000000;
142  }
143 
148  {
149  return nsecs / 1000;
150  }
151 
156  {
157  return nsecs % 1000;
158  }
159 
161  int64_t tbSec() const { return secs; }
163  int32_t tbNSec() const { return nsecs; }
164 
171  struct timespec timespec() const;
172 
177  struct timespec systemTimespec() const;
178 
179 #ifdef _SYSTEM_DARWIN_
180  mach_timespec_t machTimespec() const;
182 #endif
183 
185 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
186 
192 
197 
203 
209 
215 
221 
227 
233 
242 
250  ICL_CORE_VC_DEPRECATE_STYLE struct timespec Timespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
251 
256  ICL_CORE_VC_DEPRECATE_STYLE struct timespec SystemTimespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
257 
258 #ifdef _SYSTEM_DARWIN_
259 
262  ICL_CORE_VC_DEPRECATE_STYLE mach_timespec_t MachTimespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
263 #endif
264 
265 #endif
266 
268 protected:
269 
270  static TimeBase maxTime();
271 
272  explicit TimeBase(int64_t secs=0, int32_t nsecs=0);
273 
274  TimeBase(const struct timespec& time);
275 
276  void fromTimespec(const struct timespec& time);
277 
279 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
280 
282 
283  ICL_CORE_VC_DEPRECATE_STYLE void FromTimespec(const struct timespec& time) ICL_CORE_GCC_DEPRECATE_STYLE;
284 
285 #endif
286 
290 };
291 
292 }
293 
294 #endif
signed int int32_t
Definition: msvc_stdint.h:90
int32_t nanoSeconds() const
Definition: TimeBase.h:155
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
int32_t milliSeconds() const
Definition: TimeBase.h:139
int64_t minutes() const
Definition: TimeBase.h:123
int64_t tbSec() const
Returns the second part of this time.
Definition: TimeBase.h:161
int32_t tbNSec() const
Returns the nanosecond part of this time.
Definition: TimeBase.h:163
int64_t days() const
Use this function if you want to express the time in days.
Definition: TimeBase.h:107
Contains macros to deprecate classes, types, functions and variables.
#define ICL_CORE_IMPORT_EXPORT
Definition: ImportExport.h:42
signed __int64 int64_t
Definition: msvc_stdint.h:102
Contains global functions, encapsulated into the icl_core::os namespace.
Repesents time values.
Definition: TimeBase.h:59
bool operator==(const ThreadId &left, const ThreadId &right)
int32_t microSeconds() const
Definition: TimeBase.h:147
Contains import/export definitions for the Win32 plattform.
Contains Interface base classes and base types.
int64_t hours() const
Definition: TimeBase.h:115
int64_t seconds() const
Definition: TimeBase.h:131
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58