iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
imstkTaskNode.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkTaskNode.h"
8 #include "imstkTimer.h"
9 
10 namespace imstk
11 {
12 std::atomic<size_t> TaskNode::s_numGlobalIds = { 0 };
13 
14 void
16 {
17  if (m_enabled && m_func != nullptr)
18  {
19  if (!m_enableTiming)
20  {
21  m_func();
22  }
23  else
24  {
25  StopWatch timer;
26  timer.start();
27  m_func();
28  m_computeTime = timer.getTimeElapsed();
29  timer.stop();
30  }
31  }
32  else
33  {
34  m_computeTime = 0.0;
35  }
36 }
37 } // namespace imstk
virtual void start()
Start the appropriate timer.
Definition: imstkTimer.cpp:29
Compound Geometry.
std::function< void()> m_func
Don&#39;t allow user to call directly (must use execute)
Definition: imstkTaskNode.h:99
virtual void stop()
Start the appropriate timer.
Definition: imstkTimer.cpp:36
Stop Watch utility class.
Definition: imstkTimer.h:19
virtual double getTimeElapsed(const TimeUnitType unitType=TimeUnitType::milliSeconds)
Returns the time elapsed since calling start.
Definition: imstkTimer.cpp:136
virtual void execute()
Calls the function pointer provided if node enabled.