Files
scandocs/uni/masterarbeit/source/moversight/ms/PeerID.h
2014-06-30 13:58:10 +02:00

98 lines
2.3 KiB
C++

/*
* File: PeerID.h
* Author: jgaebler
*
* Created on January 30, 2014, 9:18 PM
*/
#pragma once
#ifndef PEERID_H
#define PEERID_H
#include "common/Reference.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Identifies a peer uniquely
* @class PeerID
* @ingroup Moversight
* @author Jan Gäbler
*/
class PeerID : public Reference<unsigned int> {
public:
/**
* @brief Constructor
*/
PeerID() : Reference<unsigned int>(0) {
}
/**
* @brief Constructor
* @param id The initial id
*/
PeerID(unsigned int id) : Reference<unsigned int>(id) {
}
/**
* @brief Copy constructor
* @param orig The instance to copy
*/
PeerID(const PeerID & orig): Reference<unsigned int>(orig){
operator=(orig);
}
/**
* @brief Assignment operator
* @param other The instance to assign
* @return A reference to the local instance.
*/
PeerID &
operator=(const PeerID & other){
if(this != &other){
Reference<unsigned int>::operator =(other);
}
return *this;
}
/**
* @brief Prefix-incrementation
* @return A reference to the local instance.
*/
PeerID & operator++(){ //++a
return static_cast<PeerID&>(Reference<unsigned int>::operator ++());
}
/**
* @brief Postfix-incrementation
* @param Pseudo-param
* @return The value of the local instance before the incrementation
*/
PeerID operator++(int){ //a++
PeerID result(*this);
++(*this);
return result;
}
};
/**
* @brief The constant undefined peer ID
*/
static const PeerID UNDEFINED_PEER_ID = 0;
/**
* @brief The constant initial peer ID
*/
static const PeerID INITIAL_PEER_ID = 1;
}
}
#endif /* PEERID_H */