90 lines
2.0 KiB
C++
90 lines
2.0 KiB
C++
/*
|
|
* File: VirtualLogicalTime.h
|
|
* Author: jgaebler
|
|
*
|
|
* Created on April 15, 2010, 2:31 PM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef _VIRTUALLOGICALTIME_H
|
|
#define _VIRTUALLOGICALTIME_H
|
|
|
|
#include "Defines.h"
|
|
#include "common/transport/TransportAddress.h"
|
|
#include <serializable.h>
|
|
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @class VirtualLogicalTime
|
|
* @brief Provides a logical time implementation.
|
|
* @ingroup Moversight
|
|
* @author Jan Gäbler
|
|
*/
|
|
class VirtualLogicalTime : public Serializable {
|
|
|
|
public:
|
|
|
|
VirtualLogicalTime();
|
|
|
|
VirtualLogicalTime(unsigned int aLtValue);
|
|
|
|
VirtualLogicalTime(PeerID peerId, unsigned startValue);
|
|
|
|
VirtualLogicalTime(const VirtualLogicalTime& orig);
|
|
|
|
~VirtualLogicalTime();
|
|
|
|
void setAsIntValue(unsigned int intValue);
|
|
|
|
unsigned int getTimePart() const;
|
|
|
|
void setTimePart(unsigned int time);
|
|
|
|
PeerID getPeerID() const;
|
|
|
|
void setPeerID(const PeerID & pId);
|
|
|
|
void update(VirtualLogicalTime newTime);
|
|
|
|
operator int() const;
|
|
|
|
VirtualLogicalTime operator+(int a);
|
|
|
|
//++a
|
|
VirtualLogicalTime & operator++();
|
|
|
|
//a++
|
|
VirtualLogicalTime operator++(int);
|
|
|
|
bool operator==(unsigned int const aLtValue) const;
|
|
|
|
bool operator==(VirtualLogicalTime const & aLt) const;
|
|
|
|
bool operator!=(VirtualLogicalTime const & aLt) const;
|
|
|
|
bool operator<(VirtualLogicalTime const & aLt) const;
|
|
|
|
bool operator>(VirtualLogicalTime const & aLt) const;
|
|
|
|
virtual unsigned int getValue() const;
|
|
|
|
void set(Archive &archive);
|
|
|
|
private:
|
|
|
|
void init(PeerID peerID, unsigned int startValue);
|
|
|
|
unsigned int value;
|
|
|
|
};
|
|
|
|
extern std::ostream & operator<<(std::ostream & o, VirtualLogicalTime const & lt);
|
|
|
|
};
|
|
};
|
|
#endif /* _VIRTUALLOGICALTIME_H */
|
|
|