Files
2014-06-30 13:58:10 +02:00

168 lines
4.9 KiB
C++

/*
* File: LTNode.cc
* Author: jgaebler
*
* Created on March 30, 2010, 11:29 AM
*/
#include "LTNode.h"
#include "ms/MemberDescription.h"
#include "mt/msg/MulticastMessage.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor. Creates an LTNode, which is not deliverable. The sequ is -1 and the nodeId is also -1.
*/
LTNode::LTNode() : deliverable(false), sequ(-1), peerID(-1), pdu(NULL) {
}
/**
* @brief Constructor. Creates an LTNode, which is not deliverable.
* @param aSequ the sequenznummer of the received peer message
* @param aNodeId the sender node id of the received peer message
* @param aMref the message referenz, identifying the stored peer message
*/
LTNode::LTNode(const unsigned int aSequ, const PeerID & aNodeId, MessageReference & aMref): deliverable(false), sequ(aSequ), peerID(aNodeId), mRef(aMref), pdu(NULL) {
}
/**
* @brief Constructor. Creates an LTNode, which is not deliverable.
* @param aSequ the sequenznummer of the received peer message
* @param aNodeId the sender node id of the received peer message
* @param aLt the logical receiving time
* @param aMref the message referenz, identifying the stored peer message
* @param aPdu the received message, stored within this LTNode
*/
LTNode::LTNode(const unsigned int aSequ, const unsigned int aNodeId, VirtualLogicalTime & aLt, MessageReference & aMref, MulticastMessage * aPdu): deliverable(false), sequ(aSequ), peerID(aNodeId), lt(aLt), mRef(aMref), pdu(aPdu) {
}
/**
* @brief Destructor
*/
LTNode::~LTNode() {
}
/**
* @brief Outputoperator. Prints a textual represantation of the current node.
* @param stream the output stream to print the textual represantation
* @param node the node to print
*/
std::ostream & operator<<(std::ostream& stream, const LTNode& node) {
return stream << "messageReference: " << node.getMessageReference() << " "
<< "nodeID: " << node.getPeerID() << " "
<< "lt: " << node.getLT() << " "
<< "sequ: " << node.getSequ() << " "
<< "deliverable: " << (node.isDeliverable() == true ? "yes" : "no");
}
/**
* @brief Returns the type of the group message, stored within this node.
* @return The type of the peer message, stored within this node.
*/
MoversightMessageType
LTNode::getMessageType() {
return pdu->getType();
}//End
/**
* @brief Sets the message to store within the node.
* @param pdu The message to store.
*/
void
LTNode::setMessage( MulticastMessage* pdu) {
this->pdu = pdu;
}
/**
* @brief Returns the message, stored within the node.
* @return The message stored within the node.
*/
MulticastMessage *
LTNode::getMessage() const {
return pdu;
}
/**
* @brief Sets the lt value, associated with the node.
* @param aLt The lt value to store.
*/
void
LTNode::setLT(const VirtualLogicalTime & alt) {
this->lt = alt;
//if a message already set? update that too
if(pdu != NULL){
pdu->setLogicalDeliveryTime(lt);
}
}
/**
* @brief Return the logical time value
* @return The lt value.
*/
VirtualLogicalTime
LTNode::getLT() const {
return lt;
}
void
LTNode::setPeerID(PeerID aPeerID) {
peerID = aPeerID;
}
PeerID
LTNode::getPeerID() const {
return peerID;
}
void
LTNode::setSequ(int sequ) {
this->sequ = sequ;
}
int
LTNode::getSequ() const {
return sequ;
}
void
LTNode::setDeliverable(bool deliverable) {
this->deliverable = deliverable;
}
bool
LTNode::isDeliverable() const {
return deliverable;
}
bool
LTNode::operator<(LTNode const & aNode) const {
return this->lt < aNode.lt;
}
bool
LTNode::operator>(LTNode const & aNode) const {
return lt > aNode.lt;
}
bool
LTNode::operator==(LTNode const & aNode) {
return mRef == aNode.mRef &&
deliverable == aNode.deliverable &&
lt == aNode.lt;
}
void
LTNode::setMessageReference(MessageReference & aMref) {
this->mRef = aMref;
}
MessageReference
LTNode::getMessageReference() const {
return mRef;
}
};
};