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

70 lines
1.8 KiB
C++

/*
* File: LTNodeQueue.h
* Author: jgaebler
*
* Created on April 14, 2010, 9:43 AM
*/
#pragma once
#ifndef _LTNODEQUEUE_H
#define _LTNODEQUEUE_H
#include "LTNode.h"
#include "common/Defines.h"
namespace ubeeme {
namespace moversight {
/**
* @class LTNodeQueue
* @brief Provides a sorted queue for storing received peer messages. The messages are ordered by the lt field of the LTNode container. If the first message within the queue marked as deliverable, the node can be delivered to the user.
* @ingroup Moversight
* @author Jan Gäbler
*/
class LTNodeQueue {
public:
LTNodeQueue();
virtual ~LTNodeQueue();
void add(LTNode & node);
void clear();
size_t size() const;
void sort();
LTNode & front();
void dequeue();
bool contains(MessageReference & mRef) const;
LTNode * find(MessageReference & mRef);
void remove(MessageReference & mRef);
LTNode & get(const unsigned int i);
bool isEmpty();
private:
typedef std::vector<LTNode> NodeQueue;
NodeQueue queue;
class LTNodeEqualComparatorFunctor {
public:
LTNodeEqualComparatorFunctor(LTNode aNode) {
orig = aNode;
}
bool operator()(LTNode aNode) {
return orig.getPeerID() == aNode.getPeerID() && orig.getSequ() == aNode.getSequ() && orig.getMessageReference() == aNode.getMessageReference();
}//End operator()
private:
LTNode orig;
};
};
};
};
#endif /* _LTNODEQUEUE_H */