core/vul/vul_timestamp.h
Go to the documentation of this file.
00001 // This is core/vul/vul_timestamp.h
00002 #ifndef vul_timestamp_h
00003 #define vul_timestamp_h
00004 //:
00005 // \file
00006 // \brief generates a timestamp.
00007 //
00008 // \verbatim
00009 //  Modifications
00010 //   10 Sep. 2004 Peter Vanroose  Inlined all 1-line methods in class decl
00011 // \endverbatim
00012 
00013 //: class to generate a unique timestamp
00014 class vul_timestamp
00015 {
00016   //: mark is incremented to give a unique timestamp
00017   static unsigned long mark;
00018 
00019  public:
00020 
00021   //: Constructor
00022   vul_timestamp() { this->touch(); }
00023   //: Destructor
00024   virtual ~vul_timestamp() {}
00025 
00026   //: Get a new timestamp
00027   void touch() { timestamp_ = get_unique_timestamp(); }
00028   //: Get a new timestamp (incremented by 1 each time)
00029   unsigned long get_time_stamp() const { return timestamp_; }
00030 
00031   //: Returns true if t is older than the last timestamp
00032   bool older(vul_timestamp const& t)const{return timestamp_<t.get_time_stamp();}
00033   //: Returns true if t is older than the last timestamp
00034   inline bool older(vul_timestamp const* t) const { return older(*t); }
00035 
00036  protected:
00037   //: last timestamp
00038   unsigned long timestamp_;
00039 
00040  private:
00041   //: get a new timestamp
00042   static unsigned long get_unique_timestamp() { return mark++; }
00043 };
00044 
00045 #endif // vul_timestamp_h