INET Framework for OMNeT++/OMNEST
inet::queueing::PacketQueueBase Class Reference

#include <PacketQueueBase.h>

Inheritance diagram for inet::queueing::PacketQueueBase:
inet::queueing::PacketProcessorBase inet::queueing::IPacketQueue inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver inet::queueing::IPacketCollection inet::queueing::IPassivePacketSink inet::queueing::IPassivePacketSource inet::queueing::CompoundPacketQueueBase inet::queueing::PacketQueue inet::queueing::InProgressQueue

Public Member Functions

virtual bool canPullSomePacket (cGate *gate) const override
 Returns false if the packet source is empty at the given gate and no more packets can be pulled from it without raising an error. More...
 
virtual bool canPushSomePacket (cGate *gate) const override
 Returns false if the packet sink is full at the given gate and no more packets can be pushed into it without raising an error. More...
 
virtual void enqueuePacket (Packet *packet) override
 Enqueues the packet into the packet queue. More...
 
virtual PacketdequeuePacket () override
 Dequeues the packet from the packet queue. More...
 
virtual void pushPacketStart (Packet *packet, cGate *gate, bps datarate) override
 Starts pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketEnd (Packet *packet, cGate *gate) override
 Ends pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength=b(0)) override
 Progresses pushing the packet into the packet sink at the given gate. More...
 
virtual PacketpullPacketStart (cGate *gate, bps datarate) override
 Starts pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketEnd (cGate *gate) override
 Ends pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketProgress (cGate *gate, bps datarate, b position, b extraProcessableLength) override
 Progresses pulling the packet from the packet source at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::PacketProcessorBase
virtual bool supportsPacketSending (cGate *gate) const override
 Returns true if the processor supports sending packets at the given gate. More...
 
virtual bool supportsPacketPassing (cGate *gate) const override
 Returns true if the processor supports passing packets as a whole at the given gate. More...
 
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
virtual bool supportsPacketPushing (cGate *gate) const =0
 Returns true if the processor supports pushing packets at the given gate. More...
 
virtual bool supportsPacketPulling (cGate *gate) const =0
 Returns true if the processor supports pulling packets at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IPacketCollection
virtual int getMaxNumPackets () const =0
 Returns maximum allowed number of packets in the collection. More...
 
virtual int getNumPackets () const =0
 Returns the number of available packets in the collection in the range [0, inf). More...
 
virtual b getMaxTotalLength () const =0
 Returns maximum allowed total length of all packets in the collection. More...
 
virtual b getTotalLength () const =0
 Returns the total length of all packets in the collection in the range [0, inf). More...
 
virtual PacketgetPacket (int index) const =0
 Returns the packet at the given index. More...
 
virtual bool isEmpty () const =0
 Returns true if there are no packets available in the collection. More...
 
virtual void removePacket (Packet *packet)=0
 Removes a packet from the collection. More...
 
virtual void removeAllPackets ()=0
 Removes all packets from the collection. More...
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSink
virtual ~IPassivePacketSink ()
 
virtual bool canPushPacket (Packet *packet, cGate *gate) const =0
 Returns true if the given packet can be pushed at the given gate into the packet sink without raising an error. More...
 
virtual void pushPacket (Packet *packet, cGate *gate)=0
 Pushes the packet into the packet sink at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSource
virtual ~IPassivePacketSource ()
 
virtual PacketcanPullPacket (cGate *gate) const =0
 Returns the packet that can be pulled at the given gate. More...
 
virtual PacketpullPacket (cGate *gate)=0
 Pulls the packet from the packet source at the given gate. More...
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void emit (simsignal_t signal, cObject *object, cObject *details=nullptr) override
 
virtual const char * resolveDirective (char directive) const override
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handlePacketProcessed (Packet *packet)
 
virtual void checkPacketOperationSupport (cGate *gate) const
 
virtual void checkPacketOperationSupport (cGate *startGate, cGate *endGate) const
 
virtual void animate (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacket (Packet *packet, cGate *gate, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, long transmissionId, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions, Action action) const
 
virtual void pushOrSendPacket (Packet *packet, cGate *gate, IPassivePacketSink *consumer)
 
virtual void pushOrSendPacketStart (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
 
virtual void pushOrSendPacketEnd (Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
 
virtual void pushOrSendPacketProgress (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
 
virtual void animatePush (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacket (Packet *packet, cGate *gate) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void animatePull (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacket (Packet *packet, cGate *gate) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1)
 
virtual void updateDisplayString () const
 

Protected Attributes

int numPushedPackets = -1
 
int numPulledPackets = -1
 
int numRemovedPackets = -1
 
int numDroppedPackets = -1
 
int numCreatedPackets = -1
 
cGate * inputGate = nullptr
 
cGate * outputGate = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Member Function Documentation

◆ canPullSomePacket()

virtual bool inet::queueing::PacketQueueBase::canPullSomePacket ( cGate *  gate) const
inlineoverridevirtual

Returns false if the packet source is empty at the given gate and no more packets can be pulled from it without raising an error.

The gate must be a valid gate of this module and it must support pulling packets.

Implements inet::queueing::IPassivePacketSource.

Reimplemented in inet::queueing::PacketQueue, and inet::queueing::CompoundPacketQueueBase.

38 { return getNumPackets() > 0; }

◆ canPushSomePacket()

virtual bool inet::queueing::PacketQueueBase::canPushSomePacket ( cGate *  gate) const
inlineoverridevirtual

Returns false if the packet sink is full at the given gate and no more packets can be pushed into it without raising an error.

The gate must be a valid gate of this module and it must support pushing packets.

Implements inet::queueing::IPassivePacketSink.

Reimplemented in inet::queueing::PacketQueue, inet::queueing::CompoundPacketQueueBase, and inet::queueing::InProgressQueue.

39 { return true; }

◆ dequeuePacket()

Packet * inet::queueing::PacketQueueBase::dequeuePacket ( )
overridevirtual

Dequeues the packet from the packet queue.

The onwership of the packet is transferred from the queue to the caller.

The queue must not be empty. The returned packet must not be nullptr.

Implements inet::queueing::IPacketQueue.

47 {
48  auto packet = pullPacket(outputGate);
49  drop(packet);
50  return packet;
51 }

◆ emit()

void inet::queueing::PacketQueueBase::emit ( simsignal_t  signal,
cObject *  object,
cObject *  details = nullptr 
)
overrideprotectedvirtual

◆ enqueuePacket()

void inet::queueing::PacketQueueBase::enqueuePacket ( Packet packet)
overridevirtual

Enqueues the packet into the packet queue.

The onwership of the packet is transferred from the caller to the queue.

The queue must not be full. The packet must not be nullptr.

Implements inet::queueing::IPacketQueue.

42 {
43  pushPacket(packet, inputGate);
44 }

◆ handleMessage()

void inet::queueing::PacketQueueBase::handleMessage ( cMessage *  message)
overrideprotectedvirtual
36 {
37  auto packet = check_and_cast<Packet *>(message);
38  pushPacket(packet, packet->getArrivalGate());
39 }

◆ initialize()

void inet::queueing::PacketQueueBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketProcessorBase.

Reimplemented in inet::queueing::PacketQueue, and inet::queueing::CompoundPacketQueueBase.

17 {
19  if (stage == INITSTAGE_LOCAL) {
20  inputGate = gate("in");
21  outputGate = gate("out");
22  displayStringTextFormat = par("displayStringTextFormat");
23  numPushedPackets = 0;
24  numPulledPackets = 0;
28  WATCH(numPushedPackets);
29  WATCH(numPulledPackets);
30  WATCH(numRemovedPackets);
31  WATCH(numDroppedPackets);
32  }
33 }

Referenced by inet::queueing::CompoundPacketQueueBase::initialize(), and inet::queueing::PacketQueue::initialize().

◆ pullPacketEnd()

virtual Packet* inet::queueing::PacketQueueBase::pullPacketEnd ( cGate *  gate)
inlineoverridevirtual

Ends pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module ends streaming a packet from the the source.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Implements inet::queueing::IPassivePacketSource.

49 { throw cRuntimeError("Invalid operation"); }

◆ pullPacketProgress()

virtual Packet* inet::queueing::PacketQueueBase::pullPacketProgress ( cGate *  gate,
bps  datarate,
b  position,
b  extraProcessableLength 
)
inlineoverridevirtual

Progresses pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The position specifies where the packet streaming is at the moment. The extra length parameter partially fixes the future of the packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, to notify the source about a change in the packet data when a preemption occurs.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Implements inet::queueing::IPassivePacketSource.

50 { throw cRuntimeError("Invalid operation"); }

◆ pullPacketStart()

virtual Packet* inet::queueing::PacketQueueBase::pullPacketStart ( cGate *  gate,
bps  datarate 
)
inlineoverridevirtual

Starts pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module starts streaming a packet from the source.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Implements inet::queueing::IPassivePacketSource.

48 { throw cRuntimeError("Invalid operation"); }

◆ pushPacketEnd()

virtual void inet::queueing::PacketQueueBase::pushPacketEnd ( Packet packet,
cGate *  gate 
)
inlineoverridevirtual

Ends pushing the packet into the packet sink at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module ends streaming a packet to the sink.

The sink must not be full at the gate and no other packet streaming can be in progress. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and streaming packets.

Implements inet::queueing::IPassivePacketSink.

45 { throw cRuntimeError("Invalid operation"); }

◆ pushPacketProgress()

virtual void inet::queueing::PacketQueueBase::pushPacketProgress ( Packet packet,
cGate *  gate,
bps  datarate,
b  position,
b  extraProcessableLength = b(0) 
)
inlineoverridevirtual

Progresses pushing the packet into the packet sink at the given gate.

This is a packet streaming operation. The position specifies where the packet streaming is at the moment. The extra length parameter partially fixes the future of the packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, to notify the sink about a change in the packet data when a preemption occurs.

The sink must not be full at the gate and no other packet streaming can be in progress. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and streaming packets.

Implements inet::queueing::IPassivePacketSink.

46 { throw cRuntimeError("Invalid operation"); }

◆ pushPacketStart()

virtual void inet::queueing::PacketQueueBase::pushPacketStart ( Packet packet,
cGate *  gate,
bps  datarate 
)
inlineoverridevirtual

Starts pushing the packet into the packet sink at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module starts streaming a packet to the sink.

The sink must not be full at the gate and no other packet streaming can be in progress. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and streaming packets.

Implements inet::queueing::IPassivePacketSink.

44 { throw cRuntimeError("Invalid operation"); }

◆ resolveDirective()

const char * inet::queueing::PacketQueueBase::resolveDirective ( char  directive) const
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketProcessorBase.

67 {
68  static std::string result;
69  switch (directive) {
70  case 'p':
71  result = std::to_string(getNumPackets());
72  break;
73  case 'l':
74  result = getTotalLength().str();
75  break;
76  case 'u':
77  result = std::to_string(numPushedPackets);
78  break;
79  case 'o':
80  result = std::to_string(numPulledPackets);
81  break;
82  case 'r':
83  result = std::to_string(numRemovedPackets);
84  break;
85  case 'd':
86  result = std::to_string(numDroppedPackets);
87  break;
88  case 'c':
89  result = std::to_string(numCreatedPackets);
90  break;
91  case 'n':
92  result = !isEmpty() ? getPacket(0)->getFullName() : "";
93  break;
94  default:
95  result = PacketProcessorBase::resolveDirective(directive);
96  break;
97  }
98  return result.c_str();
99 }

Member Data Documentation

◆ inputGate

◆ numCreatedPackets

int inet::queueing::PacketQueueBase::numCreatedPackets = -1
protected

◆ numDroppedPackets

int inet::queueing::PacketQueueBase::numDroppedPackets = -1
protected

◆ numPulledPackets

int inet::queueing::PacketQueueBase::numPulledPackets = -1
protected

Referenced by emit(), initialize(), and resolveDirective().

◆ numPushedPackets

int inet::queueing::PacketQueueBase::numPushedPackets = -1
protected

Referenced by emit(), initialize(), and resolveDirective().

◆ numRemovedPackets

int inet::queueing::PacketQueueBase::numRemovedPackets = -1
protected

Referenced by emit(), initialize(), and resolveDirective().

◆ outputGate


The documentation for this class was generated from the following files:
inet::queueing::PacketQueueBase::numPulledPackets
int numPulledPackets
Definition: PacketQueueBase.h:21
inet::queueing::PacketProcessorBase::initialize
virtual void initialize(int stage) override
Definition: PacketProcessorBase.cc:16
inet::units::value::str
std::string str() const
Definition: Units.h:101
inet::queueing::PacketQueueBase::numPushedPackets
int numPushedPackets
Definition: PacketQueueBase.h:20
inet::queueing::IPassivePacketSink::pushPacket
virtual void pushPacket(Packet *packet, cGate *gate)=0
Pushes the packet into the packet sink at the given gate.
inet::queueing::IPacketCollection::isEmpty
virtual bool isEmpty() const =0
Returns true if there are no packets available in the collection.
inet::packetRemovedSignal
simsignal_t packetRemovedSignal
Definition: Simsignals.cc:84
inet::packetPulledSignal
simsignal_t packetPulledSignal
Definition: Simsignals.cc:105
inet::queueing::IPacketCollection::getNumPackets
virtual int getNumPackets() const =0
Returns the number of available packets in the collection in the range [0, inf).
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::packetPushedSignal
simsignal_t packetPushedSignal
Definition: Simsignals.cc:99
inet::queueing::PacketProcessorBase::resolveDirective
virtual const char * resolveDirective(char directive) const override
Definition: PacketProcessorBase.cc:407
inet::queueing::PacketQueueBase::numDroppedPackets
int numDroppedPackets
Definition: PacketQueueBase.h:23
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::IPacketCollection::getPacket
virtual Packet * getPacket(int index) const =0
Returns the packet at the given index.
inet::queueing::PacketQueueBase::numCreatedPackets
int numCreatedPackets
Definition: PacketQueueBase.h:24
inet::queueing::PacketQueueBase::outputGate
cGate * outputGate
Definition: PacketQueueBase.h:27
inet::queueing::PacketProcessorBase::displayStringTextFormat
const char * displayStringTextFormat
Definition: PacketProcessorBase.h:29
inet::Packet::getFullName
virtual const char * getFullName() const override
Returns the full name of the packet.
Definition: Packet.cc:290
inet::queueing::PacketQueueBase::numRemovedPackets
int numRemovedPackets
Definition: PacketQueueBase.h:22
inet::queueing::IPacketCollection::getTotalLength
virtual b getTotalLength() const =0
Returns the total length of all packets in the collection in the range [0, inf).
inet::queueing::PacketQueueBase::inputGate
cGate * inputGate
Definition: PacketQueueBase.h:26
inet::queueing::IPassivePacketSource::pullPacket
virtual Packet * pullPacket(cGate *gate)=0
Pulls the packet from the packet source at the given gate.