155 lines
4.3 KiB
C++
155 lines
4.3 KiB
C++
/*
|
|
* File: MemberDescription.cc
|
|
* Author: jgaebler
|
|
*
|
|
* Created on July 29, 2010, 2:44 PM
|
|
*/
|
|
|
|
#include "MemberDescription.h"
|
|
#include "common/Exception.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Default constructor.
|
|
*/
|
|
MemberDescription::MemberDescription() : pID(UNDEFINED_PEER_ID),
|
|
state(DISJOINED),
|
|
clusterID(UNDEFINED_CLUSTER_ID) {
|
|
}
|
|
|
|
/**
|
|
* @brief Creates a member description based on a given peer.
|
|
* @param p The peer to describe.
|
|
*/
|
|
MemberDescription::MemberDescription(const Peer & p) : pID(p.getPeerID()),
|
|
address(p.getLocalAddress()),
|
|
state(p.getState()),
|
|
clusterID(p.getClusterID()),
|
|
pDesc(p.getPeerDescription()),
|
|
resources(p.getPeerResources()) {
|
|
|
|
//check the peer if
|
|
if (pID == UNDEFINED_PEER_ID) {
|
|
throw IllegalParameterException("MemberDescription - the given peer ID is equal to UNDEFINED_PEER_ID");
|
|
}//end if
|
|
}
|
|
|
|
/**
|
|
* @brief Constructor
|
|
* @param pID The id of the peer.
|
|
* @param ta The transport address of the peer
|
|
* @param s The state of the peer.
|
|
* @param cID The cluster ID of the peer.
|
|
* @param pd The peer description of the peer.
|
|
* @param res The resource value representation of the peer.
|
|
*/
|
|
MemberDescription::MemberDescription(const PeerID pID,
|
|
const ubeeme::moversight::TransportAddress & ta,
|
|
const State & s,
|
|
const ClusterID cID,
|
|
const PeerDescription & pd,
|
|
const PeerResources & res) : pID(pID), address(ta), state(s), clusterID(cID), pDesc(pd), resources(res) {
|
|
|
|
//check the peer if
|
|
if (pID == UNDEFINED_PEER_ID) {
|
|
throw IllegalParameterException("MemberDescription - the given peer ID is equal to UNDEFINED_PEER_ID");
|
|
}//end if
|
|
}
|
|
|
|
MemberDescription::~MemberDescription() {
|
|
}
|
|
|
|
PeerID
|
|
MemberDescription::getPeerID() const {
|
|
return pID;
|
|
}
|
|
|
|
const ubeeme::moversight::TransportAddress &
|
|
MemberDescription::getTransportAddress() const {
|
|
return address;
|
|
}
|
|
|
|
const State &
|
|
MemberDescription::getState() const {
|
|
return state;
|
|
}
|
|
|
|
ClusterID
|
|
MemberDescription::getClusterID() const {
|
|
return clusterID;
|
|
}
|
|
|
|
void
|
|
MemberDescription::setPeerID(PeerID pId) {
|
|
|
|
//check the peer if
|
|
if (pID == UNDEFINED_PEER_ID) {
|
|
throw IllegalParameterException("MemberDescription - the given peer ID is equal to UNDEFINED_PEER_ID");
|
|
}//end if
|
|
|
|
this->pID = pId;
|
|
}
|
|
|
|
void
|
|
MemberDescription::setTransportAddress(const ubeeme::moversight::TransportAddress & a) {
|
|
address = a;
|
|
}
|
|
|
|
void
|
|
MemberDescription::setState(const State & s) {
|
|
state = s;
|
|
}
|
|
|
|
void
|
|
MemberDescription::setClusterID(ClusterID cID) {
|
|
clusterID = cID;
|
|
}
|
|
|
|
void
|
|
MemberDescription::setPeerDescription(const PeerDescription & pd) {
|
|
pDesc = pd;
|
|
}
|
|
|
|
const PeerDescription &
|
|
MemberDescription::getPeerDescription() const {
|
|
return pDesc;
|
|
}
|
|
|
|
void
|
|
MemberDescription::set(Archive & archive) {
|
|
|
|
archive(pID);
|
|
archive(address);
|
|
|
|
if(archive.isReading()){
|
|
|
|
int8 tmp;
|
|
archive(tmp);
|
|
state = (State) tmp;
|
|
}
|
|
else{
|
|
|
|
int8 & tmp = (int8&) state;
|
|
archive(tmp);
|
|
}
|
|
|
|
archive(clusterID);
|
|
archive(pDesc);
|
|
archive(resources);
|
|
}
|
|
|
|
void
|
|
MemberDescription::setPeerResources(const PeerResources & res) {
|
|
resources = res;
|
|
}
|
|
|
|
const PeerResources &
|
|
MemberDescription::getPeerResources() const {
|
|
return resources;
|
|
}
|
|
|
|
}
|
|
}
|