fw4spl
TimeStamp.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWCORE_TIMESTAMP_HPP__
8 #define __FWCORE_TIMESTAMP_HPP__
9 
10 #include "fwCore/base.hpp"
11 #include "fwCore/HiResClock.hpp"
12 
13 namespace fwCore
14 {
15 
20 class FWCORE_CLASS_API TimeStamp : public BaseObject
21 {
22 
23 public:
25 
29  typedef ::fwCore::HiResClock::HiResClockType TimeStampType;
30 
31 
32 
37  FWCORE_API TimeStamp()
38  {
39  this->m_modifiedTime = 0;
40  this->m_lifePeriod = 0;
41  }
42 
49  FWCORE_API void modified();
50 
51 
55  FWCORE_API TimeStampType getTimeStamp() const
56  {
57  return this->m_modifiedTime;
58  }
59 
60 
61 
67  FWCORE_API bool operator>(const TimeStamp& ts) const
68  {
69  return ( this->m_modifiedTime > ts.m_modifiedTime );
70  }
71 
77  FWCORE_API bool operator<(const TimeStamp& ts) const
78  {
79  return ( this->m_modifiedTime < ts.m_modifiedTime );
80  }
81 
85  FWCORE_API operator TimeStampType() const
86  {
87  return this->m_modifiedTime;
88  }
89 
90 
96  FWCORE_API void setLifePeriod(TimeStampType period)
97  {
98  m_lifePeriod = period;
99  }
100 
106  FWCORE_API TimeStampType getLifePeriod() const
107  {
108  return m_lifePeriod;
109  }
110 
111 
118  FWCORE_API bool periodExpired() const
119  {
120  return (::fwCore::HiResClock::getTimeInMilliSec() - this->m_modifiedTime) > m_lifePeriod;
121  }
122 
123 
124 private:
128  TimeStampType m_modifiedTime;
129 
133  TimeStampType m_lifePeriod;
134 
135 };
136 
137 
138 } //namespace fwCore
139 
140 #endif // __FWCORE_TIMESTAMP_HPP__
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
FWCORE_API HiResClockType getTimeInMilliSec()
Definition: HiResClock.cpp:46
FWCORE_API bool operator>(const TimeStamp &ts) const
Greater than operator for TimeStamp.
Definition: TimeStamp.hpp:67
FWCORE_API void setLifePeriod(TimeStampType period)
Setter for the life period.
Definition: TimeStamp.hpp:96
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Provides a timestamp and a expiracy system.
Definition: TimeStamp.hpp:20
FWCORE_API TimeStampType getTimeStamp() const
Definition: TimeStamp.hpp:55
FWCORE_API bool periodExpired() const
Check TimeStamp expiracy status.
Definition: TimeStamp.hpp:118
FWCORE_API TimeStampType getLifePeriod() const
Getter for the life period.
Definition: TimeStamp.hpp:106
FWCORE_API bool operator<(const TimeStamp &ts) const
Lesser than operator for TimeStamp.
Definition: TimeStamp.hpp:77
::fwCore::HiResClock::HiResClockType TimeStampType
Type used in logical typestamp.
Definition: TimeStamp.hpp:24