MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitk::IGTTimeStamp Class Reference

Time stamp in milliseconds. More...

#include <mitkIGTTimeStamp.h>

Inheritance diagram for mitk::IGTTimeStamp:

Public Member Functions

 mitkClassMacroItkParent (IGTTimeStamp, itk::Object)
 
void Start (itk::Object::Pointer device)
 starts the time-acquisition
 
void Stop (itk::Object::Pointer device)
 stops the time-acqusition
 
double GetElapsed ()
 returns the time elapsed since calling Start() for the first time in milliseconds
 
double GetElapsed (itk::Object::Pointer device)
 returns the time elapsed since 'device' called Start() in milliseconds
 
double GetOffset (itk::Object::Pointer Device)
 returns the offset of this device's starting-time to the reference-time in ms
 
void SetRealTimeClock (mitk::RealTimeClock::Pointer Clock)
 setter for the internally used RealTimeClock()
 
void Initialize ()
 creates a new RealTimeClock
 

Static Public Member Functions

static IGTTimeStampCreateInstance ()
 creates a new instance of mitkTimeStamp
 
static IGTTimeStampGetInstance ()
 returns a pointer to the current instance of mitkTimeStamp
 

Protected Member Functions

 IGTTimeStamp ()
 
 ~IGTTimeStamp () override
 
double GetCurrentStamp ()
 

Protected Attributes

double m_Time
 
double m_ReferenceTime
 
mitk::RealTimeClock::Pointer m_RealTimeClock
 
std::map< itk::Object::Pointer, double > m_DeviceMap
 
std::map< itk::Object::Pointer, double >::iterator m_MapIterator
 

Static Protected Attributes

static mitk::IGTTimeStamp::Pointer s_Instance = nullptr
 

Detailed Description

Time stamp in milliseconds.

This class provides a timestamp in milliseconds. It is a Singleton class, that internally uses a mitkRealTimeClock() for time-acquisition.

First you have to call Start() in order to set the reference-time to the current time. If the user has not created and set his own "RealTimeClock", initialize() will be called and a default mitkRealTimeClock() is created. In addition the TimeStamp() saves a pointer to the device calling and the respective offset-time. The first device will have an offset of 0, the following's offset will be the time elapsed since the starting of the first device. This offset can be prompted by calling GetOffset();

You can always get the time elapsed since calling Start() with GetElapsed(). It returns the time spent in milliseconds as a double.

When the TimeStamp is no longer used, you can call Stop(). This erases the pointer to the device and the offset. When all devices have "stopped tracking" the reference-time and the current-time are reset to 0.

Definition at line 48 of file mitkIGTTimeStamp.h.

Constructor & Destructor Documentation

◆ IGTTimeStamp()

mitk::IGTTimeStamp::IGTTimeStamp ( )
protected

Definition at line 20 of file mitkIGTTimeStamp.cpp.

◆ ~IGTTimeStamp()

mitk::IGTTimeStamp::~IGTTimeStamp ( )
overrideprotected

Definition at line 25 of file mitkIGTTimeStamp.cpp.

Member Function Documentation

◆ CreateInstance()

mitk::IGTTimeStamp * mitk::IGTTimeStamp::CreateInstance ( )
static

creates a new instance of mitkTimeStamp

This method returns a pointer to the currently existing TimeStamp. If there is no exisiting instance, a new one is created and returned automatically

DECREPATED: Use GetInstance instead

Definition at line 29 of file mitkIGTTimeStamp.cpp.

◆ GetCurrentStamp()

double mitk::IGTTimeStamp::GetCurrentStamp ( )
protected

Definition at line 121 of file mitkIGTTimeStamp.cpp.

◆ GetElapsed() [1/2]

double mitk::IGTTimeStamp::GetElapsed ( )

returns the time elapsed since calling Start() for the first time in milliseconds

GetElapsed() returns the time elapsed since Start() has been called first, no matter which itk::Object did the call. This method-call can be used if you want to need to have several processes you want to monitor and need timestamps in the same space of time, e.g. when using two tracking-devices on the same experiment.

Definition at line 96 of file mitkIGTTimeStamp.cpp.

◆ GetElapsed() [2/2]

double mitk::IGTTimeStamp::GetElapsed ( itk::Object::Pointer device)

returns the time elapsed since 'device' called Start() in milliseconds

GetElapsed(itk::Object device) returns the time elapsed since the given itk::Object called Start(). This overloaded method should be used when you only have one independent process to keep track of, e.g. when you want to measure how long it takes to execute a piece of code.

Definition at line 107 of file mitkIGTTimeStamp.cpp.

◆ GetInstance()

mitk::IGTTimeStamp * mitk::IGTTimeStamp::GetInstance ( )
static

returns a pointer to the current instance of mitkTimeStamp

This method returns a pointer to the currently existing TimeStamp. If there is no exisiting instance, a new one is created and returned automatically

Definition at line 34 of file mitkIGTTimeStamp.cpp.

◆ GetOffset()

double mitk::IGTTimeStamp::GetOffset ( itk::Object::Pointer Device)

returns the offset of this device's starting-time to the reference-time in ms

Device 'A' is the first device to call Start(). Device 'B' calls Start() some time later. This time-difference is the offset, that each device has realtive to the device that started the time-acquisition. Each device's offset is stored in a map with a pointer to the device.

If this device has not been or is no longer saved in the map of devices, -1 will be returned.

only used internally

Definition at line 135 of file mitkIGTTimeStamp.cpp.

◆ Initialize()

void mitk::IGTTimeStamp::Initialize ( )

creates a new RealTimeClock

Instanciates a new RealTimeClock, that will be specific for the Operating System. This will only be called internally when no other RealTimeClock has been set by the user.

Definition at line 148 of file mitkIGTTimeStamp.cpp.

◆ mitkClassMacroItkParent()

mitk::IGTTimeStamp::mitkClassMacroItkParent ( IGTTimeStamp ,
itk::Object  )

◆ SetRealTimeClock()

void mitk::IGTTimeStamp::SetRealTimeClock ( mitk::RealTimeClock::Pointer Clock)

setter for the internally used RealTimeClock()

If you want to use a "third-party" RealTimeClock, e.g PocoRealTimeClock, BoostRealTimeClock or ITKRealTimeClock, you can set it using this method: auto RealTimeClock = mitk::RealTimeClock::New(); mitk::TimeStamp::GetInstance()->SetRealTimeClock(RealTimeClock);

Right now, none of these RealTimeClocks have been implemented!!

Notice: The mitk-implementation of an os-dependant RealTimeClock is used by default.

Definition at line 130 of file mitkIGTTimeStamp.cpp.

◆ Start()

void mitk::IGTTimeStamp::Start ( itk::Object::Pointer device)

starts the time-acquisition

Each device is to call this method when it starts tracking. The current time is saved as a reference-value (m_Time = 0). Internally the device (pointer) and its offset are saved in a map, so that no device can call this method twice. If the user has not set its own RealTimeClock, a default one is created dependant on the OS in use.

Definition at line 46 of file mitkIGTTimeStamp.cpp.

◆ Stop()

void mitk::IGTTimeStamp::Stop ( itk::Object::Pointer device)

stops the time-acqusition

Each device has to call Stop() when it has finished and its pointer will be erased from the map. When the last device has "stopped" the reference-time and the current-time will be reset to 0.

Definition at line 70 of file mitkIGTTimeStamp.cpp.

Member Data Documentation

◆ m_DeviceMap

std::map<itk::Object::Pointer, double> mitk::IGTTimeStamp::m_DeviceMap
protected

Definition at line 180 of file mitkIGTTimeStamp.h.

◆ m_MapIterator

std::map<itk::Object::Pointer,double>::iterator mitk::IGTTimeStamp::m_MapIterator
protected

Definition at line 182 of file mitkIGTTimeStamp.h.

◆ m_RealTimeClock

mitk::RealTimeClock::Pointer mitk::IGTTimeStamp::m_RealTimeClock
protected

Definition at line 174 of file mitkIGTTimeStamp.h.

◆ m_ReferenceTime

double mitk::IGTTimeStamp::m_ReferenceTime
protected

Definition at line 171 of file mitkIGTTimeStamp.h.

◆ m_Time

double mitk::IGTTimeStamp::m_Time
protected

Definition at line 168 of file mitkIGTTimeStamp.h.

◆ s_Instance

mitk::IGTTimeStamp::Pointer mitk::IGTTimeStamp::s_Instance = nullptr
staticprotected

Definition at line 177 of file mitkIGTTimeStamp.h.


The documentation for this class was generated from the following files: