OMNeT++ Simulation Library  5.6.1
cPacketQueue Class Reference

#include <cpacketqueue.h>

Description

A queue class specialized for cPacket objects.

The added value is that this class keeps track of the total queue length in bits as well.

Inheritance diagram for cPacketQueue:
cQueue cOwnedObject cNamedObject cObject

Public Member Functions

Constructors, destructor, assignment.
 cPacketQueue (const char *name=nullptr, Comparator *cmp=nullptr)
 
 cPacketQueue (const char *name, CompareFunc cmp)
 
 cPacketQueue (const cPacketQueue &queue)
 
cPacketQueueoperator= (const cPacketQueue &queue)
 
Redefined cObject member functions.
virtual cPacketQueuedup () const override
 
virtual std::string str () const override
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
Setup, insertion and removal functions.
virtual void insert (cPacket *pkt)
 
virtual void insertBefore (cPacket *where, cPacket *pkt)
 
virtual void insertAfter (cPacket *where, cPacket *pkt)
 
virtual cPacketremove (cPacket *pkt)
 
virtual cPacketpop () override
 
virtual void clear () override
 
Query functions.
int64_t getBitLength () const
 
int64_t getByteLength () const
 
virtual cPacketfront () const override
 
virtual cPacketback () const override
 
virtual cPacketget (int i) const override
 
- Public Member Functions inherited from cQueue
 cQueue (const char *name=nullptr, Comparator *cmp=nullptr)
 
 cQueue (const char *name, CompareFunc cmp)
 
 cQueue (const cQueue &queue)
 
virtual ~cQueue ()
 
cQueueoperator= (const cQueue &queue)
 
virtual void forEachChild (cVisitor *v) override
 
virtual void setup (Comparator *cmp)
 
virtual void setup (CompareFunc cmp)
 
virtual int getLength () const
 
bool isEmpty () const
 
_OPPDEPRECATED int length () const
 
_OPPDEPRECATED bool empty () const
 
virtual bool contains (cObject *obj) const
 
void setTakeOwnership (bool tk)
 
bool getTakeOwnership () const
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
virtual bool isSoftOwner () const
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (const cNamedObject &o)
 
virtual void setName (const char *s)
 
virtual const char * getName () const override
 
virtual void setNamePooling (bool b)
 
virtual bool getNamePooling ()
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Additional Inherited Members

- Public Types inherited from cQueue
typedef int(* CompareFunc) (cObject *a, cObject *b)
 Function for comparing two cObjects, used by cQueue for priority queuing. More...
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cDefaultListgetDefaultOwner ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cPacketQueue() [1/3]

cPacketQueue ( const char *  name = nullptr,
Comparator cmp = nullptr 
)
inline

Constructor. When comparator argument is nullptr, the queue will act as FIFO, otherwise as priority queue.

◆ cPacketQueue() [2/3]

cPacketQueue ( const char *  name,
CompareFunc  cmp 
)
inline

Constructor. Sets up cPacketQueue as a priority queue.

◆ cPacketQueue() [3/3]

cPacketQueue ( const cPacketQueue queue)

Copy constructor. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them.

Member Function Documentation

◆ operator=()

cPacketQueue& operator= ( const cPacketQueue queue)

Assignment operator. Duplication and assignment work all right with cPacketQueue. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them.

The name member is not copied; see cNamedObject's operator=() for more details.

◆ dup()

virtual cPacketQueue* dup ( ) const
inlineoverridevirtual

Duplication and assignment work all right with cPacketQueue. Contained objects that are owned by the queue will be duplicated so that the new queue will have its own copy of them.

Reimplemented from cQueue.

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cQueue.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
overridevirtual

Serializes the object into an MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cQueue.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
overridevirtual

Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cQueue.

◆ insert()

virtual void insert ( cPacket pkt)
virtual

Adds an element to the back of the queue. Trying to insert nullptr is an error (throws cRuntimeError). The given object must be an instance of cPacket.

◆ insertBefore()

virtual void insertBefore ( cPacket where,
cPacket pkt 
)
virtual

Inserts exactly before the given object. If the given position does not exist or if you try to insert nullptr, cRuntimeError is thrown. The given object must be an instance of cPacket.

◆ insertAfter()

virtual void insertAfter ( cPacket where,
cPacket pkt 
)
virtual

Inserts exactly after the given object. If the given position does not exist or if you try to insert nullptr, cRuntimeError is thrown. The given object must be an instance of cPacket.

◆ remove()

virtual cPacket* remove ( cPacket pkt)
virtual

Unlinks and returns the object given. If the object is not in the queue, nullptr is returned. The given object must be an instance of cPacket.

◆ pop()

virtual cPacket* pop ( )
overridevirtual

Unlinks and returns the front element in the queue. If the queue is empty, cRuntimeError is thrown.

Reimplemented from cQueue.

◆ clear()

virtual void clear ( )
overridevirtual

Empties the container. Contained objects that were owned by the queue (see getTakeOwnership()) will be deleted.

Reimplemented from cQueue.

◆ getBitLength()

int64_t getBitLength ( ) const
inline

Returns the total size of the messages in the queue, in bits. This is the sum of the message bit lengths; see cPacket::getBitLength().

◆ getByteLength()

int64_t getByteLength ( ) const
inline

Returns the sum of the message lengths in bytes, that is, getBitLength()/8. If getBitLength() is not a multiple of 8, the result is rounded up.

◆ front()

virtual cPacket* front ( ) const
inlineoverridevirtual

Returns pointer to the object at the front of the queue. This is the element to be return by pop(). Returns nullptr if the queue is empty.

Reimplemented from cQueue.

References cQueue::front().

◆ back()

virtual cPacket* back ( ) const
inlineoverridevirtual

Returns pointer to the last (back) element in the queue. This is the element most recently added by insert(). Returns nullptr if the queue is empty.

Reimplemented from cQueue.

References cQueue::back().

◆ get()

virtual cPacket* get ( int  i) const
inlineoverridevirtual

Returns the ith element in the queue, or nullptr if i is out of range. get(0) returns the front element. This method performs linear search.

Reimplemented from cQueue.

References cQueue::get().


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