A queue class specialized for cPacket objects. More...
#include <cpacketqueue.h>
Public Member Functions | |
Constructors, destructor, assignment. | |
cPacketQueue (const char *name=NULL, CompareFunc cmp=NULL) | |
cPacketQueue (const cPacketQueue &queue) | |
cPacketQueue & | operator= (const cPacketQueue &queue) |
Redefined cObject member functions. | |
virtual cPacketQueue * | dup () const |
virtual std::string | info () const |
virtual void | parsimPack (cCommBuffer *buffer) |
virtual void | parsimUnpack (cCommBuffer *buffer) |
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 () |
virtual void | clear () |
Query functions. | |
int64 | getBitLength () const |
int64 | getByteLength () const |
virtual cPacket * | front () const |
virtual cPacket * | back () const |
cPacket * | get (int i) const |
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.
cPacketQueue::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.
virtual cPacket* cPacketQueue::back | ( | ) | const [inline, virtual] |
Returns pointer to the last (back) element in the queue.
This is the element most recently added by insert(). Returns NULL if the queue is empty.
Reimplemented from cQueue.
References cQueue::front().
virtual void cPacketQueue::clear | ( | ) | [virtual] |
Empties the container.
Contained objects that were owned by the queue (see getTakeOwnership()) will be deleted.
Reimplemented from cQueue.
virtual cPacketQueue* cPacketQueue::dup | ( | ) | const [inline, virtual] |
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.
virtual cPacket* cPacketQueue::front | ( | ) | const [inline, virtual] |
cPacket* cPacketQueue::get | ( | int | i | ) | const [inline] |
Returns the ith element in the queue, or NULL if i is out of range.
get(0) returns the front element. This method performs linear search.
Reimplemented from cQueue.
References cQueue::back().
int64 cPacketQueue::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().
int64 cPacketQueue::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.
virtual std::string cPacketQueue::info | ( | ) | const [virtual] |
virtual void cPacketQueue::insert | ( | cPacket * | pkt | ) | [virtual] |
Adds an element to the back of the queue.
Trying to insert a NULL pointer is an error (throws cRuntimeError). 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 a NULL pointer, cRuntimeError is thrown. 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 a NULL pointer, cRuntimeError is thrown. The given object must be an instance of cPacket.
cPacketQueue& 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.
virtual void cPacketQueue::parsimPack | ( | cCommBuffer * | buffer | ) | [virtual] |
virtual void cPacketQueue::parsimUnpack | ( | cCommBuffer * | buffer | ) | [virtual] |
virtual cPacket* cPacketQueue::pop | ( | ) | [virtual] |
Unlinks and returns the front element in the queue.
If the queue is empty, cRuntimeError is thrown.
Reimplemented from cQueue.
Unlinks and returns the object given.
If the object is not in the queue, NULL pointer is returned. The given object must be an instance of cPacket.