Files
scandocs/uni/masterarbeit/source/moversight/ut/msg/UnicastMessage.cc
2014-06-30 13:58:10 +02:00

132 lines
3.7 KiB
C++
Executable File

/*
* File: UnicastMessage.cc
* Author: jgaebler
*
* Created on October 25, 2012, 3:00 PM
*/
#include "UnicastMessage.h"
#include "Dispatcher.h"
#include "common/validator/MessageValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param name The name of the message.
* @param type The type of the message.
*/
UnicastMessage::UnicastMessage()
: ExteriorMessage("UM", UM), sequ(0), isLastMessage(false) {
}
/**
* @brief Copy constructor
* @param orig The message to copy
*/
UnicastMessage::UnicastMessage( const UnicastMessage& other)
: ExteriorMessage(other) {
operator=( other);
}
UnicastMessage::~UnicastMessage() {
}
void
UnicastMessage::handleReceive(Dispatcher & dis) {
//validate the message
if (dis.getMessageValidator()->isValid( *this)) {
dis.getUnicastTransfer().handleMessage(*this);
}
}
UnicastMessage*
UnicastMessage::dup() const {
return new UnicastMessage(*this);
}
/**
* @brief Assignment operator.
* @param other The instance to assign.
* @return A reference to the local instance.
*/
UnicastMessage&
UnicastMessage::operator=( const UnicastMessage & other) {
ExteriorMessage::operator =(other);
isLastMessage = other.isLastMessage;
sequ = other.sequ;
messageReference = other.messageReference;
return *this;
}
/**
* @brief Returns the sequence number of the message.
* @return The sequence number of the message.
*/
int
UnicastMessage::getSequ() const {
return sequ;
}
/**
* @brief Sets the sequence number of the message.
* @param sequ The sequence number of the message.
*/
void
UnicastMessage::setSequ( const int sequ) {
this->sequ = sequ;
}
/**
* @brief Returns the isLast field of the message, which indicates if this message the last within a sequence of messages.
* @return True, if this message the last on, false otherwise.
*/
bool
UnicastMessage::getIsLast(){
return isLastMessage;
}
/**
* @brief Sets the isLast field of the message. The default value is false.
* @param isLast True, if this message the last message of a dedicated sequence, false otherwise.
*/
void
UnicastMessage::setIsLast( const bool isLast){
isLastMessage = isLast;
}
/**
* @brief Permits access to the message reference of the message.
* @return The message reference of the message.
*/
const MessageReference&
UnicastMessage::getMessageReference() const {
return messageReference;
}
/**
* @brief Sets the message reference of the message.
* @param mRef The message reference to set.
*/
void
UnicastMessage::setMessageReference( const MessageReference& mRef) {
messageReference = mRef;
}
/**
* @brief Archives the message.
* @param archive The archive to which the attributes are to add
*/
void
UnicastMessage::set( Archive& archive) {
ExteriorMessage::set(archive);
archive(isLastMessage);
archive(sequ);
archive(messageReference);
}
}
}