|
INET Framework for OMNeT++/OMNEST
|
This class represents a piece of data that is usually part of a packet or some other data such as a protocol buffer.
More...
#include <Chunk.h>
|
| enum | ChunkType {
CT_EMPTY,
CT_BITCOUNT,
CT_BITS,
CT_BYTECOUNT,
CT_BYTES,
CT_SLICE,
CT_ENCRYPTED,
CT_CPACKET,
CT_SEQUENCE,
CT_FIELDS
} |
| | This enum is used to avoid std::dynamic_cast and dynamicPtrCast. More...
|
| |
| enum | PeekFlag {
PF_ALLOW_NULLPTR = (1 << 0),
PF_ALLOW_EMPTY = (1 << 1),
PF_ALLOW_INCOMPLETE = (1 << 2),
PF_ALLOW_INCORRECT = (1 << 3),
PF_ALLOW_IMPROPERLY_REPRESENTED = (1 << 4),
PF_ALLOW_SERIALIZATION = (1 << 5),
PF_ALLOW_ALL = -1
} |
| | This enum specifies bitmasks for the flags argument of various peek functions. More...
|
| |
| enum | PrintLevel {
PRINT_LEVEL_TRACE,
PRINT_LEVEL_DEBUG,
PRINT_LEVEL_DETAIL,
PRINT_LEVEL_INFO,
PRINT_LEVEL_COMPLETE = INT_MIN
} |
| |
| enum | PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0),
PRINT_FLAG_MULTILINE = (1 << 1)
} |
| |
|
|
| | Chunk () |
| |
| | Chunk (const Chunk &other) |
| |
| virtual const Ptr< Chunk > | dupShared () const |
| | Returns a mutable copy of this chunk in a shared pointer. More...
|
| |
| virtual void | forEachChild (cVisitor *v) override |
| |
| virtual void | parsimPack (cCommBuffer *buffer) const override |
| |
| virtual void | parsimUnpack (cCommBuffer *buffer) override |
| |
|
| virtual bool | isMutable () const |
| |
| virtual bool | isImmutable () const |
| |
| virtual void | markImmutable () |
| |
| void | markMutableIfExclusivelyOwned () |
| |
|
| virtual bool | isComplete () const |
| |
| virtual bool | isIncomplete () const |
| |
| virtual void | markIncomplete () |
| |
|
| virtual bool | isCorrect () const |
| |
| virtual bool | isIncorrect () const |
| |
| virtual void | markIncorrect () |
| |
|
| virtual bool | isProperlyRepresented () const |
| |
| virtual bool | isImproperlyRepresented () const |
| |
| virtual void | markImproperlyRepresented () |
| |
|
| virtual void | moveIterator (Iterator &iterator, b length) const |
| |
| virtual void | seekIterator (Iterator &iterator, b position) const |
| |
|
| virtual bool | canInsertAtFront (const Ptr< const Chunk > &chunk) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| virtual bool | canInsertAtBack (const Ptr< const Chunk > &chunk) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| virtual bool | canInsertAt (const Ptr< const Chunk > &chunk, b offset) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| void | insertAtFront (const Ptr< const Chunk > &chunk) |
| | Inserts the provided chunk at the beginning of this chunk. More...
|
| |
| void | insertAtBack (const Ptr< const Chunk > &chunk) |
| | Inserts the provided chunk at the end of this chunk. More...
|
| |
| void | insertAt (const Ptr< const Chunk > &chunk, b offset) |
| | Inserts the provided chunk into this chunk. More...
|
| |
|
| virtual bool | canRemoveAtFront (b length) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| virtual bool | canRemoveAtBack (b length) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| virtual bool | canRemoveAt (b offset, b length) const |
| | Returns true if this chunk is capable of representing the result. More...
|
| |
| void | removeAtFront (b length) |
| | Removes the requested part from the beginning of this chunk. More...
|
| |
| void | removeAtBack (b length) |
| | Removes the requested part from the end of this chunk. More...
|
| |
| void | removeAt (b offset, b length) |
| | Removes the requested part from this chunk. More...
|
| |
|
| int | getChunkId () const |
| | Returns the sequentially assigned id. More...
|
| |
| virtual ChunkType | getChunkType () const =0 |
| | Returns the type of this chunk as an enum member. More...
|
| |
| virtual b | getChunkLength () const =0 |
| | Returns the length of data represented by this chunk. More...
|
| |
| virtual bool | containsSameData (const Chunk &other) const |
| | Returns true if the two chunks represent the same binary data. More...
|
| |
| virtual bool | isEmpty () const |
| | Returns true if this chunk contains no data. More...
|
| |
| const Ptr< Chunk > | simplify () const |
| | Returns the simplified representation of this chunk eliminating all potential redundancies. More...
|
| |
| const Ptr< Chunk > | peek (const Iterator &iterator, b length=unspecifiedLength, int flags=0) const |
| | Returns the designated part of the data represented by this chunk in its default representation. More...
|
| |
| template<typename T > |
| bool | has (const Iterator &iterator, b length=unspecifiedLength) const |
| | Returns whether if the designated part of the data is available in the requested representation. More...
|
| |
| template<typename T > |
| const Ptr< T > | peek (const Iterator &iterator, b length=unspecifiedLength, int flags=0) const |
| | Returns the designated part of the data represented by this chunk in the requested representation. More...
|
| |
|
| virtual SharingRegionTagSet & | getRegionTags () override |
| | Returns all region tags. More...
|
| |
| int | getNumTags () const |
| | Returns the number of chunk tags. More...
|
| |
| const Ptr< const TagBase > | getTag (int index) const |
| | Returns the chunk tag at the given index. More...
|
| |
| void | clearTags (b offset=b(0), b length=b(-1)) |
| | Clears the set of chunk tags in the given region. More...
|
| |
| void | copyTags (const Chunk &source, b sourceOffset=b(0), b offset=b(0), b length=b(-1)) |
| | Copies the set of chunk tags from the source region to the provided region. More...
|
| |
| template<typename T > |
| const Ptr< const T > | findTag (b offset=b(0), b length=b(-1)) const |
| | Returns the chunk tag for the provided type and range, or returns nullptr if no such chunk tag is found. More...
|
| |
| template<typename T > |
| const Ptr< const T > | getTag (b offset=b(0), b length=b(-1)) const |
| | Returns the chunk tag for the provided type and range, or throws an exception if no such chunk tag is found. More...
|
| |
| template<typename T > |
| void | mapAllTags (b offset, b length, std::function< void(b, b, const Ptr< const T > &)> f) const |
| | Maps all tags in the provided range to to the function. More...
|
| |
| template<typename T > |
| void | mapAllTagsForUpdate (b offset, b length, std::function< void(b, b, const Ptr< T > &)> f) |
| | Maps all tags in the provided range to to the function. More...
|
| |
| template<typename T > |
| std::vector< SharingRegionTagSet::RegionTag< const T > > | getAllTags (b offset=b(0), b length=b(-1)) const |
| | Returns all chunk tags for the provided type and range in a detached vector of region tags. More...
|
| |
| template<typename T > |
| std::vector< SharingRegionTagSet::RegionTag< T > > | getAllTagsForUpdate (b offset=b(0), b length=b(-1)) |
| | Returns all chunk tags for the provided type and range in a detached vector of region tags. More...
|
| |
| template<typename T > |
| const Ptr< T > | addTag (b offset=b(0), b length=b(-1)) |
| | Returns a newly added chunk tag for the provided type and range, or throws an exception if such a chunk tag is already present. More...
|
| |
| template<typename T > |
| const Ptr< T > | addTagIfAbsent (b offset=b(0), b length=b(-1)) |
| | Returns a newly added chunk tag for the provided type and range if absent, or returns the chunk tag that is already present. More...
|
| |
| template<typename T > |
| std::vector< SharingRegionTagSet::RegionTag< T > > | addTagsWhereAbsent (b offset=b(0), b length=b(-1)) |
| | Returns the newly added chunk tags for the provided type and range where the tag is absent. More...
|
| |
| template<typename T > |
| const Ptr< T > | removeTag (b offset, b length) |
| | Removes the chunk tag for the provided type and range, or throws an exception if no such chunk tag is found. More...
|
| |
| template<typename T > |
| const Ptr< T > | removeTagIfPresent (b offset, b length) |
| | Removes the chunk tag for the provided type and range if present, or returns nullptr if no such chunk tag is found. More...
|
| |
| template<typename T > |
| std::vector< SharingRegionTagSet::RegionTag< T > > | removeTagsWherePresent (b offset, b length) |
| | Removes and returns all chunk tags for the provided type and range. More...
|
| |
|
| virtual std::ostream & | printToStream (std::ostream &stream, int level, int evFlags=0) const override |
| | Prints an optinally formatted human readable string representation of the data present in this chunk to the given stream. More...
|
| |
| virtual std::ostream & | printFieldsToStream (std::ostream &stream, int level, int evFlags=0) const |
| | Prints an optinally formatted human readable string representation of the feilds of this chunk to the given stream. More...
|
| |
| virtual std::string | str () const override |
| | Returns a human readable string representation of the data present in this chunk. More...
|
| |
| virtual | ~IPrintableObject () |
| |
| virtual std::string | printToString () const |
| |
| virtual std::string | printToString (int level, int evFlags=0) const |
| |
| virtual std::string | getInfoStringRepresentation (int evFlags=0) const |
| |
| virtual std::string | getDetailStringRepresentation (int evFlags=0) const |
| |
| virtual std::string | getDebugStringRepresentation (int evFlags=0) const |
| |
| virtual std::string | getTraceStringRepresentation (int evFlags=0) const |
| |
| virtual std::string | getCompleteStringRepresentation (int evFlags=0) const |
| |
|
| typedef bool(* | PeekPredicate) (const Ptr< Chunk > &) |
| |
| const typedef Ptr< Chunk >(* | PeekConverter )(const Ptr< Chunk > &chunk, const Chunk::Iterator &iterator, b length, int flags) |
| |
| virtual void | handleChange () |
| |
| virtual void | doInsertAtFront (const Ptr< const Chunk > &chunk) |
| |
| virtual void | doInsertAtBack (const Ptr< const Chunk > &chunk) |
| |
| virtual void | doInsertAt (const Ptr< const Chunk > &chunk, b offset) |
| |
| virtual void | doRemoveAtFront (b length) |
| |
| virtual void | doRemoveAtBack (b length) |
| |
| virtual void | doRemoveAt (b offset, b length) |
| |
| virtual const Ptr< Chunk > | peekUnchecked (PeekPredicate predicate, PeekConverter converter, const Iterator &iterator, b length, int flags) const =0 |
| |
| template<typename T > |
| const Ptr< T > | peekConverted (const Iterator &iterator, b length, int flags) const |
| |
| template<typename T > |
| const Ptr< T > | checkPeekResult (const Ptr< T > &chunk, int flags) const |
| |
| static const Ptr< Chunk > | convertChunk (const std::type_info &typeInfo, const Ptr< Chunk > &chunk, b offset, b length, int flags) |
| | Creates a new chunk of the given type that represents the designated part of the provided chunk. More...
|
| |
This class represents a piece of data that is usually part of a packet or some other data such as a protocol buffer.
The chunk interface is designed to be very flexible in terms of alternative representations. For example, when the actual bytes in the data is irrelevant, a chunk can be as simple as an integer specifying its length. Contrary, sometimes it might be necessary to represent the data bytes as is. For example, when one is using an external program to send or receive the data. But most often it's better to have a representation that is easy to inspect and understand during debugging. Fortunately, this representation can be easily generated using the omnetpp message compiler. In any case, chunks can always be converted to and from a sequence of bytes using the corresponding serializer.
Chunks can represent data in different ways:
Chunks are initially:
- mutable, then may become immutable, but never the other way around. There is one exception to this rule, when the chunk is exclusively owned. That is when it has exactly one reference. Immutable chunks cannot be changed anymore because they might be used to efficiently share data.
- complete, then may become incomplete, but never the other way around. Incomplete chunks are not totally filled in. For example, when a chunk is created by deserializing it from insufficient amount of data.
- correct, then may become incorrect, but never the other way around. Incorrect chunks contain bit errors. For example, when a packet is sent through a lossy channel causing bit errors in it.
- properly represented, then may become improperly represented, but never the other way around. Improperly represented chunks misrepresent their data. For example, when a chunk is created by deserializing data but the field based representation does not fully support all possible data.
Chunks can be safely shared using Ptr. In fact, the reason for having immutable chunks is to allow for efficient sharing using shared pointers. For example, when a Packet data structure is duplicated the copy can share immutable chunks with the original.
In general, chunks support the following operations:
- insert to the beginning or end
- remove from the beginning or end
- query length and peek an arbitrary part
- serialize to and deserialize from a sequence of bytes
- copy to a new mutable chunk
- convert to a human readable string
The chunk API supports polymorphism, so it's possible to create chunk class hierarchies with proper automatic deserialization. Chunks can be nested into each other similarly how SliceChunk and SequenceChunk does it. You can find examples for these in the tests folder of INET.
Communication protocol headers often contain optional parts. There are many ways to represent optional fields with chunks. For example, the IP header contains an optional part that is a list of IP specific options. Assuming the packet already contains a SequenceChunk, the IP header can be represented in various ways. Here are a few examples:
Communication protocol headers also often contain CRC or checksum fields. In network simulations, most of the time it's unnecessary to compute the correct CRC. One can safely assume the correct CRC is present, unless the packet has to be serialized. As for the representation, a FieldsChunk subclass should contain a CRC field and possibly a CRC mode field. Please note that computing, inserting and verifying the actual CRC is not the task of the chunk serializer but rather the task of the communication protocol. You can find a few examples how to implement CRC insertion and verification in the TCP/IP protocol stack.
Implementing lossy communication channels is somewhat more complicated but also more flexible with new chunk API. Whenever a packet passes through a lossy channel there are a number of options to represent errors.
- the simplest way is marking the whole packet erroneous via setBitError()
- a more detailed way would be iterating through the chunks in the packet and marking the erroneous chunks via markIncorrect(). Note that the chunks marked this way has to be duplicated before, and they have to be replaced in the packet to avoid accidentally propagating the same error to multiple receivers.
- the most detailed way is asking for the BytesChunk (or BitsChunk) of the packet and actually changing the erroneous bytes (bits) before the packet arrives at the receiver. Fortunately, the receiver doesn't have to worry about receiving a packet containing bytes instead of the original chunks, because the chunk API provides the requested chunk types either way.
Representation duality is a very important aspect of the chunk API. It means that a protocol doesn't have to worry about the actual representation of the packet's data while it's processing. For example, when the IP protocol peeks the packet for the IpHeader, there are a few possiblities. The requested class is either already there to be returned, or if the packet contains the raw bytes, then it's going to be deserialized automatically and transparently.
In fact, the chunk API supports turning any kind of chunk into any other kind of chunk using serialization/deserialization. This represents the fact that the protocol data is really a sequence of bits and any other representation is just a view on top of that. Of course, this could lead to all sorts of surprising things such as accidentally processing a Foo protocol header as a Bar protocol header. This can happen due bit errors (e.g. incorrect length field) or programming errors. To avoid hard to debug errors this conversion is disabled by default.
General rules for peeking into a chunk: 1) Peeking never returns a) a SliceChunk containing
- a BitsChunk
- a BitCountChunk
- a BytesChunk
- a ByteCountChunk
- another SliceChunk
- the whole of another chunk
- a SequenceChunk with superfluous elements b) a SequenceChunk containing
- connecting BitsChunks
- connecting BitCountChunks
- connecting BytesChunks
- connecting ByteCountChunks
- connecting SliceChunks of the same chunk
- another SequenceChunk
- only one chunk 2) Peeking (various special cases) a) an empty part of the chunk returns nullptr if allowed b) the whole of the chunk returns the chunk c) any part that is directly represented by another chunk returns that chunk 3) Peeking without providing a return type for a a) BitsChunk always returns a BitsChunk containing the bits of the requested part b) BitCountChunk always returns a BitCountChunk containing the requested length c) BytesChunk always returns a BytesChunk containing the bytes of the requested part d) ByteCountChunk always returns a ByteCountChunk containing the requested length e) SliceChunk always returns a SliceChunk containing the requested slice of the chunk that is used by the original SliceChunk f) SequenceChunk may return
- an element chunk
- a SliceChunk of an element chunk
- a SliceChunk using the original SequenceChunk
- a new SequenceChunk using the elements of the original SequenceChunk g) any other chunk returns a SliceChunk 4) Peeking with providing a return type always returns a chunk of the requested type (or a subtype thereof) a) Peeking with a BitCountChunk return type for any chunk returns a BitCountChunk containing the requested bit length b) Peeking with a BitsChunk return type for any chunk returns a BitsChunk containing a part of the serialized bits of the original chunk c) Peeking with a ByteCountChunk return type for any chunk returns a ByteCountChunk containing the requested byte length d) Peeking with a BytesChunk return type for any chunk returns a BytesChunk containing a part of the serialized bytes of the original chunk e) Peeking with a SliceChunk return type for any chunk returns a SliceChunk containing the requested slice of the original chunk f) Peeking with a SequenceChunk return type is an error g) Peeking with a any other return type for any chunk returns a chunk of the requested type containing data deserialized from the bytes that were serialized from the original chunk 5) Peeking never returns a chunk that is one of the following unless it's explicitly allowed by passing the corresponding peek flag a) a nullptr b) an incomplete chunk c) an incorrect chunk d) an improperly represented chunk e) a chunk converted from Foo to Bar
General rules for inserting a chunk into another: a) Inserting a BitsChunk into a BitsChunk merges them b) Inserting a BitCountChunk into a BitCountChunk merges them c) Inserting a BytesChunk into a BytesChunk merges them d) Inserting a ByteCountChunk into a ByteCountChunk merges them e) Inserting a connecting SliceChunk into a SliceChunk merges them
◆ PeekPredicate
| typedef bool(* inet::Chunk::PeekPredicate) (const Ptr< Chunk > &) |
|
protected |
◆ ChunkFlag
This enum specifies bitmasks for the flags field of Chunk.
| Enumerator |
|---|
| CF_IMMUTABLE | |
| CF_INCOMPLETE | |
| CF_INCORRECT | |
| CF_IMPROPERLY_REPRESENTED | |
◆ ChunkType
This enum is used to avoid std::dynamic_cast and dynamicPtrCast.
| Enumerator |
|---|
| CT_EMPTY | |
| CT_BITCOUNT | |
| CT_BITS | |
| CT_BYTECOUNT | |
| CT_BYTES | |
| CT_SLICE | |
| CT_ENCRYPTED | |
| CT_CPACKET | |
| CT_SEQUENCE | |
| CT_FIELDS | |
◆ PeekFlag
This enum specifies bitmasks for the flags argument of various peek functions.
| Enumerator |
|---|
| PF_ALLOW_NULLPTR | |
| PF_ALLOW_EMPTY | |
| PF_ALLOW_INCOMPLETE | |
| PF_ALLOW_INCORRECT | |
| PF_ALLOW_IMPROPERLY_REPRESENTED | |
| PF_ALLOW_SERIALIZATION | |
| PF_ALLOW_ALL | |
◆ Chunk() [1/2]
◆ Chunk() [2/2]
| inet::Chunk::Chunk |
( |
const Chunk & |
other | ) |
|
26 SharedBase<Chunk>(other),
◆ _getTag()
◆ addTag()
template<typename T >
| const Ptr<T> inet::Chunk::addTag |
( |
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| |
|
inline |
◆ addTagIfAbsent()
template<typename T >
| const Ptr<T> inet::Chunk::addTagIfAbsent |
( |
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| |
|
inline |
◆ addTagsWhereAbsent()
Returns the newly added chunk tags for the provided type and range where the tag is absent.
◆ canInsertAt()
| virtual bool inet::Chunk::canInsertAt |
( |
const Ptr< const Chunk > & |
chunk, |
|
|
b |
offset |
|
) |
| const |
|
inlinevirtual |
◆ canInsertAtBack()
| virtual bool inet::Chunk::canInsertAtBack |
( |
const Ptr< const Chunk > & |
chunk | ) |
const |
|
inlinevirtual |
◆ canInsertAtFront()
| virtual bool inet::Chunk::canInsertAtFront |
( |
const Ptr< const Chunk > & |
chunk | ) |
const |
|
inlinevirtual |
◆ canRemoveAt()
| virtual bool inet::Chunk::canRemoveAt |
( |
b |
offset, |
|
|
b |
length |
|
) |
| const |
|
inlinevirtual |
◆ canRemoveAtBack()
| virtual bool inet::Chunk::canRemoveAtBack |
( |
b |
length | ) |
const |
|
inlinevirtual |
◆ canRemoveAtFront()
| virtual bool inet::Chunk::canRemoveAtFront |
( |
b |
length | ) |
const |
|
inlinevirtual |
◆ checkMutable()
| void inet::Chunk::checkMutable |
( |
| ) |
const |
|
inlineprotected |
◆ checkPeekResult()
template<typename T >
| const Ptr<T> inet::Chunk::checkPeekResult |
( |
const Ptr< T > & |
chunk, |
|
|
int |
flags |
|
) |
| const |
|
inlineprotected |
409 if (chunk ==
nullptr) {
411 throw cRuntimeError(
"Returning an empty chunk (nullptr) is not allowed according to the flags: %x",
flags);
413 else if (chunk->getChunkType() ==
CT_EMPTY) {
415 throw cRuntimeError(
"Returning an empty chunk (EmptyChunk) is not allowed according to the flags: %x",
flags);
419 throw cRuntimeError(
"Returning an incomplete chunk is not allowed according to the flags: %x",
flags);
421 throw cRuntimeError(
"Returning an incorrect chunk is not allowed according to the flags: %x",
flags);
423 throw cRuntimeError(
"Returning an improperly represented chunk is not allowed according to the flags: %x",
flags);
◆ clearTags()
| void inet::Chunk::clearTags |
( |
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| |
|
inline |
Clears the set of chunk tags in the given region.
◆ containsSameData()
| virtual bool inet::Chunk::containsSameData |
( |
const Chunk & |
other | ) |
const |
|
inlinevirtual |
Returns true if the two chunks represent the same binary data.
The two chunks are compared without serialization, and the method is allowed to return false if the result cannot be determined correctly. Tags and other metadata are ignored in the comparison.
Reimplemented in inet::SliceChunk, inet::EncryptedChunk, inet::BytesChunk, inet::SequenceChunk, inet::BitsChunk, inet::BitCountChunk, inet::ByteCountChunk, inet::FieldsChunk, and inet::cPacketChunk.
Referenced by inet::cPacketChunk::containsSameData(), inet::FieldsChunk::containsSameData(), inet::BitCountChunk::containsSameData(), inet::ByteCountChunk::containsSameData(), inet::BitsChunk::containsSameData(), inet::SequenceChunk::containsSameData(), inet::BytesChunk::containsSameData(), inet::EncryptedChunk::containsSameData(), and inet::SliceChunk::containsSameData().
◆ convertChunk()
| const Ptr< Chunk > inet::Chunk::convertChunk |
( |
const std::type_info & |
typeInfo, |
|
|
const Ptr< Chunk > & |
chunk, |
|
|
b |
offset, |
|
|
b |
length, |
|
|
int |
flags |
|
) |
| |
|
staticprotected |
Creates a new chunk of the given type that represents the designated part of the provided chunk.
The designated part starts at the provided offset and has the provided length. This function isn't a constructor to allow creating instances of message compiler generated field based chunk classes.
119 auto chunkType = chunk->getChunkType();
121 auto chunkObject = chunk.get();
122 throw cRuntimeError(
"Implicit data reinterpretation via chunk serialization/deserialization (%s -> %s) is disabled to prevent unexpected behavior due to reinterpretation and unpredictable performance degradation due to overhead (you may consider changing the Chunk::enableImplicitChunkSerialization flag or passing the PF_ALLOW_SERIALIZATION flag)", opp_typename(
typeid(*chunkObject)), opp_typename(typeInfo));
124 MemoryOutputStream outputStream;
125 serialize(outputStream, chunk, offset, length <
b(0) ?
std::min(-length, chunk->getChunkLength() - offset) : length);
126 MemoryInputStream inputStream(outputStream.getData());
127 const auto& result =
deserialize(inputStream, typeInfo);
128 result->regionTags.copyTags(chunk->regionTags, offset,
b(0), result->getChunkLength());
Referenced by inet::FieldsChunk::convertChunk().
◆ copyTags()
| void inet::Chunk::copyTags |
( |
const Chunk & |
source, |
|
|
b |
sourceOffset = b(0), |
|
|
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| |
|
inline |
Copies the set of chunk tags from the source region to the provided region.
◆ deserialize()
Deserializes a chunk from the given stream.
The returned chunk will be an instance of the provided type. The chunk represents the bytes in the stream starting from the current stream position up to the length required by the deserializer of the chunk.
195 #if CHUNK_CHECK_IMPLEMENTATION_ENABLED
196 auto startPosition =
B(stream.getPosition());
198 auto chunk = serializer->deserialize(stream, typeInfo);
199 #if CHUNK_CHECK_IMPLEMENTATION_ENABLED
200 auto endPosition =
B(stream.getPosition());
203 if (stream.isReadBeyondEnd())
204 chunk->markIncomplete();
Referenced by convertChunk().
◆ doInsertAt()
| virtual void inet::Chunk::doInsertAt |
( |
const Ptr< const Chunk > & |
chunk, |
|
|
b |
offset |
|
) |
| |
|
inlineprotectedvirtual |
◆ doInsertAtBack()
| virtual void inet::Chunk::doInsertAtBack |
( |
const Ptr< const Chunk > & |
chunk | ) |
|
|
inlineprotectedvirtual |
◆ doInsertAtFront()
| virtual void inet::Chunk::doInsertAtFront |
( |
const Ptr< const Chunk > & |
chunk | ) |
|
|
inlineprotectedvirtual |
◆ doRemoveAt()
| virtual void inet::Chunk::doRemoveAt |
( |
b |
offset, |
|
|
b |
length |
|
) |
| |
|
inlineprotectedvirtual |
◆ doRemoveAtBack()
| virtual void inet::Chunk::doRemoveAtBack |
( |
b |
length | ) |
|
|
inlineprotectedvirtual |
◆ doRemoveAtFront()
| virtual void inet::Chunk::doRemoveAtFront |
( |
b |
length | ) |
|
|
inlineprotectedvirtual |
◆ dupShared()
| virtual const Ptr<Chunk> inet::Chunk::dupShared |
( |
| ) |
const |
|
inlinevirtual |
Returns a mutable copy of this chunk in a shared pointer.
Reimplemented in inet::SequenceChunk, inet::SliceChunk, inet::BytesChunk, inet::BitCountChunk, inet::BitsChunk, inet::ByteCountChunk, inet::EncryptedChunk, inet::cPacketChunk, and inet::EmptyChunk.
437 {
return Ptr<Chunk>(
static_cast<Chunk *
>(dup())); }
Referenced by inet::ieee80211::Defragmentation::defragmentFrames(), inet::ProbabilisticBroadcast::handleLowerPacket(), inet::Dsdv::handleMessageWhenUp(), inet::FieldsChunk::peekUnchecked(), inet::RsvpTe::processPathMsg(), and inet::Rip::processRequest().
◆ findTag()
template<typename T >
| const Ptr<const T> inet::Chunk::findTag |
( |
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| const |
|
inline |
Returns the chunk tag for the provided type and range, or returns nullptr if no such chunk tag is found.
◆ forEachChild()
| void inet::Chunk::forEachChild |
( |
cVisitor * |
v | ) |
|
|
overridevirtual |
◆ getAllTags()
Returns all chunk tags for the provided type and range in a detached vector of region tags.
◆ getAllTagsForUpdate()
Returns all chunk tags for the provided type and range in a detached vector of region tags.
◆ getBinDumpLine()
| const char * inet::Chunk::getBinDumpLine |
( |
int |
index | ) |
|
|
protected |
74 int offset = index * 32;
76 MemoryOutputStream outputStream;
77 serialize(outputStream, shared_from_this(),
b(offset),
b(length));
78 std::vector<bool> bits;
79 outputStream.copyData(bits);
80 for (
int i = 0; i < length; i++) {
81 if (i != 0 && i % 4 == 0)
83 asStringValue += (bits[i] ?
"1" :
"0");
86 catch (cRuntimeError&
e) {
87 asStringValue =
e.what();
89 return asStringValue.c_str();
◆ getBinDumpNumLines()
| int inet::Chunk::getBinDumpNumLines |
( |
| ) |
const |
|
protected |
◆ getChunkId()
| int inet::Chunk::getChunkId |
( |
| ) |
const |
|
inline |
Returns the sequentially assigned id.
◆ getChunkLength()
| virtual b inet::Chunk::getChunkLength |
( |
| ) |
const |
|
pure virtual |
Returns the length of data represented by this chunk.
Implemented in inet::SequenceChunk, inet::SliceChunk, inet::EncryptedChunk, inet::BytesChunk, inet::BitsChunk, inet::BitCountChunk, inet::ByteCountChunk, inet::FieldsChunk, inet::cPacketChunk, inet::EmptyChunk, and inet::PacketDissector::ProtocolDataUnit.
Referenced by containsSameData(), getBinDumpLine(), getBinDumpNumLines(), getHexDumpLine(), getHexDumpNumLines(), printFieldsToStream(), and serialize().
◆ getChunkType()
| virtual ChunkType inet::Chunk::getChunkType |
( |
| ) |
const |
|
pure virtual |
Returns the type of this chunk as an enum member.
This can be used to avoid expensive std::dynamic_cast and dynamicPtrCast operators.
Implemented in inet::SequenceChunk, inet::SliceChunk, inet::EncryptedChunk, inet::BytesChunk, inet::BitsChunk, inet::BitCountChunk, inet::ByteCountChunk, inet::FieldsChunk, inet::cPacketChunk, inet::EmptyChunk, and inet::PacketDissector::ProtocolDataUnit.
Referenced by containsSameData().
◆ getHexDumpLine()
| const char * inet::Chunk::getHexDumpLine |
( |
int |
index | ) |
|
|
protected |
96 int offset = index * 8 * 16;
98 MemoryOutputStream outputStream;
99 serialize(outputStream, shared_from_this(),
b(offset),
b(length));
100 ASSERT(outputStream.getLength() ==
b(length));
101 std::vector<uint8_t> bytes;
102 outputStream.copyData(bytes);
104 for (
size_t i = 0; i < bytes.size(); i++) {
106 asStringValue +=
" ";
107 sprintf(tmp,
"%02X", bytes[i]);
108 asStringValue += tmp;
111 catch (cRuntimeError&
e) {
112 asStringValue =
e.what();
114 return asStringValue.c_str();
◆ getHexDumpNumLines()
| int inet::Chunk::getHexDumpNumLines |
( |
| ) |
const |
|
protected |
◆ getNumTags()
| int inet::Chunk::getNumTags |
( |
| ) |
const |
|
inline |
Returns the number of chunk tags.
◆ getRegionTags()
◆ getTag() [1/2]
template<typename T >
| const Ptr<const T> inet::Chunk::getTag |
( |
b |
offset = b(0), |
|
|
b |
length = b(-1) |
|
) |
| const |
|
inline |
Returns the chunk tag for the provided type and range, or throws an exception if no such chunk tag is found.
◆ getTag() [2/2]
| const Ptr<const TagBase> inet::Chunk::getTag |
( |
int |
index | ) |
const |
|
inline |
Returns the chunk tag at the given index.
◆ handleChange()
| void inet::Chunk::handleChange |
( |
| ) |
|
|
protectedvirtual |
Reimplemented in inet::FieldsChunk.
Referenced by inet::BytesChunk::copyFromBuffer(), inet::FieldsChunk::handleChange(), inet::BitsChunk::setBit(), inet::BitsChunk::setBits(), inet::BytesChunk::setByte(), inet::BytesChunk::setBytes(), inet::SequenceChunk::setChunks(), inet::ByteCountChunk::setData(), inet::BitCountChunk::setData(), inet::BitCountChunk::setLength(), inet::ByteCountChunk::setLength(), inet::EncryptedChunk::setLength(), inet::SliceChunk::setLength(), and inet::SliceChunk::setOffset().
◆ has()
Returns whether if the designated part of the data is available in the requested representation.
652 if (length >=
b(0) &&
getChunkLength() < iterator.getPosition() + length)
656 return chunk !=
nullptr && chunk->isComplete();
◆ insertAt()
| void inet::Chunk::insertAt |
( |
const Ptr< const Chunk > & |
chunk, |
|
|
b |
offset |
|
) |
| |
|
inline |
Inserts the provided chunk into this chunk.
◆ insertAtBack()
| void inet::Chunk::insertAtBack |
( |
const Ptr< const Chunk > & |
chunk | ) |
|
|
inline |
◆ insertAtFront()
| void inet::Chunk::insertAtFront |
( |
const Ptr< const Chunk > & |
chunk | ) |
|
|
inline |
◆ isComplete()
| virtual bool inet::Chunk::isComplete |
( |
| ) |
const |
|
inlinevirtual |
◆ isCorrect()
| virtual bool inet::Chunk::isCorrect |
( |
| ) |
const |
|
inlinevirtual |
◆ isEmpty()
| virtual bool inet::Chunk::isEmpty |
( |
| ) |
const |
|
inlinevirtual |
◆ isImmutable()
| virtual bool inet::Chunk::isImmutable |
( |
| ) |
const |
|
inlinevirtual |
◆ isImproperlyRepresented()
| virtual bool inet::Chunk::isImproperlyRepresented |
( |
| ) |
const |
|
inlinevirtual |
◆ isIncomplete()
| virtual bool inet::Chunk::isIncomplete |
( |
| ) |
const |
|
inlinevirtual |
◆ isIncorrect()
| virtual bool inet::Chunk::isIncorrect |
( |
| ) |
const |
|
inlinevirtual |
◆ isMutable()
| virtual bool inet::Chunk::isMutable |
( |
| ) |
const |
|
inlinevirtual |
◆ isProperlyRepresented()
| virtual bool inet::Chunk::isProperlyRepresented |
( |
| ) |
const |
|
inlinevirtual |
◆ mapAllTags()
template<typename T >
| void inet::Chunk::mapAllTags |
( |
b |
offset, |
|
|
b |
length, |
|
|
std::function< void(b, b, const Ptr< const T > &)> |
f |
|
) |
| const |
|
inline |
Maps all tags in the provided range to to the function.
◆ mapAllTagsForUpdate()
template<typename T >
| void inet::Chunk::mapAllTagsForUpdate |
( |
b |
offset, |
|
|
b |
length, |
|
|
std::function< void(b, b, const Ptr< T > &)> |
f |
|
) |
| |
|
inline |
Maps all tags in the provided range to to the function.
◆ markImmutable()
| virtual void inet::Chunk::markImmutable |
( |
| ) |
|
|
inlinevirtual |
◆ markImproperlyRepresented()
| virtual void inet::Chunk::markImproperlyRepresented |
( |
| ) |
|
|
inlinevirtual |
◆ markIncomplete()
| virtual void inet::Chunk::markIncomplete |
( |
| ) |
|
|
inlinevirtual |
◆ markIncorrect()
| virtual void inet::Chunk::markIncorrect |
( |
| ) |
|
|
inlinevirtual |
◆ markMutableIfExclusivelyOwned()
| void inet::Chunk::markMutableIfExclusivelyOwned |
( |
| ) |
|
|
inline |
452 CHUNK_CHECK_USAGE(shared_from_this().use_count() == 2,
"chunk is not exclusively owned");
◆ moveIterator()
| void inet::Chunk::moveIterator |
( |
Iterator & |
iterator, |
|
|
b |
length |
|
) |
| const |
|
virtual |
Reimplemented in inet::SequenceChunk.
134 auto position = iterator.getPosition() + length;
135 iterator.setPosition(position);
136 iterator.setIndex(position ==
b(0) ? 0 : -1);
◆ parsimPack()
| void inet::Chunk::parsimPack |
( |
cCommBuffer * |
buffer | ) |
const |
|
overridevirtual |
Reimplemented in inet::SequenceChunk, inet::SliceChunk, inet::FieldsChunk, inet::BytesChunk, inet::BitCountChunk, inet::BitsChunk, inet::ByteCountChunk, inet::EncryptedChunk, and inet::cPacketChunk.
Referenced by inet::cPacketChunk::parsimPack(), inet::EncryptedChunk::parsimPack(), inet::BitCountChunk::parsimPack(), inet::BitsChunk::parsimPack(), inet::ByteCountChunk::parsimPack(), inet::BytesChunk::parsimPack(), inet::FieldsChunk::parsimPack(), inet::SliceChunk::parsimPack(), and inet::SequenceChunk::parsimPack().
◆ parsimUnpack()
| void inet::Chunk::parsimUnpack |
( |
cCommBuffer * |
buffer | ) |
|
|
overridevirtual |
Reimplemented in inet::SequenceChunk, inet::SliceChunk, inet::FieldsChunk, inet::BytesChunk, inet::BitCountChunk, inet::BitsChunk, inet::ByteCountChunk, inet::EncryptedChunk, and inet::cPacketChunk.
49 buffer->unpack(
flags);
Referenced by inet::cPacketChunk::parsimUnpack(), inet::EncryptedChunk::parsimUnpack(), inet::BitCountChunk::parsimUnpack(), inet::BitsChunk::parsimUnpack(), inet::ByteCountChunk::parsimUnpack(), inet::BytesChunk::parsimUnpack(), inet::FieldsChunk::parsimUnpack(), inet::SliceChunk::parsimUnpack(), and inet::SequenceChunk::parsimUnpack().
◆ peek() [1/2]
Returns the designated part of the data represented by this chunk in its default representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation. If the length is negative, then the result won't be longer than the absolute length. The result is mutable iff the designated part is directly represented in this chunk by a mutable chunk, otherwise the result is immutable.
148 return checkPeekResult<Chunk>(chunk,
flags);
◆ peek() [2/2]
Returns the designated part of the data represented by this chunk in the requested representation.
If the length is unspecified, then the length of the result is chosen according to the internal representation. If the length is negative, then the result won't be longer than the absolute length. The result is mutable iff the designated part is directly represented in this chunk by a mutable chunk, otherwise the result is immutable.
670 if (std::is_same<T, Chunk>::value)
675 return staticPtrCast<T>(
peek(iterator, length,
flags));
678 const auto& predicate = [] (
const Ptr<Chunk>& chunk) ->
bool {
return chunk ==
nullptr || dynamicPtrCast<T>(chunk); };
679 const auto& converter = [] (
const Ptr<Chunk>& chunk,
const Iterator& iterator,
b length,
int flags) ->
const Ptr<Chunk> {
return chunk->peekConverted<
T>(iterator, length,
flags); };
681 return checkPeekResult<T>(staticPtrCast<T>(chunk),
flags);
◆ peekConverted()
template<typename T >
| const Ptr<T> inet::Chunk::peekConverted |
( |
const Iterator & |
iterator, |
|
|
b |
length, |
|
|
int |
flags |
|
) |
| const |
|
inlineprotected |
400 CHUNK_CHECK_USAGE(iterator.isForward() || length >=
b(0),
"chunk conversion using backward iterator with undefined length is invalid");
401 auto offset = iterator.isForward() ? iterator.getPosition() :
getChunkLength() - iterator.getPosition() - length;
402 const auto& chunk = T::convertChunk(
typeid(
T),
const_cast<Chunk *
>(
this)->shared_from_this(), offset, length,
flags);
403 chunk->markImmutable();
404 return staticPtrCast<T>(chunk);
◆ peekUnchecked()
Implemented in inet::SequenceChunk, inet::SliceChunk, inet::FieldsChunk, inet::EncryptedChunk, inet::BitCountChunk, inet::BitsChunk, inet::ByteCountChunk, inet::BytesChunk, inet::cPacketChunk, inet::EmptyChunk, and inet::PacketDissector::ProtocolDataUnit.
Referenced by peek().
◆ printFieldsToStream()
| std::ostream & inet::Chunk::printFieldsToStream |
( |
std::ostream & |
stream, |
|
|
int |
level, |
|
|
int |
evFlags = 0 |
|
) |
| const |
|
virtual |
Prints an optinally formatted human readable string representation of the feilds of this chunk to the given stream.
Reimplemented in inet::SliceChunk, inet::BytesChunk, inet::EncryptedChunk, inet::BitsChunk, inet::BitCountChunk, inet::ByteCountChunk, inet::FieldsChunk, inet::cPacketChunk, and inet::EmptyChunk.
Referenced by inet::ByteCountChunk::printFieldsToStream(), printToStream(), and str().
◆ printToStream()
| std::ostream & inet::Chunk::printToStream |
( |
std::ostream & |
stream, |
|
|
int |
level, |
|
|
int |
evFlags = 0 |
|
) |
| const |
|
overridevirtual |
Prints an optinally formatted human readable string representation of the data present in this chunk to the given stream.
Reimplemented from inet::IPrintableObject.
Reimplemented in inet::SequenceChunk.
153 std::string className = getClassName();
154 auto index = className.rfind(
"::");
155 if (index != std::string::npos)
156 className = className.substr(index + 2);
◆ removeAt()
| void inet::Chunk::removeAt |
( |
b |
offset, |
|
|
b |
length |
|
) |
| |
|
inline |
Removes the requested part from this chunk.
587 CHUNK_CHECK_USAGE(
b(0) <= offset && offset + length <= chunkLength,
"offset is invalid");
◆ removeAtBack()
| void inet::Chunk::removeAtBack |
( |
b |
length | ) |
|
|
inline |
Removes the requested part from the end of this chunk.
◆ removeAtFront()
| void inet::Chunk::removeAtFront |
( |
b |
length | ) |
|
|
inline |
Removes the requested part from the beginning of this chunk.
◆ removeTag()
template<typename T >
| const Ptr<T> inet::Chunk::removeTag |
( |
b |
offset, |
|
|
b |
length |
|
) |
| |
|
inline |
Removes the chunk tag for the provided type and range, or throws an exception if no such chunk tag is found.
◆ removeTagIfPresent()
template<typename T >
| const Ptr<T> inet::Chunk::removeTagIfPresent |
( |
b |
offset, |
|
|
b |
length |
|
) |
| |
|
inline |
Removes the chunk tag for the provided type and range if present, or returns nullptr if no such chunk tag is found.
◆ removeTagsWherePresent()
Removes and returns all chunk tags for the provided type and range.
◆ seekIterator()
| void inet::Chunk::seekIterator |
( |
Iterator & |
iterator, |
|
|
b |
position |
|
) |
| const |
|
virtual |
Reimplemented in inet::SequenceChunk.
141 iterator.setPosition(position);
142 iterator.setIndex(position ==
b(0) ? 0 : -1);
◆ serialize()
Serializes a chunk into the given stream.
The bytes representing the chunk is written at the current position of the stream up to its length. The offset parameter and the offset + length value must be in the range [0, chunkLength]. If the length parameter is -1, then the chunk will be serialized up to its end.
179 const Chunk *chunkPointer = chunk.get();
181 #if CHUNK_CHECK_IMPLEMENTATION_ENABLED
182 auto startPosition = stream.getLength();
184 serializer->
serialize(stream, chunk, offset, length);
185 #if CHUNK_CHECK_IMPLEMENTATION_ENABLED
186 auto endPosition = stream.getLength();
187 auto expectedChunkLength = length ==
b(-1) ? chunk->getChunkLength() - offset : length;
Referenced by inet::tcp::Tcp::checkCrc(), inet::tcp::TcpCrcInsertionHook::computeCrc(), inet::Pim::computeCrc(), inet::Udp::computeCrc(), inet::BytesChunk::convertChunk(), inet::BitsChunk::convertChunk(), convertChunk(), inet::Ipv4Encap::encapsulate(), getBinDumpLine(), getHexDumpLine(), inet::sctp::SctpCrcInsertion::insertCrc(), inet::Icmp::insertCrc(), inet::Icmpv6::insertCrc(), inet::Ipv4::insertCrc(), inet::Igmpv2::insertCrc(), inet::Igmpv3::insertCrc(), inet::SequenceChunkSerializer::serialize(), inet::SliceChunkSerializer::serialize(), inet::Ipv4::setComputedCrc(), inet::ospfv2::setOspfCrc(), and inet::Ipv4::verifyCrc().
◆ simplify()
| const Ptr<Chunk> inet::Chunk::simplify |
( |
| ) |
const |
|
inline |
Returns the simplified representation of this chunk eliminating all potential redundancies.
This function may return a nullptr for emptry chunks.
◆ str()
| std::string inet::Chunk::str |
( |
| ) |
const |
|
overridevirtual |
◆ ChunkDescriptor
| friend class ChunkDescriptor |
|
friend |
◆ EncryptedChunk
◆ SequenceChunk
◆ SliceChunk
◆ enableImplicitChunkSerialization
| bool inet::Chunk::enableImplicitChunkSerialization = false |
|
static |
Peeking some part into a chunk that requires automatic serialization will throw an exception when implicit chunk serialization is disabled.
Referenced by convertChunk().
◆ flags
The boolean chunk flags are merged into a single integer.
Referenced by inet::FieldsChunk::containsSameData(), convertChunk(), parsimPack(), parsimUnpack(), peek(), inet::EmptyChunk::peekUnchecked(), inet::cPacketChunk::peekUnchecked(), inet::BytesChunk::peekUnchecked(), inet::BitCountChunk::peekUnchecked(), inet::BitsChunk::peekUnchecked(), inet::ByteCountChunk::peekUnchecked(), inet::EncryptedChunk::peekUnchecked(), inet::FieldsChunk::peekUnchecked(), inet::SliceChunk::peekUnchecked(), and inet::SequenceChunk::peekUnchecked().
◆ id
The id is automatically assigned sequentially during construction.
◆ nextId
| int inet::Chunk::nextId = 0 |
|
static |
◆ PeekConverter
◆ regionTags
◆ unspecifiedLength
| const b inet::Chunk::unspecifiedLength = b(-std::numeric_limits<int64_t>::max()) |
|
static |
The documentation for this class was generated from the following files:
@ PF_ALLOW_NULLPTR
Definition: Chunk.h:278
virtual const Ptr< Chunk > peekUnchecked(PeekPredicate predicate, PeekConverter converter, const Iterator &iterator, b length, int flags) const =0
compose< Wb, pow< m, -2 > > T
Definition: Units.h:951
void mapAllTags(b offset, b length, std::function< void(b, b, const Ptr< const TagBase > &)> f) const
Definition: SharingRegionTagSet.cc:110
std::vector< SharingRegionTagSet::RegionTag< TagBase > > addTagsWhereAbsent(const std::type_info &typeInfo, b offset, b length, const Ptr< const TagBase > &tag)
Definition: SharingRegionTagSet.cc:63
#define CHUNK_CHECK_IMPLEMENTATION(condition)
Definition: Chunk.h:29
std::vector< RegionTag< T > > getAllTags(b offset, b length) const
Returns all the shared tags of the provided type and range.
Definition: SharingRegionTagSet.h:470
virtual void doRemoveAtFront(b length)
Definition: Chunk.h:380
Chunk()
Definition: Chunk.cc:18
@ PRINT_LEVEL_DETAIL
Definition: IPrintableObject.h:24
virtual b getChunkLength() const =0
Returns the length of data represented by this chunk.
virtual bool canInsertAtBack(const Ptr< const Chunk > &chunk) const
Returns true if this chunk is capable of representing the result.
Definition: Chunk.h:497
void copyTags(const SharingRegionTagSet &source, b sourceOffset, b offset, b length)
Copies the set of tags from the source region to the provided region.
Definition: SharingRegionTagSet.cc:219
int getNumTags() const
Returns the number of tags.
Definition: SharingRegionTagSet.h:300
virtual void doRemoveAtBack(b length)
Definition: Chunk.h:381
#define EV_FAINT
Definition: INETDefs.h:104
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
const Ptr< TagBase > removeTag(int index)
Definition: SharingRegionTagSet.cc:100
const value< double, units::C > e(1.602176487e-19)
static void serialize(MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset=b(0), b length=b(-1))
Serializes a chunk into the given stream.
Definition: Chunk.cc:175
@ CT_ENCRYPTED
Definition: Chunk.h:268
virtual bool canRemoveAtBack(b length) const
Returns true if this chunk is capable of representing the result.
Definition: Chunk.h:550
static bool enableImplicitChunkSerialization
Peeking some part into a chunk that requires automatic serialization will throw an exception when imp...
Definition: Chunk.h:340
@ PF_ALLOW_IMPROPERLY_REPRESENTED
Definition: Chunk.h:282
virtual void handleChange()
Definition: Chunk.cc:53
virtual void doInsertAtBack(const Ptr< const Chunk > &chunk)
Definition: Chunk.h:378
const Ptr< const T > findTag(b offset, b length) const
Returns the shared tag of the provided type and range, or returns nullptr if no such tag is found.
Definition: SharingRegionTagSet.h:354
virtual void doInsertAtFront(const Ptr< const Chunk > &chunk)
Definition: Chunk.h:377
const Ptr< T > addTagIfAbsent(b offset, b length)
Returns a newly added exclusively owned tag of the provided type and range if absent,...
Definition: SharingRegionTagSet.h:402
virtual std::ostream & printFieldsToStream(std::ostream &stream, int level, int evFlags=0) const
Prints an optinally formatted human readable string representation of the feilds of this chunk to the...
Definition: Chunk.cc:161
@ CT_EMPTY
Definition: Chunk.h:262
@ PRINT_LEVEL_COMPLETE
Definition: IPrintableObject.h:26
void mapAllTagsForUpdate(b offset, b length, std::function< void(b, b, const Ptr< TagBase > &)> f)
Definition: SharingRegionTagSet.cc:137
int id
The id is automatically assigned sequentially during construction.
Definition: Chunk.h:348
@ PF_ALLOW_SERIALIZATION
Definition: Chunk.h:283
const Ptr< const TagBase > & getTag(int index) const
Returns the shared tag at the given index.
Definition: SharingRegionTagSet.h:310
static const Ptr< Chunk > deserialize(MemoryInputStream &stream, const std::type_info &typeInfo)
Deserializes a chunk from the given stream.
Definition: Chunk.cc:192
intscale< b, 1, 8 > B
Definition: Units.h:1168
virtual void doInsertAt(const Ptr< const Chunk > &chunk, b offset)
Definition: Chunk.h:379
@ PF_ALLOW_INCOMPLETE
Definition: Chunk.h:280
SharingRegionTagSet regionTags
The set of region tags attached to the data represented by this chunk.
Definition: Chunk.h:356
virtual bool canInsertAtFront(const Ptr< const Chunk > &chunk) const
Returns true if this chunk is capable of representing the result.
Definition: Chunk.h:492
#define CHUNK_CHECK_USAGE(condition, format,...)
Definition: Chunk.h:42
#define EV_FIELD(...)
Definition: INETDefs.h:112
void moveTags(b shift)
Moves all tags with the provided shift.
Definition: SharingRegionTagSet.cc:230
@ PF_ALLOW_EMPTY
Definition: Chunk.h:279
@ CT_BITCOUNT
Definition: Chunk.h:263
virtual bool isMutable() const
Definition: Chunk.h:447
virtual bool canRemoveAtFront(b length) const
Returns true if this chunk is capable of representing the result.
Definition: Chunk.h:545
@ CT_BYTES
Definition: Chunk.h:266
virtual ChunkType getChunkType() const =0
Returns the type of this chunk as an enum member.
@ CT_BITS
Definition: Chunk.h:264
@ CT_BYTECOUNT
Definition: Chunk.h:265
const Ptr< Chunk > peek(const Iterator &iterator, b length=unspecifiedLength, int flags=0) const
Returns the designated part of the data represented by this chunk in its default representation.
Definition: Chunk.cc:145
value< int64_t, units::b > b
Definition: Units.h:1241
@ PF_ALLOW_INCORRECT
Definition: Chunk.h:281
void addTag(b offset, b length, const Ptr< const TagBase > &tag)
Definition: SharingRegionTagSet.cc:56
#define EV_NORMAL
Definition: INETDefs.h:102
@ CF_INCOMPLETE
Definition: Chunk.h:252
int evFlags
Definition: INETDefs.cc:12
int flags
The boolean chunk flags are merged into a single integer.
Definition: Chunk.h:352
virtual void parsimUnpack(cCommBuffer *buffer) override
Definition: SharingRegionTagSet.cc:40
@ CF_IMMUTABLE
Definition: Chunk.h:251
static int nextId
Definition: Chunk.h:342
const ChunkSerializer * getSerializer(const std::type_info &typeInfo) const
Definition: ChunkSerializerRegistry.cc:26
@ CT_SEQUENCE
Definition: Chunk.h:270
const RegionTag< TagBase > & getRegionTag(int index) const
Returns the shared region tag at the given index.
Definition: SharingRegionTagSet.h:320
void clearTags(b offset, b length)
Clears the set of tags in the given region.
Definition: SharingRegionTagSet.cc:166
@ CF_IMPROPERLY_REPRESENTED
Definition: Chunk.h:254
std::vector< RegionTag< T > > removeTagsWherePresent(b offset, b length)
Removes and returns all tags of the provided type and range and returns them for update.
Definition: SharingRegionTagSet.h:492
virtual void serialize(MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset, b length) const =0
Serializes a chunk into a stream by writing the bytes representing the chunk at the end of the stream...
@ PF_ALLOW_ALL
Definition: Chunk.h:284
@ CT_CPACKET
Definition: Chunk.h:269
const Ptr< T > removeTagIfPresent(b offset, b length)
Removes the tag of the provided type and range if present and returns it for update,...
Definition: SharingRegionTagSet.h:438
static ChunkSerializerRegistry globalRegistry
Definition: ChunkSerializerRegistry.h:20
virtual bool canRemoveAt(b offset, b length) const
Returns true if this chunk is capable of representing the result.
Definition: Chunk.h:555
@ CF_INCORRECT
Definition: Chunk.h:253
@ CT_FIELDS
Definition: Chunk.h:271
std::vector< RegionTag< T > > getAllTagsForUpdate(b offset, b length)
Returns all the exclusively owned tags of the provided type and range for update.
Definition: SharingRegionTagSet.h:481
virtual void doRemoveAt(b offset, b length)
Definition: Chunk.h:382
void checkMutable() const
Definition: Chunk.h:370
virtual void parsimPack(cCommBuffer *buffer) const override
Definition: SharingRegionTagSet.cc:28
@ CT_SLICE
Definition: Chunk.h:267