fw4spl
HiResTimer.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWCORE_HIRESTIMER_HPP__
8 #define __FWCORE_HIRESTIMER_HPP__
9 
10 #ifdef WIN32
11 #include <windows.h>
12 #else
13 #include <sys/time.h>
14 #endif
15 
16 #include <fwCore/BaseObject.hpp>
17 #include "fwCore/HiResClock.hpp"
18 #include <fwCore/config.hpp>
19 
20 namespace fwCore
21 {
22 
28 class FWCORE_CLASS_API HiResTimer : public BaseObject
29 {
30 public:
32 
37  FWCORE_API HiResTimer();
38  FWCORE_API virtual ~HiResTimer();
39 
45  FWCORE_API void start();
46 
51  FWCORE_API void stop();
52 
59  FWCORE_API void reset(::fwCore::HiResClock::HiResClockType initial_value = 0.);
60 
61 
72  FWCORE_API ::fwCore::HiResClock::HiResClockType getElapsedTimeInSec();
73 
77  FWCORE_API ::fwCore::HiResClock::HiResClockType getElapsedTimeInMilliSec();
78 
82  FWCORE_API ::fwCore::HiResClock::HiResClockType getElapsedTimeInMicroSec();
83 
85 protected:
86 
87 
88 private:
92  ::fwCore::HiResClock::HiResClockType m_startTimeInMicroSec;
96  ::fwCore::HiResClock::HiResClockType m_endTimeInMicroSec;
100  ::fwCore::HiResClock::HiResClockType m_cumulTimeInMicroSec;
104  bool m_stopped;
105 };
106 
107 } //namespace fwCore
108 
109 #endif // __FWCORE_HIRESTIMER_HPP__
This class provide a timer (stopwatch). HiResTimer is able to measure the elapsed time with a few mic...
Definition: HiResTimer.hpp:28
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
double HiResClockType
Type returned by HiResClock Functions.
Definition: HiResClock.hpp:29
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.