7 vrpn_uint32 * vector) :
8 d_timestampSize (vectorLength),
11 d_timestamp =
new vrpn_uint32[vectorLength];
17 d_timestampSize (r.d_timestampSize),
20 d_timestamp =
new vrpn_uint32[r.d_timestampSize];
31 fprintf(stderr,
"vrpn_LamportTimestamp::~vrpn_LamportTimestamp(): delete failed\n");
44 fprintf(stderr,
"vrpn_LamportTimestamp::operator =(): delete failed\n");
50 d_timestampSize = r.d_timestampSize;
51 try { d_timestamp =
new vrpn_uint32[r.d_timestampSize]; }
70 if (d_timestampSize != r.d_timestampSize) {
71 return d_timestampSize < r.d_timestampSize;
77 for (i = 0; i < d_timestampSize; i++) {
78 if (d_timestamp[i] > r.d_timestamp[i]) {
83 for (i = 0; i < d_timestampSize; i++) {
84 if (d_timestamp[i] < r.d_timestamp[i]) {
93 if ((i < 0) || (i >= d_timestampSize)) {
96 return d_timestamp[i];
100 return d_timestampSize;
104void vrpn_LamportTimestamp::copy (
const vrpn_uint32 * vector) {
107 if (d_timestamp && vector) {
108 for (i = 0; i < d_timestampSize; i++) {
109 d_timestamp[i] = vector[i];
117 d_numHosts (numHosts),
118 d_ourIndex (ourIndex),
119 d_currentTimestamp(NULL)
121 d_currentTimestamp =
new(std::nothrow) vrpn_uint32[numHosts];
124 if (d_currentTimestamp) {
125 for (i = 0; i < numHosts; i++) {
126 d_currentTimestamp[i] = 0;
133 if (d_currentTimestamp) {
135 delete[] d_currentTimestamp;
137 fprintf(stderr,
"vrpn_LamportClock::~vrpn_LamportClock(): delete failed\n");
146 if (r.
size() != d_numHosts) {
151 for (i = 0; i < d_numHosts; i++) {
152 if (r[i] > d_currentTimestamp[i]) {
153 d_currentTimestamp[i] = r[i];
161 d_currentTimestamp[d_ourIndex]++;
165 catch (...) {
return NULL; }
void receive(const vrpn_LamportTimestamp &)
Updates this clock to reflect a timestamp received from another clock/host.
vrpn_LamportClock(int numHosts, int ourIndex)
vrpn_LamportTimestamp * getTimestampAndAdvance(void)
Increments the current timestamp and returns it.
Timestamp for a single event, produced by a vrpn_LamportClock and hopefully generally usable in place...
vrpn_uint32 operator[](int i) const
Returns the event count for the i'th host.
int size(void) const
Returns the number of hosts participating in the timestamp.
vrpn_bool operator<(const vrpn_LamportTimestamp &r) const
Returns vrpn_true if this timestamp precedes r. It'd be nice if we could throw an exception here,...
~vrpn_LamportTimestamp(void)
vrpn_LamportTimestamp(int vectorLength, vrpn_uint32 *vector)
class VRPN_API vrpn_LamportTimestamp