/* * File: StreamMessage.cc * Author: jgaebler * * Created on February 17, 2012, 3:55 PM */ #include "StreamMessage.h" #include "Dispatcher.h" #include "Moversight.h" #include "app/Application.h" #include "common/validator/MessageValidator.h" namespace ubeeme { namespace moversight { /** * @brief Constructor. */ StreamMessage::StreamMessage() : MoversightMessage( "SMDT", SMDT) { } /** * @brief Copy Constructor. * @param other The instance to copy. */ StreamMessage::StreamMessage( const StreamMessage& other) : MoversightMessage(other) { operator=( other); } /** * @brief Copy Constructor. * @param other Rvalue reference to a different StreamMessage. */ StreamMessage::StreamMessage( StreamMessage&& other) : MoversightMessage(other) { operator=( other); } /** * @brief Destructor. */ StreamMessage::~StreamMessage() { } /** * @brief Duplicates the current instance. A way to copy a message. * @return The duplicated instance. */ StreamMessage* StreamMessage::dup() const { return new StreamMessage( *this); } /** * @brief Assignment operator. * @param other The instance to assign. * @return A reference to the local instance. */ StreamMessage& StreamMessage::operator=( const StreamMessage& other) { if( this == &other) return *this; MoversightMessage::operator=( other); data = other.data; return *this; } /** * @brief Assignment operator. * @param other Rvalue reference to a different StreamMessage. * @return A reference to the local instance. */ StreamMessage& StreamMessage::operator=( StreamMessage&& other) { if( this == &other) return *this; MoversightMessage::operator=( other); data = std::move( other.data); return *this; } /** * @brief Sets the data. * @param sendData The data to be send */ void StreamMessage::setData( const ByteArray& sendData) { data = sendData; } /** * @brief Sets the data. * @param sendData Rvalue reference to the data to be set. */ void StreamMessage::setData( ByteArray&& sendData) { data = sendData; } /** * @brief Gets the Data * @return the ByteArray of data */ const ByteArray& StreamMessage::getData() const { return data; } /** * @brief Archives the message. * @param archive The archive to which the attributes are to add */ void StreamMessage::set( Archive& archive) { MoversightMessage::set( archive); archive( data); } /** * @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 StreamMessage::handleReceive( Dispatcher& dis) { //validate the message if( dis.getMessageValidator()->isValid( *this)) { //handle the message dis.getStreamTransfer().handleMessage( this); }//End if } /** * @brief Handles the message delivering. To deliver a message, the message to each module which is interested in this message. * @param dis A reference to the dispatcher, used to forward this message to the handling modules. */ void StreamMessage::handleDeliver( Dispatcher& dis) { #if OMNETPP dis.getMoversightCallback().receiveStreamMessage( *this, getSourceID()); #else dis.getMoversight().delegateReceive( data, getSource()); #endif } } }