Public Member Functions | Protected Member Functions | Protected Attributes

PassiveQueueBase Class Reference

#include <PassiveQueueBase.h>

Inheritance diagram for PassiveQueueBase:
IPassiveQueue DropTailQoSQueue DropTailQueue REDQueue

List of all members.

Public Member Functions

virtual void requestPacket ()

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void finish ()
virtual bool enqueue (cMessage *msg)=0
virtual cMessage * dequeue ()=0
virtual void sendOut (cMessage *msg)=0

Protected Attributes

int packetRequested
int numQueueReceived
int numQueueDropped

Detailed Description

Abstract base class for passive queues. Implements IPassiveQueue. Enqueue/dequeue have to be implemented in virtual functions in subclasses; the actual queue or piority queue data structure also goes into subclasses.

Definition at line 32 of file PassiveQueueBase.h.


Member Function Documentation

virtual cMessage* PassiveQueueBase::dequeue (  )  [protected, pure virtual]

Returns a packet from the queue, or NULL if the queue is empty.

Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.

Referenced by requestPacket().

virtual bool PassiveQueueBase::enqueue ( cMessage *  msg  )  [protected, pure virtual]

Inserts packet into the queue or the priority queue, or drops it (or another packet). Returns true if a packet was dropped.

Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.

Referenced by handleMessage().

void PassiveQueueBase::finish (  )  [protected, virtual]

Reimplemented in REDQueue.

Definition at line 74 of file PassiveQueueBase.cc.

{
    recordScalar("packets received by queue", numQueueReceived);
    recordScalar("packets dropped by queue", numQueueDropped);
}

void PassiveQueueBase::handleMessage ( cMessage *  msg  )  [protected, virtual]

Definition at line 36 of file PassiveQueueBase.cc.

{
    numQueueReceived++;
    if (packetRequested>0)
    {
        packetRequested--;
        sendOut(msg);
    }
    else
    {
        bool dropped = enqueue(msg);
        if (dropped)
            numQueueDropped++;
    }

    if (ev.isGUI())
    {
        char buf[40];
        sprintf(buf, "q rcvd: %d\nq dropped: %d", numQueueReceived, numQueueDropped);
        getDisplayString().setTagArg("t",0,buf);
    }
}

void PassiveQueueBase::initialize (  )  [protected, virtual]

Reimplemented in DropTailQoSQueue, DropTailQueue, and REDQueue.

Definition at line 23 of file PassiveQueueBase.cc.

{
    // state
    packetRequested = 0;
    WATCH(packetRequested);

    // statistics
    numQueueReceived = 0;
    numQueueDropped = 0;
    WATCH(numQueueReceived);
    WATCH(numQueueDropped);
}

void PassiveQueueBase::requestPacket (  )  [virtual]

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.

Implements IPassiveQueue.

Definition at line 59 of file PassiveQueueBase.cc.

{
    Enter_Method("requestPacket()");

    cMessage *msg = dequeue();
    if (msg==NULL)
    {
        packetRequested++;
    }
    else
    {
        sendOut(msg);
    }
}

virtual void PassiveQueueBase::sendOut ( cMessage *  msg  )  [protected, pure virtual]

Should be redefined to send out the packet; e.g. send(msg,"out").

Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.

Referenced by handleMessage(), and requestPacket().


Member Data Documentation

Definition at line 40 of file PassiveQueueBase.h.

Referenced by finish(), handleMessage(), and initialize().

Definition at line 39 of file PassiveQueueBase.h.

Referenced by finish(), handleMessage(), and initialize().

Definition at line 36 of file PassiveQueueBase.h.

Referenced by handleMessage(), initialize(), and requestPacket().


The documentation for this class was generated from the following files: