4 vrpn_uint32 * vector) :
5 d_timestampSize (vectorLength),
6 d_timestamp (new vrpn_uint32 [vectorLength]) {
11 vrpn_LamportTimestamp::vrpn_LamportTimestamp
13 d_timestampSize (r.d_timestampSize),
14 d_timestamp (
new vrpn_uint32 [r.d_timestampSize]) {
23 delete [] d_timestamp;
31 delete [] d_timestamp;
34 d_timestampSize = r.d_timestampSize;
35 d_timestamp =
new vrpn_uint32 [r.d_timestampSize];
50 if (d_timestampSize != r.d_timestampSize) {
51 return d_timestampSize < r.d_timestampSize;
57 for (i = 0; i < d_timestampSize; i++) {
58 if (d_timestamp[i] > r.d_timestamp[i]) {
63 for (i = 0; i < d_timestampSize; i++) {
64 if (d_timestamp[i] < r.d_timestamp[i]) {
73 if ((i < 0) || (i >= d_timestampSize)) {
76 return d_timestamp[i];
80 return d_timestampSize;
84 void vrpn_LamportTimestamp::copy (
const vrpn_uint32 * vector) {
87 if (d_timestamp && vector) {
88 for (i = 0; i < d_timestampSize; i++) {
89 d_timestamp[i] = vector[i];
97 d_numHosts (numHosts),
98 d_ourIndex (ourIndex),
99 d_currentTimestamp (new vrpn_uint32 [numHosts]) {
103 if (d_currentTimestamp) {
104 for (i = 0; i < numHosts; i++) {
105 d_currentTimestamp[i] = 0;
112 if (d_currentTimestamp) {
113 delete [] d_currentTimestamp;
120 if (r.
size() != d_numHosts) {
125 for (i = 0; i < d_numHosts; i++) {
126 if (r[i] > d_currentTimestamp[i]) {
127 d_currentTimestamp[i] = r[i];
135 d_currentTimestamp[d_ourIndex]++;
vrpn_uint32 operator [](int i) const
Returns the event count for the i'th host.
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,...
int size(void) const
Returns the number of hosts participating in the timestamp.
class VRPN_API vrpn_LamportTimestamp
vrpn_LamportTimestamp(int vectorLength, vrpn_uint32 *vector)
Timestamp for a single event, produced by a vrpn_LamportClock and hopefully generally usable in place...
vrpn_LamportClock(int numHosts, int ourIndex)
~vrpn_LamportTimestamp(void)
void receive(const vrpn_LamportTimestamp &)
Updates this clock to reflect a timestamp received from another clock/host.
vrpn_LamportTimestamp * getTimestampAndAdvance(void)
Increments the current timestamp and returns it.