TimeBase.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00029 //----------------------------------------------------------------------
00030 #ifndef ICL_CORE_TIME_BASE_H_INCLUDED
00031 #define ICL_CORE_TIME_BASE_H_INCLUDED
00032 
00033 #include "icl_core/BaseTypes.h"
00034 #include "icl_core/ImportExport.h"
00035 #include "icl_core/os.h"
00036 
00037 #ifdef _IC_BUILDER_HAS_TIME_H_
00038 # include <time.h>
00039 #endif
00040 #ifdef _IC_BUILDER_HAS_SYS_TIME_H_
00041 # include <sys/time.h>
00042 #endif
00043 
00044 #ifdef _SYSTEM_DARWIN_
00045 # include <mach/clock_types.h>
00046 #endif
00047 
00048 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00049 # include "icl_core/Deprecate.h"
00050 #endif
00051 
00052 namespace icl_core {
00053 
00055 
00059 class ICL_CORE_IMPORT_EXPORT TimeBase
00060 {
00061 public:
00063   TimeBase& operator += (const TimeBase& span);
00064 
00066   TimeBase& operator -= (const TimeBase& span);
00067 
00071   bool operator != (const TimeBase& other) const;
00072 
00076   bool operator == (const TimeBase& other) const;
00077 
00082   bool operator < (const TimeBase& other) const;
00083 
00087   bool operator > (const TimeBase& other) const;
00088 
00093   bool operator <= (const TimeBase& other) const;
00094 
00099   bool operator >= (const TimeBase& other) const;
00100 
00104   void normalizeTime();
00105 
00107   int64_t days() const
00108   {
00109     return secs / 86400;
00110   }
00111 
00115   int64_t hours() const
00116   {
00117     return secs / 3600 % 24;
00118   }
00119 
00123   int64_t minutes() const
00124   {
00125     return (secs % 3600) / 60;
00126   }
00127 
00131   int64_t seconds() const
00132   {
00133     return (secs % 3600) % 60;
00134   }
00135 
00139   int32_t milliSeconds() const
00140   {
00141     return nsecs / 1000000;
00142   }
00143 
00147   int32_t microSeconds() const
00148   {
00149     return nsecs / 1000;
00150   }
00151 
00155   int32_t nanoSeconds() const
00156   {
00157     return nsecs % 1000;
00158   }
00159 
00161   int64_t tbSec() const { return secs; }
00163   int32_t tbNSec() const { return nsecs; }
00164 
00171   struct timespec timespec() const;
00172 
00177   struct timespec systemTimespec() const;
00178 
00179 #ifdef _SYSTEM_DARWIN_
00180 
00181   mach_timespec_t machTimespec() const;
00182 #endif
00183 
00185 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00186 
00191   ICL_CORE_VC_DEPRECATE_STYLE void NormalizeTime() ICL_CORE_GCC_DEPRECATE_STYLE;
00192 
00196   ICL_CORE_VC_DEPRECATE_STYLE int64_t Days() const ICL_CORE_GCC_DEPRECATE_STYLE;
00197 
00202   ICL_CORE_VC_DEPRECATE_STYLE int64_t Hours() const ICL_CORE_GCC_DEPRECATE_STYLE;
00203 
00208   ICL_CORE_VC_DEPRECATE_STYLE int64_t Minutes() const ICL_CORE_GCC_DEPRECATE_STYLE;
00209 
00214   ICL_CORE_VC_DEPRECATE_STYLE int64_t Seconds() const ICL_CORE_GCC_DEPRECATE_STYLE;
00215 
00220   ICL_CORE_VC_DEPRECATE_STYLE int32_t MilliSeconds() const ICL_CORE_GCC_DEPRECATE_STYLE;
00221 
00226   ICL_CORE_VC_DEPRECATE_STYLE int32_t MicroSeconds() const ICL_CORE_GCC_DEPRECATE_STYLE;
00227 
00232   ICL_CORE_VC_DEPRECATE_STYLE int32_t NanoSeconds() const ICL_CORE_GCC_DEPRECATE_STYLE;
00233 
00237   ICL_CORE_VC_DEPRECATE_STYLE int64_t TbSec() const ICL_CORE_GCC_DEPRECATE_STYLE;
00241   ICL_CORE_VC_DEPRECATE_STYLE int32_t TbNSec() const ICL_CORE_GCC_DEPRECATE_STYLE;
00242 
00250   ICL_CORE_VC_DEPRECATE_STYLE struct timespec Timespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
00251 
00256   ICL_CORE_VC_DEPRECATE_STYLE struct timespec SystemTimespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
00257 
00258 #ifdef _SYSTEM_DARWIN_
00259 
00262   ICL_CORE_VC_DEPRECATE_STYLE mach_timespec_t MachTimespec() const ICL_CORE_GCC_DEPRECATE_STYLE;
00263 #endif
00264 
00265 #endif
00266 
00267 
00268 protected:
00269 
00270   static TimeBase maxTime();
00271 
00272   explicit TimeBase(int64_t secs=0, int32_t nsecs=0);
00273 
00274   TimeBase(const struct timespec& time);
00275 
00276   void fromTimespec(const struct timespec& time);
00277 
00279 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00280 
00281   static ICL_CORE_VC_DEPRECATE_STYLE TimeBase MaxTime() ICL_CORE_GCC_DEPRECATE_STYLE;
00282 
00283   ICL_CORE_VC_DEPRECATE_STYLE void FromTimespec(const struct timespec& time) ICL_CORE_GCC_DEPRECATE_STYLE;
00284 
00285 #endif
00286 
00287 
00288   int64_t secs;
00289   int32_t nsecs;
00290 };
00291 
00292 }
00293 
00294 #endif


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24