ScopedStopWatch.cpp
Go to the documentation of this file.
1 #include "ScopedStopWatch.h"
2 
3 #include <functional>
4 
5 #include <IceUtil/Time.h>
6 
8 
9 
10 namespace armarx::core::time
11 {
12 
13  ScopedStopWatch::ScopedStopWatch(std::function<void(const Duration&)> callback,
14  ClockType clockType) :
15  StopWatch(clockType), _callback{callback}
16  {
17  // pass
18  }
19 
20 
22  {
23  _callback(stop());
24  }
25 
26 } // namespace armarx::core::time
27 
28 
29 namespace armarx
30 {
31  ScopedStopWatch::ScopedStopWatch(std::function<void(IceUtil::Time)> callback,
32  TimeMode timeMode) :
33  StopWatch(timeMode), m_callback{callback}
34  {
35  // pass
36  }
37 
38 
40  {
41  m_callback(stop());
42  }
43 } // namespace armarx
armarx::core::time::ScopedStopWatch::~ScopedStopWatch
virtual ~ScopedStopWatch() override
Destructs the ScopedStopWatch.
Definition: ScopedStopWatch.cpp:21
armarx::ScopedStopWatch::ScopedStopWatch
ScopedStopWatch(std::function< void(IceUtil::Time)> callback, armarx::TimeMode timeMode=armarx::TimeMode::SystemTime)
Definition: ScopedStopWatch.cpp:31
armarx::core::time
Definition: Clock.cpp:13
armarx::ScopedStopWatch::~ScopedStopWatch
virtual ~ScopedStopWatch() override
Definition: ScopedStopWatch.cpp:39
armarx::core::time::ScopedStopWatch::ScopedStopWatch
ScopedStopWatch(std::function< void(const Duration &)> callback, ClockType clockType=ClockType::Virtual)
Constructs a ScopedStopWatch.
Definition: ScopedStopWatch.cpp:13
armarx::core::time::StopWatch::stop
Duration stop()
Stops the timer and returns the measured duration.
Definition: StopWatch.cpp:43
armarx::core::time::ClockType
ClockType
Describes the type of clock.
Definition: ClockType.h:10
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::TimeMode
TimeMode
Time mode to be used.
Definition: TimeUtil.h:119
TimeUtil.h
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::StopWatch::stop
IceUtil::Time stop()
Definition: StopWatch.cpp:124
armarx::core::time::StopWatch
Measures the passed time between the construction or calling reset() and stop().
Definition: StopWatch.h:42
ScopedStopWatch.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StopWatch
Definition: StopWatch.h:120