#ifndef __INET_IPASSIVEQUEUE_H
#define __INET_IPASSIVEQUEUE_H
#include <omnetpp.h>
#include "INETDefs.h"
class IPassiveQueueListener;
/**
* Abstract interface for passive queues.
*/
class INET_API IPassiveQueue
{
public:
virtual ~IPassiveQueue() {}
/**
* The queue should send a packet whenever this method is invoked.
* If the queue is currently empty, it should send a packet when
* when one becomes available.
*/
virtualvoid requestPacket() = 0;
/**
* Returns number of pending requests.
*/
virtualint getNumPendingRequests() = 0;
/**
* Return true when queue is empty, otherwise return false.
*/
virtualbool isEmpty() = 0;
/**
* Clear all queued packets and stored requests.
*/
virtualvoid clear() = 0;
/**
* Returns a packet directly from the queue, bypassing the primary,
* send-on-request mechanism. Returns NULL if the queue is empty.
*/
virtual cMessage *pop() = 0;
/**
* Adds a new listener to the listener list.
* It does nothing, if the listener list already contains the listener
* (by pointer equality).
*/
virtualvoid addListener(IPassiveQueueListener *listener) = 0;
/**
* Removes a listener from the listener list.
* It does nothing if the listener was not found on the listener list.
*/
virtualvoid removeListener(IPassiveQueueListener *listener) = 0;
};
/**
* Interface for notifying listeners about passive queue events.
*/
class INET_API IPassiveQueueListener
{
public:
virtual ~IPassiveQueueListener() {};
/**
* A packet arrived and it was added to the queue (the queue length
* increased by one). Therefore a subsequent requestPacket() call
* can deliver a packet immediately.
*/
virtualvoid packetEnqueued(IPassiveQueue *queue) = 0;
};
#endif