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

73 lines
2.2 KiB
C++

/*
* File: NVBValidator.cc
* Author: stubbfel
*
* Created on 14. August 2013, 20:30
*/
#include "NVBValidator.h"
namespace ubeeme {
namespace moversight {
/**
* @brief Constructor
* @param dis A dispatcher reference
*/
NVBValidator::NVBValidator(Dispatcher & dis) : MessageValidator(dis) {
}
/**
* @brief Destructor
*/
NVBValidator::~NVBValidator() {
}
/**
* @brief Checks, if the received interior message valid within the current group.
* @param msg The message to validate.
* @return True, if the received message checked as valid message within the current group, false otherwise.
*/
bool
NVBValidator::isValid(const MoversightMessage & msg) const {
return membershipService.contains( msg.getSourceID());
}
/**
* @brief Checks, if the received exterior message valid within the current view, or not.
* @param msg The message to validate.
* @return True, if the received message checked as valid message within the current view, false otherwise.
*/
bool
NVBValidator::isValid(const ExteriorMessage & msg) const {
return true;
}
/**
* @brief Checks, if the received multicast message valid within the current view, or not (in terms of relates to the current group setting).
* @param msg The message to validate.
* @return True, if the received message checked as valid message within the current view, false otherwise.
*/
bool
NVBValidator::isValid(const MulticastMessage & msg) const {
if (membershipService.contains(msg.getMessageReference().getPeerID()) ||
dispatcher.getLocalState() == WAITING_FOR_ROSTER) {
ViewID msgViewID = msg.getViewID();
ViewID msViewID = membershipService.getViewID();
if (msgViewID == msViewID) {
return true;
}
else if (msgViewID > msViewID) {
dispatcher.getNextViewBuffer().pushReceiveMsg(msg);
}
}
return false;
}
}
}