6 vrpn_uint32 * vector) :
7 d_timestampSize (vectorLength),
10 d_timestamp =
new vrpn_uint32[vectorLength];
16 d_timestampSize (r.d_timestampSize),
19 d_timestamp =
new vrpn_uint32[r.d_timestampSize];
30 fprintf(stderr,
"vrpn_LamportTimestamp::~vrpn_LamportTimestamp(): delete failed\n");
43 fprintf(stderr,
"vrpn_LamportTimestamp::operator =(): delete failed\n");
49 d_timestampSize = r.d_timestampSize;
50 try { d_timestamp =
new vrpn_uint32[r.d_timestampSize]; }
69 if (d_timestampSize != r.d_timestampSize) {
70 return d_timestampSize < r.d_timestampSize;
76 for (i = 0; i < d_timestampSize; i++) {
77 if (d_timestamp[i] > r.d_timestamp[i]) {
82 for (i = 0; i < d_timestampSize; i++) {
83 if (d_timestamp[i] < r.d_timestamp[i]) {
92 if ((i < 0) || (i >= d_timestampSize)) {
95 return d_timestamp[i];
99 return d_timestampSize;
103void vrpn_LamportTimestamp::copy (
const vrpn_uint32 * vector) {
106 if (d_timestamp && vector) {
107 for (i = 0; i < d_timestampSize; i++) {
108 d_timestamp[i] = vector[i];
116 d_numHosts (numHosts),
117 d_ourIndex (ourIndex),
118 d_currentTimestamp(NULL)
120 d_currentTimestamp =
new vrpn_uint32[numHosts];
123 if (d_currentTimestamp) {
124 for (i = 0; i < numHosts; i++) {
125 d_currentTimestamp[i] = 0;
132 if (d_currentTimestamp) {
134 delete[] d_currentTimestamp;
136 fprintf(stderr,
"vrpn_LamportClock::~vrpn_LamportClock(): delete failed\n");
145 if (r.
size() != d_numHosts) {
150 for (i = 0; i < d_numHosts; i++) {
151 if (r[i] > d_currentTimestamp[i]) {
152 d_currentTimestamp[i] = r[i];
160 d_currentTimestamp[d_ourIndex]++;
164 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)