IGSTK
igstkTimeStamp.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkTimeStamp.h,v $
5  Language: C++
6  Date: $Date: 2008-03-20 16:47:43 $
7  Version: $Revision: 1.17 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __igstkTimeStamp_h
18 #define __igstkTimeStamp_h
19 
20 
21 #include <iostream>
22 #include "igstkRealTimeClock.h"
23 #include "itkNumericTraits.h"
24 
25 namespace igstk
26 {
27 
55 class TimeStamp
56 {
57 
58 public:
59 
60  typedef double TimePeriodType;
61 
64 
66  static TimePeriodType GetZeroValue();
67 
70 
72  TimeStamp();
73  virtual ~TimeStamp();
74 
75 
77  const TimeStamp & operator=( const TimeStamp & inputTimeStamp );
78 
83  void SetStartTimeNowAndExpireAfter( TimePeriodType millisecondsToExpire);
84 
85 
90 
91 
97 
98 
106  bool IsValidAtTime( TimePeriodType milliseconds ) const;
107 
111  bool IsValidNow( ) const;
112 
113  void Print(std::ostream& os, itk::Indent indent) const;
114 
115 protected:
116 
117  void PrintHeader(std::ostream& os, itk::Indent indent) const;
118 
119  void PrintTrailer(std::ostream& itkNotUsed(os),
120  itk::Indent itkNotUsed(indent)) const;
121 
123  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
124 
125 
126 private:
127 
128  TimePeriodType m_StartTime;
129  TimePeriodType m_ExpirationTime;
130 
131 };
132 
133 std::ostream& operator<<(std::ostream& os, const TimeStamp& o);
134 
135 }
136 
137 #endif
TimeStamp provides periods of validity for data.
TimePeriodType GetExpirationTime() const
Returns the time in milliseconds at which this stamp will expire.
static TimePeriodType GetZeroValue()
Get the zero time period on the machine.
std::ostream & operator<<(std::ostream &os, const igstk::AffineTransform &o)
TimePeriodType GetStartTime() const
Returns the time in milliseconds at which this stamp started to be valid.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print the object information in a stream.
void SetStartTimeNowAndExpireAfter(TimePeriodType millisecondsToExpire)
This method sets both the Start time and the Expiration time of the TimeStamp.
void PrintTrailer(std::ostream &itkNotUsed(os), itk::Indent itkNotUsed(indent)) const
const TimeStamp & operator=(const TimeStamp &inputTimeStamp)
Copy one time stamp into another.
void Print(std::ostream &os, itk::Indent indent) const
bool IsValidAtTime(TimePeriodType milliseconds) const
This method returns 'true' is the current TimeStamp is still valid at the time in milliseconds indica...
static TimeStamp ComputeOverlap(TimeStamp t1, TimeStamp t2)
Compute the intersection of two time stamps.
void PrintHeader(std::ostream &os, itk::Indent indent) const
static TimePeriodType GetLongestPossibleTime()
Define the longest time period on the machine.
virtual ~TimeStamp()
bool IsValidNow() const
This method returns 'true' is the current TimeStamp is valid at the time when this method is called...
TimeStamp()
Constructor and destructor.