-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathEventTicker.cpp
More file actions
111 lines (81 loc) · 2.56 KB
/
EventTicker.cpp
File metadata and controls
111 lines (81 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*****************************************************************************
*
* libdiffpy Complex Modeling Initiative
* (c) 2013 Brookhaven Science Associates,
* Brookhaven National Laboratory.
* All rights reserved.
*
* File coded by: Pavol Juhas
*
* See AUTHORS.txt for a list of people who contributed.
* See LICENSE.txt for license information.
*
******************************************************************************
*
* class EventTicker for managing modification times of dependent objects.
*
* This is used to determine if cached values need update, due to a change
* of their dependencies. The EventTicker class is inspired by the
* ObjCryst::RefinableObjClock class.
*
*****************************************************************************/
#include <diffpy/EventTicker.hpp>
#include <diffpy/serialization.ipp>
namespace diffpy {
namespace eventticker {
//////////////////////////////////////////////////////////////////////////////
// class EventTicker
//////////////////////////////////////////////////////////////////////////////
// Constructor ---------------------------------------------------------------
EventTicker::EventTicker() : mtick(0, 0)
{ }
// Public Methods ------------------------------------------------------------
void EventTicker::click()
{
++gtick.second;
if (0 >= gtick.second)
{
++gtick.first;
gtick.second = 0;
}
mtick = gtick;
}
void EventTicker::updateFrom(const EventTicker& other)
{
if (other > *this) mtick = other.mtick;
}
EventTicker::value_type EventTicker::value() const
{
return mtick;
}
bool EventTicker::operator<(const EventTicker& other) const
{
return mtick < other.mtick;
}
bool EventTicker::operator<=(const EventTicker& other) const
{
return mtick <= other.mtick;
}
bool EventTicker::operator>(const EventTicker& other) const
{
return mtick > other.mtick;
}
bool EventTicker::operator>=(const EventTicker& other) const
{
return mtick >= other.mtick;
}
bool EventTicker::operator==(const EventTicker& other) const
{
return mtick == other.mtick;
}
bool EventTicker::operator!=(const EventTicker& other) const
{
return mtick != other.mtick;
}
// Static Global Data --------------------------------------------------------
EventTicker::value_type EventTicker::gtick(0, 0);
} // namespace eventticker
} // namespace diffpy
// Serialization -------------------------------------------------------------
DIFFPY_INSTANTIATE_SERIALIZATION(diffpy::eventticker::EventTicker)
// End of file