|
INET Framework for OMNeT++/OMNEST
|
This class represents a first in, first out queue of chunks. More...
#include <ChunkQueue.h>
Public Member Functions | |
Constructors, destructors and duplication related functions | |
| ChunkQueue (const char *name=nullptr, const Ptr< const Chunk > &content=EmptyChunk::singleton) | |
| ChunkQueue (const ChunkQueue &other) | |
| virtual ChunkQueue * | dup () const override |
Length querying related functions | |
| b | getLength () const |
| Returns the total length of data currently available in the queue. More... | |
| b | getPushedLength () const |
| Returns the total length of data pushed into the queue so far. More... | |
| b | getPoppedLength () const |
| Returns the total length of data popped from the queue so far. More... | |
Querying data related functions | |
| const Ptr< const Chunk > | peek (b length=b(-1), int flags=0) const |
| Returns the designated data from the head of the queue as an immutable chunk in its current representation. More... | |
| const Ptr< const Chunk > | peekAt (b offset, b length, int flags=0) const |
| Returns the designated data at the given offset as an immutable chunk in its current representation. More... | |
| template<typename T > | |
| bool | has (b length=b(-1)) const |
| Returns true if the designated data is available at the head of the queue in the requested representation. More... | |
| template<typename T > | |
| const Ptr< const T > | peek (b length=b(-1), int flags=0) const |
| Returns the designated data from the head of the queue as an immutable chunk in the requested representation. More... | |
| template<typename T > | |
| const Ptr< const T > | peekAt (b offset, b length=b(-1), int flags=0) const |
| Returns the designated data at the given offset as an immutable chunk in the requested representation. More... | |
| const Ptr< const Chunk > | peekAll (int flags=0) const |
| Returns all data in the queue in the current representation. More... | |
| const Ptr< const BitsChunk > | peekAllAsBits (int flags=0) const |
| Returns all data in the queue in the as a sequence of bits. More... | |
| const Ptr< const BytesChunk > | peekAllAsBytes (int flags=0) const |
| Returns all data in the queue in the as a sequence of bytes. More... | |
Removing data related functions | |
| const Ptr< const Chunk > | pop (b length=b(-1), int flags=0) |
| Pops the designated data and returns it as an immutable chunk in its current representation. More... | |
| template<typename T > | |
| const Ptr< const T > | pop (b length=b(-1), int flags=0) |
| Pops the designated data from the head of the queue and returns it as an immutable chunk in the requested representation. More... | |
| void | clear () |
| Erases all data from the queue. More... | |
Filling with data related functions | |
| void | push (const Ptr< const Chunk > &chunk) |
| Inserts the provided chunk at the tail of the queue. More... | |
| virtual std::string | str () const override |
| Returns a human readable string representation. More... | |
Protected Member Functions | |
| const Chunk * | getContent () const |
| bool | isIteratorConsistent (const Chunk::Iterator &iterator) |
| void | remove (b length) |
| void | moveIteratorOrRemove (b length) |
Protected Attributes | |
| b | pushedLength = b(0) |
| b | poppedLength = b(0) |
| Ptr< const Chunk > | content |
| This chunk is always immutable to allow arbitrary peeking. More... | |
| Chunk::Iterator | iterator |
Friends | |
| class | ChunkQueueDescriptor |
This class represents a first in, first out queue of chunks.
It is mainly useful for application and protocol buffers where the incoming chunks are guaranteed to be in order.
Internally, queues stores the data in different kind of chunks. See the Chunk class and its subclasses for details. All chunks are immutable in a queue. Chunks are automatically merged as they are pushed into the queue, and they are also shared among queues when duplicating.
In general, this class supports the following operations:
| inet::ChunkQueue::ChunkQueue | ( | const char * | name = nullptr, |
| const Ptr< const Chunk > & | content = EmptyChunk::singleton |
||
| ) |
| inet::ChunkQueue::ChunkQueue | ( | const ChunkQueue & | other | ) |
| void inet::ChunkQueue::clear | ( | ) |
Erases all data from the queue.
Referenced by inet::tcp::TcpSendQueue::init(), inet::tcp::TcpLwipSendQueue::setConnection(), and inet::tcp::TcpLwipReceiveQueue::setConnection().
|
inlineoverridevirtual |
|
inlineprotected |
|
inline |
Returns the total length of data currently available in the queue.
Referenced by clear(), inet::tcp::TcpLwipReceiveQueue::extractBytesUpTo(), inet::tcp::TcpLwipReceiveQueue::getAmountOfBufferedBytes(), inet::tcp::TcpLwipSendQueue::getBytesAvailable(), inet::tcp::TcpLwipSendQueue::getBytesForTcpLayer(), inet::tcp::TcpLwipReceiveQueue::getExtractableBytesUpTo(), inet::tcp::TcpLwipReceiveQueue::getQueueLength(), peek(), peekAt(), and pop().
|
inline |
Returns the total length of data popped from the queue so far.
|
inline |
Returns the total length of data pushed into the queue so far.
Returns true if the designated data is available at the head of the queue in the requested representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
|
inlineprotected |
Returns the designated data from the head of the queue as an immutable chunk in its current representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
Referenced by inet::tcp::TcpLwipSendQueue::getBytesForTcpLayer(), and pop().
|
inline |
Returns the designated data from the head of the queue as an immutable chunk in the requested representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
|
inline |
Returns all data in the queue in the current representation.
The length of the returned chunk is the same as the value returned by getLength().
|
inline |
Returns all data in the queue in the as a sequence of bits.
The length of the returned chunk is the same as the value returned by getLength().
|
inline |
Returns all data in the queue in the as a sequence of bytes.
The length of the returned chunk is the same as the value returned by getLength().
Returns the designated data at the given offset as an immutable chunk in its current representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
Referenced by inet::tcp::TcpSendQueue::createSegmentWithBytes().
|
inline |
Returns the designated data at the given offset as an immutable chunk in the requested representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
Pops the designated data and returns it as an immutable chunk in its current representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
Referenced by inet::tcp::TcpLwipSendQueue::dequeueTcpLayerMsg(), inet::tcp::TcpSendQueue::discardUpTo(), inet::tcp::TcpLwipReceiveQueue::extractBytesUpTo(), inet::TcpGenericServerApp::handleMessage(), inet::bgp::BgpRouter::socketDataArrived(), and inet::Ldp::socketDataArrived().
|
inline |
Pops the designated data from the head of the queue and returns it as an immutable chunk in the requested representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation.
| void inet::ChunkQueue::push | ( | const Ptr< const Chunk > & | chunk | ) |
Inserts the provided chunk at the tail of the queue.
Referenced by inet::tcp::TcpSendQueue::enqueueAppData(), inet::tcp::TcpLwipSendQueue::enqueueAppData(), inet::tcp::TcpLwipReceiveQueue::enqueueTcpLayerData(), inet::TcpGenericServerApp::handleMessage(), and inet::TcpSocket::ReceiveQueueBasedCallback::socketDataArrived().
|
protected |
Referenced by moveIteratorOrRemove().
|
overridevirtual |
Returns a human readable string representation.
Referenced by inet::operator<<(), and inet::tcp::TcpSendQueue::str().
|
friend |
|
protected |
This chunk is always immutable to allow arbitrary peeking.
Nevertheless it's reused if possible to allow efficient merging with newly added chunks.
Referenced by ChunkQueue(), clear(), moveIteratorOrRemove(), peek(), peekAt(), push(), remove(), and str().
|
protected |
Referenced by clear(), and moveIteratorOrRemove().