80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
/*
|
|
* File: NeighborhoodDetectionQueue.h
|
|
* Author: gschneid
|
|
*
|
|
* Created on August 28, 2012, 11:07 AM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef NEIGHBORHOODDETECTIONQUEUE_H
|
|
#define NEIGHBORHOODDETECTIONQUEUE_H
|
|
|
|
#include "common/container/PairQueue.h"
|
|
#include "common/Exception.h"
|
|
#include "container/PeerIDList.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @class NeighborhoodDetectionQueue
|
|
* @brief Provides a queue to store elements of the kind <PeerID, bool> to save
|
|
* the needed pairs for the partition detection.
|
|
* @author Grit Schneider
|
|
* @ingroup Moversight
|
|
*/
|
|
class NeighborhoodDetectionQueue : public PairQueue<PeerID, bool> {
|
|
public:
|
|
|
|
/**
|
|
* @brief Adds the given object with the correct key to the queue.
|
|
* @param master The associated object.
|
|
* @throws LogicException - because its not possible to get the needed information to add
|
|
* both parameters out of one of them.
|
|
*/
|
|
void add(bool master) {
|
|
master=master;
|
|
throw LogicException("Not working here");
|
|
}//End
|
|
|
|
/**
|
|
* @brief Adds the given key and value to the queue.
|
|
* @param pID The key to add - here its the PeerID.
|
|
* @param master The value to add with its key - here its a boolean whether the peer is master or not.
|
|
*/
|
|
void add(PeerID pID, bool master) {
|
|
PairQueue<PeerID, bool>::add(pID, master);
|
|
}
|
|
|
|
/**
|
|
* Method to extract only the PeerIDs (meaning the keys of the queue).
|
|
* @return a PeerIDList with all the PeerIDs in this queue.
|
|
*/
|
|
PeerIDList getPeerIDList() {
|
|
PeerIDList pIDList;
|
|
for (size_t i = 0; i < size(); i++) {
|
|
pIDList.add(getKey(i));
|
|
}
|
|
return pIDList;
|
|
}
|
|
|
|
/**
|
|
* @brief Method to extract all PeerIDs of the masters in the queue.
|
|
* @return PeerIDList of masters only.
|
|
*/
|
|
PeerIDList getMastersOnly() {
|
|
PeerIDList pIDList;
|
|
for (size_t i = 0; i < size(); i++) {
|
|
if (get(i)) {
|
|
pIDList.add(getKey(i));
|
|
}
|
|
}
|
|
return pIDList;
|
|
}
|
|
|
|
};
|
|
};
|
|
};
|
|
#endif /* NEIGHBORHOODDETECTIONQUEUE_H */
|
|
|