OMNeT++ Simulation Library
6.0.3
|
#include <cpacketqueue.h>
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.
Public Member Functions | |
Constructors, destructor, assignment. | |
cPacketQueue (const char *name=nullptr, Comparator *cmp=nullptr) | |
cPacketQueue (const char *name, CompareFunc cmp) | |
cPacketQueue (const cPacketQueue &queue) | |
cPacketQueue & | operator= (const cPacketQueue &queue) |
Redefined cObject member functions. | |
virtual cPacketQueue * | dup () 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 cPacket * | remove (cPacket *pkt) |
virtual cPacket * | pop () override |
virtual void | clear () override |
Query functions. | |
int64_t | getBitLength () const |
int64_t | getByteLength () const |
virtual cPacket * | front () const override |
virtual cPacket * | back () const override |
virtual cPacket * | get (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 () |
cQueue & | operator= (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 |
int | length () const |
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 () |
cOwnedObject & | operator= (const cOwnedObject &o) |
virtual cObject * | getOwner () const override |
virtual bool | isOwnedObject () const override |
Public Member Functions inherited from cNamedObject | |
cNamedObject () | |
cNamedObject (const char *name, bool namepooling=true) | |
cNamedObject (const cNamedObject &obj) | |
virtual | ~cNamedObject () |
cNamedObject & | operator= (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)=default | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
virtual std::string | getClassAndFullName () const |
virtual std::string | getClassAndFullPath () const |
const cObject * | getThisPtr () const |
virtual std::ostream & | printOn (std::ostream &os) const |
virtual bool | isSoftOwner () const |
cObject * | findObject (const char *name, bool deep=true) |
virtual cClassDescriptor * | getDescriptor () const |
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 cSoftOwner * | getOwningContext () |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
|
inline |
Constructor. When comparator argument is nullptr, the queue will act as FIFO, otherwise as priority queue.
|
inline |
Constructor. Sets up cPacketQueue as a priority queue.
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.
cPacketQueue& operator= | ( | const cPacketQueue & | queue | ) |
Assignment operator. 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::operator=() for details.
|
inlineoverridevirtual |
Creates and returns an exact copy of this object. 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.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
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.
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.
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.
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.
|
overridevirtual |
Unlinks and returns the front element in the queue. If the queue is empty, cRuntimeError is thrown.
Reimplemented from cQueue.
|
overridevirtual |
Empties the container. Contained objects that were owned by the queue (see getTakeOwnership()) will be deleted.
Reimplemented from cQueue.
|
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().
|
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.
|
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().
|
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().
|
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().