vul_timestamp.h
Go to the documentation of this file.
1 // This is core/vul/vul_timestamp.h
2 #ifndef vul_timestamp_h
3 #define vul_timestamp_h
4 #include <vul/vul_export.h>
5 
6 //:
7 // \file
8 // \brief generates a timestamp.
9 //
10 // \verbatim
11 // Modifications
12 // 10 Sep. 2004 Peter Vanroose Inlined all 1-line methods in class decl
13 // \endverbatim
14 
15 //: class to generate a unique timestamp
17 {
18  //: mark is incremented to give a unique timestamp
19  static VUL_EXPORT unsigned long mark;
20 
21  public:
22 
23  //: Constructor
24  vul_timestamp() { this->touch(); }
25  //: Destructor
26  virtual ~vul_timestamp() = default;
27 
28  //: Get a new timestamp
30  //: Get a new timestamp (incremented by 1 each time)
31  unsigned long get_time_stamp() const { return timestamp_; }
32 
33  //: Returns true if t is older than the last timestamp
34  bool older(vul_timestamp const& t)const{return timestamp_<t.get_time_stamp();}
35  //: Returns true if t is older than the last timestamp
36  inline bool older(vul_timestamp const* t) const { return older(*t); }
37 
38  protected:
39  //: last timestamp
40  unsigned long timestamp_;
41 
42  private:
43  //: get a new timestamp
44  static unsigned long get_unique_timestamp() { return mark++; }
45 };
46 
47 #endif // vul_timestamp_h
bool older(vul_timestamp const &t) const
Returns true if t is older than the last timestamp.
Definition: vul_timestamp.h:34
static unsigned long get_unique_timestamp()
get a new timestamp.
Definition: vul_timestamp.h:44
bool older(vul_timestamp const *t) const
Returns true if t is older than the last timestamp.
Definition: vul_timestamp.h:36
virtual ~vul_timestamp()=default
Destructor.
class to generate a unique timestamp.
Definition: vul_timestamp.h:16
void touch()
Get a new timestamp.
Definition: vul_timestamp.h:29
unsigned long get_time_stamp() const
Get a new timestamp (incremented by 1 each time).
Definition: vul_timestamp.h:31
vul_timestamp()
Constructor.
Definition: vul_timestamp.h:24
static VUL_EXPORT unsigned long mark
mark is incremented to give a unique timestamp.
Definition: vul_timestamp.h:19
unsigned long timestamp_
last timestamp.
Definition: vul_timestamp.h:40