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

172 lines
4.8 KiB
C++

#include "JoinRequest.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
*/
JoinRequest::JoinRequest()
: ExteriorMessage( "JR", JR), inviterGroupSize(0), strategy(0) {
}
/**
* @brief Copy constructor
* @param other The instance to copy
*/
JoinRequest::JoinRequest( const JoinRequest& other) : ExteriorMessage(other) {
operator=(other);
}
/**
* @brief Destructor
*/
JoinRequest::~JoinRequest(){
}
/**
* @brief Creates a copy of the current instance.
* @return The copy of the current instance.
*/
JoinRequest *
JoinRequest::dup() const {
return new JoinRequest(*this);
}
/**
* @brief Assingment operator
* @param other The instance to assign.
* @return A reference to the local instance.
*/
JoinRequest &
JoinRequest::operator=(const JoinRequest& other) {
if (this==&other) return *this;
ExteriorMessage::operator=(other);
inviterID = other.inviterID;
invitationID = other.invitationID;
inviterGroupSize = other.inviterGroupSize;
strategy = other.strategy;
peerDescription = other.peerDescription;
return *this;
}
/**
* @brief Handles this message. To handle a message, it has first successfully validated.
* @param dis A reference to the dispatcher, used to forward this message to the handling modules.
*/
void
JoinRequest::handleReceive(Dispatcher& dis) {
// @NOTE whuuuut?
#if ! OMNETPP
setSource(from());
#endif
if( dis.getMessageValidator()->isValid( *this)) {
dis.getMembershipService().handleJoinRequest(this);
}
}
/**
* @brief Gets the inviterID
* @return the peerID of the inviter
*/
const PeerID&
JoinRequest::getInviterID() const {
return inviterID;
}
/**
* @brief Sets the inviterID
* @param inviterID PeerID of the inviter
*/
void
JoinRequest::setInviterID(const PeerID& inviterID) {
this->inviterID = inviterID;
}
/**
* @brief Gets the invitationID
* @return the invitationsID of the joinrequest
*/
const InvitationID&
JoinRequest::getInvitationID() const {
return invitationID;
}
/**
* @brief Sets the invitationID
* @param invitationID The invitationID to be set
*/
void JoinRequest::setInvitationID(const InvitationID& invitationID){
this->invitationID = invitationID;
}
/**
* @brief Gets the inviterGroupSize
* @return groupsize
*/
int JoinRequest::getInviterGroupSize() const {
return inviterGroupSize;
}
/**
* @brief Sets the inviterGroupSize
* @param inviterGroupSize The size of the invitergroup
*/
void JoinRequest::setInviterGroupSize( const int inviterGroupSize){
this->inviterGroupSize = inviterGroupSize;
}
/**
* @brief Gets the peerplacingstrategy
* @return the peerplacingstrategy
*/
int JoinRequest::getStrategy() const {
return strategy;
}
/**
* @brief Sets the Peerplacingstrategy
* @param strategy The strategy to be set
*/
void JoinRequest::setStrategy( const int strategy) {
this->strategy = strategy;
}
/**
* @brief Gets the PeerDescription
* @return the Peerdescription
*/
const PeerDescription&
JoinRequest::getPeerDescription() const {
return peerDescription;
}
/**
* @brief Sets the PeerDescription
* @param peerDescription The peerDescription to be set
*/
void JoinRequest::setPeerDescription(const PeerDescription& peerDescription){
this->peerDescription = peerDescription;
}
/**
* @brief Archive method
* @param archive The archive to which the attributes are to add
*/
void JoinRequest::set(Archive & archive) {
ExteriorMessage::set(archive);
archive(inviterID);
archive(invitationID);
archive(inviterGroupSize);
archive(strategy);
archive(peerDescription);
}
}
}