Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::IGTTimeStamp Class Reference

Time stamp in milliseconds. More...

#include <mitkIGTTimeStamp.h>

Inheritance diagram for mitk::IGTTimeStamp:
Collaboration diagram for mitk::IGTTimeStamp:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 IGTTimeStamp ()
 
virtual ~IGTTimeStamp ()
 
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
 

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 52 of file mitkIGTTimeStamp.h.

Constructor & Destructor Documentation

mitk::IGTTimeStamp::IGTTimeStamp ( )
protected

Definition at line 24 of file mitkIGTTimeStamp.cpp.

mitk::IGTTimeStamp::~IGTTimeStamp ( )
protectedvirtual

Definition at line 29 of file mitkIGTTimeStamp.cpp.

Member Function Documentation

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 33 of file mitkIGTTimeStamp.cpp.

References GetInstance().

double mitk::IGTTimeStamp::GetCurrentStamp ( )
protected

Definition at line 125 of file mitkIGTTimeStamp.cpp.

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 100 of file mitkIGTTimeStamp.cpp.

Referenced by mitk::NavigationDataPlayer::GenerateData(), mitk::NavigationDataRecorder::GenerateData(), mitk::TrackingDeviceSource::GenerateData(), mitk::NavigationDataPlayer::Pause(), mitk::NavigationDataPlayer::Resume(), mitk::NavigationDataPlayer::StartPlaying(), and mitk::NavigationDataRecorderDeprecated::Update().

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 111 of file mitkIGTTimeStamp.cpp.

References offset.

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 139 of file mitkIGTTimeStamp.cpp.

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 152 of file mitkIGTTimeStamp.cpp.

References mitk::RealTimeClock::New().

mitk::IGTTimeStamp::mitkClassMacroItkParent ( IGTTimeStamp  ,
itk::Object   
)
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: mitk::<bla>RealTimeClock::Pointer RealTimeClock = mitk::<bla>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 134 of file mitkIGTTimeStamp.cpp.

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 50 of file mitkIGTTimeStamp.cpp.

Referenced by mitk::NavigationDataPlayer::NavigationDataPlayer(), mitk::NavigationDataRecorderDeprecated::NavigationDataRecorderDeprecated(), mitk::NavigationDataRecorder::ResetRecording(), mitk::NavigationDataRecorder::StartRecording(), mitk::ClaronTrackingDevice::StartTracking(), mitk::VirtualTrackingDevice::StartTracking(), and mitk::NDITrackingDevice::StartTracking().

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 74 of file mitkIGTTimeStamp.cpp.

Referenced by mitk::NavigationDataRecorder::ResetRecording(), mitk::VirtualTrackingDevice::StopTracking(), and mitk::TrackingDevice::StopTracking().

Member Data Documentation

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

Definition at line 184 of file mitkIGTTimeStamp.h.

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

Definition at line 186 of file mitkIGTTimeStamp.h.

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

Definition at line 178 of file mitkIGTTimeStamp.h.

double mitk::IGTTimeStamp::m_ReferenceTime
protected

Definition at line 175 of file mitkIGTTimeStamp.h.

double mitk::IGTTimeStamp::m_Time
protected

Definition at line 172 of file mitkIGTTimeStamp.h.

mitk::IGTTimeStamp::Pointer mitk::IGTTimeStamp::s_Instance
staticprotected

Definition at line 181 of file mitkIGTTimeStamp.h.

Referenced by GetInstance().


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