INET Framework for OMNeT++/OMNEST
inet::SliceChunk Class Reference

This class represents data using a slice of another chunk. More...

#include <SliceChunk.h>

Inheritance diagram for inet::SliceChunk:
inet::Chunk inet::IPrintableObject inet::IRegionTaggedObject

Public Member Functions

Constructors, destructors and duplication related functions
 SliceChunk ()
 
 SliceChunk (const SliceChunk &other)=default
 
 SliceChunk (const Ptr< Chunk > &chunk, b offset, b length)
 
virtual SliceChunkdup () const override
 
virtual const Ptr< ChunkdupShared () const override
 Returns a mutable copy of this chunk in a shared pointer. More...
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
virtual void forEachChild (cVisitor *v) override
 
Field accessor functions
const Ptr< Chunk > & getChunk () const
 
void setChunk (const Ptr< Chunk > &chunk)
 
b getOffset () const
 
void setOffset (b offset)
 
b getLength () const
 
void setLength (b length)
 
Overridden flag functions
virtual bool isMutable () const override
 
virtual bool isImmutable () const override
 
virtual bool isComplete () const override
 
virtual bool isIncomplete () const override
 
virtual bool isCorrect () const override
 
virtual bool isIncorrect () const override
 
virtual bool isProperlyRepresented () const override
 
virtual bool isImproperlyRepresented () const override
 
Overridden chunk functions
virtual ChunkType getChunkType () const override
 Returns the type of this chunk as an enum member. More...
 
virtual b getChunkLength () const override
 Returns the length of data represented by this chunk. More...
 
virtual bool containsSameData (const Chunk &other) const override
 Returns true if the two chunks represent the same binary data. More...
 
virtual bool canInsertAtFront (const Ptr< const Chunk > &chunk) const override
 Returns true if this chunk is capable of representing the result. More...
 
virtual bool canInsertAtBack (const Ptr< const Chunk > &chunk) const override
 Returns true if this chunk is capable of representing the result. More...
 
virtual bool canRemoveAtFront (b length) const override
 Returns true if this chunk is capable of representing the result. More...
 
virtual bool canRemoveAtBack (b length) const override
 Returns true if this chunk is capable of representing the result. More...
 
virtual std::ostream & printFieldsToStream (std::ostream &stream, int level, int evFlags=0) const override
 Prints an optinally formatted human readable string representation of the feilds of this chunk to the given stream. More...
 
- Public Member Functions inherited from inet::Chunk
 Chunk ()
 
 Chunk (const Chunk &other)
 
virtual void markImmutable ()
 
void markMutableIfExclusivelyOwned ()
 
virtual void markIncomplete ()
 
virtual void markIncorrect ()
 
virtual void markImproperlyRepresented ()
 
virtual void moveIterator (Iterator &iterator, b length) const
 
virtual void seekIterator (Iterator &iterator, b position) const
 
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 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 bool isEmpty () const
 Returns true if this chunk contains no data. More...
 
const Ptr< Chunksimplify () const
 Returns the simplified representation of this chunk eliminating all potential redundancies. More...
 
const Ptr< Chunkpeek (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< Tpeek (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 SharingRegionTagSetgetRegionTags () override
 Returns all region tags. More...
 
int getNumTags () const
 Returns the number of chunk tags. More...
 
const Ptr< const TagBasegetTag (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 TfindTag (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 TgetTag (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< TaddTag (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< TaddTagIfAbsent (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< TremoveTag (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< TremoveTagIfPresent (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::string str () const override
 Returns a human readable string representation of the data present in this chunk. More...
 
- Public Member Functions inherited from inet::IPrintableObject
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
 

Protected Member Functions

Chunk_getChunk () const
 
virtual const Ptr< ChunkpeekUnchecked (PeekPredicate predicate, PeekConverter converter, const Iterator &iterator, b length, int flags) const override
 
virtual void doInsertAtFront (const Ptr< const Chunk > &chunk) override
 
virtual void doInsertAtBack (const Ptr< const Chunk > &chunk) override
 
virtual void doRemoveAtFront (b length) override
 
virtual void doRemoveAtBack (b length) override
 
- Protected Member Functions inherited from inet::Chunk
int getBinDumpNumLines () const
 
int getHexDumpNumLines () const
 
const char * getBinDumpLine (int index)
 
const char * getHexDumpLine (int index)
 
const SharingRegionTagSet::RegionTag< TagBase > & _getTag (int index) const
 
void checkMutable () const
 
virtual void handleChange ()
 
virtual void doInsertAt (const Ptr< const Chunk > &chunk, b offset)
 
virtual void doRemoveAt (b offset, b length)
 
template<typename T >
const Ptr< TpeekConverted (const Iterator &iterator, b length, int flags) const
 
template<typename T >
const Ptr< TcheckPeekResult (const Ptr< T > &chunk, int flags) const
 

Static Protected Member Functions

static const Ptr< ChunkconvertChunk (const std::type_info &typeInfo, const Ptr< Chunk > &chunk, b offset, b length, int flags)
 
- Static Protected Member Functions inherited from inet::Chunk
static const Ptr< ChunkconvertChunk (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...
 

Protected Attributes

Ptr< Chunkchunk
 The chunk of which this chunk is a slice, or nullptr if not yet specified. More...
 
b offset
 The offset measured in bits, or -1 if not yet specified. More...
 
b length
 The length measured in bits, or -1 if not yet specified. More...
 
- Protected Attributes inherited from inet::Chunk
int id
 The id is automatically assigned sequentially during construction. More...
 
int flags
 The boolean chunk flags are merged into a single integer. More...
 
SharingRegionTagSet regionTags
 The set of region tags attached to the data represented by this chunk. More...
 
const typedef Ptr< Chunk >(* PeekConverter )(const Ptr< Chunk > &chunk, const Chunk::Iterator &iterator, b length, int flags)
 

Friends

class Chunk
 
class SliceChunkDescriptor
 

Additional Inherited Members

- Public Types inherited from inet::Chunk
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...
 
- Public Types inherited from inet::IPrintableObject
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) }
 
- Static Public Member Functions inherited from inet::Chunk
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. More...
 
static const Ptr< Chunkdeserialize (MemoryInputStream &stream, const std::type_info &typeInfo)
 Deserializes a chunk from the given stream. More...
 
- Static Public Attributes inherited from inet::Chunk
static const b unspecifiedLength = b(-std::numeric_limits<int64_t>::max())
 
static bool enableImplicitChunkSerialization = false
 Peeking some part into a chunk that requires automatic serialization will throw an exception when implicit chunk serialization is disabled. More...
 
static int nextId = 0
 
- Protected Types inherited from inet::Chunk
enum  ChunkFlag { CF_IMMUTABLE = (1 << 0), CF_INCOMPLETE = (1 << 1), CF_INCORRECT = (1 << 2), CF_IMPROPERLY_REPRESENTED = (1 << 3) }
 This enum specifies bitmasks for the flags field of Chunk. More...
 
typedef bool(* PeekPredicate) (const Ptr< Chunk > &)
 

Detailed Description

This class represents data using a slice of another chunk.

The slice is designated with the sliced chunk, an offset, and a length field, both measured in bits. It's used by the Chunk API implementation internally to efficiently represent slices of other chunks. User code should not directly instantiate this class.

Constructor & Destructor Documentation

◆ SliceChunk() [1/3]

inet::SliceChunk::SliceChunk ( )
15  :
16  Chunk(),
17  chunk(nullptr),
18  offset(-1),
19  length(-1)
20 {
21 }

◆ SliceChunk() [2/3]

inet::SliceChunk::SliceChunk ( const SliceChunk other)
default

◆ SliceChunk() [3/3]

inet::SliceChunk::SliceChunk ( const Ptr< Chunk > &  chunk,
b  offset,
b  length 
)
23  :
24  Chunk(),
25  chunk(chunk),
26  offset(offset),
27  length(length < b(0) ? std::min(-length, chunk->getChunkLength() - offset) : length)
28 {
29  CHUNK_CHECK_USAGE(chunk->isImmutable(), "chunk is mutable");
30 #if CHUNK_CHECK_IMPLEMENTATION_ENABLED
31  b chunkLength = chunk->getChunkLength();
32  CHUNK_CHECK_IMPLEMENTATION(b(0) <= this->offset && this->offset <= chunkLength);
33  CHUNK_CHECK_IMPLEMENTATION(b(0) <= this->length && this->offset + this->length <= chunkLength);
34 #endif
35  regionTags.copyTags(chunk->regionTags, offset, b(0), length);
36 }

Member Function Documentation

◆ _getChunk()

Chunk* inet::SliceChunk::_getChunk ( ) const
inlineprotected
42 { return chunk.get(); } // only for class descriptor

◆ canInsertAtBack()

bool inet::SliceChunk::canInsertAtBack ( const Ptr< const Chunk > &  chunk) const
overridevirtual

Returns true if this chunk is capable of representing the result.

Reimplemented from inet::Chunk.

136 {
137  if (chunk->getChunkType() == CT_SLICE) {
138  const auto& otherSliceChunk = staticPtrCast<const SliceChunk>(chunk);
139  return this->chunk == otherSliceChunk->chunk && offset + length == otherSliceChunk->offset;
140  }
141  else
142  return false;
143 }

◆ canInsertAtFront()

bool inet::SliceChunk::canInsertAtFront ( const Ptr< const Chunk > &  chunk) const
overridevirtual

Returns true if this chunk is capable of representing the result.

Reimplemented from inet::Chunk.

126 {
127  if (chunk->getChunkType() == CT_SLICE) {
128  const auto& otherSliceChunk = staticPtrCast<const SliceChunk>(chunk);
129  return this->chunk == otherSliceChunk->chunk && offset == otherSliceChunk->offset + otherSliceChunk->length;
130  }
131  else
132  return false;
133 }

◆ canRemoveAtBack()

virtual bool inet::SliceChunk::canRemoveAtBack ( b  length) const
inlineoverridevirtual

Returns true if this chunk is capable of representing the result.

Reimplemented from inet::Chunk.

108 { return false; }

◆ canRemoveAtFront()

virtual bool inet::SliceChunk::canRemoveAtFront ( b  length) const
inlineoverridevirtual

Returns true if this chunk is capable of representing the result.

Reimplemented from inet::Chunk.

107 { return false; }

◆ containsSameData()

bool inet::SliceChunk::containsSameData ( const Chunk other) const
overridevirtual

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 from inet::Chunk.

65 {
66  if (&other == this)
67  return true;
68  else if (!Chunk::containsSameData(other))
69  return false;
70  else {
71  auto otherSlice = static_cast<const SliceChunk *>(&other);
72  return offset == otherSlice->offset && chunk->containsSameData(*otherSlice->chunk.get());
73  }
74 }

◆ convertChunk()

const Ptr< Chunk > inet::SliceChunk::convertChunk ( const std::type_info &  typeInfo,
const Ptr< Chunk > &  chunk,
b  offset,
b  length,
int  flags 
)
staticprotected
102 {
103  b chunkLength = chunk->getChunkLength();
104  CHUNK_CHECK_IMPLEMENTATION(b(0) <= offset && offset <= chunkLength);
105  CHUNK_CHECK_IMPLEMENTATION(length <= chunkLength - offset);
106  b sliceLength = length < b(0) ? std::min(-length, chunkLength) - offset : length;
107  CHUNK_CHECK_IMPLEMENTATION(b(0) <= sliceLength && sliceLength <= chunkLength);
108  return makeShared<SliceChunk>(chunk, offset, sliceLength);
109 }

◆ doInsertAtBack()

void inet::SliceChunk::doInsertAtBack ( const Ptr< const Chunk > &  chunk)
overrideprotectedvirtual

Reimplemented from inet::Chunk.

154 {
155  const auto& otherSliceChunk = staticPtrCast<const SliceChunk>(chunk);
156  CHUNK_CHECK_IMPLEMENTATION(this->chunk == otherSliceChunk->chunk && offset + length == otherSliceChunk->offset);
157  length += otherSliceChunk->length;
158 }

◆ doInsertAtFront()

void inet::SliceChunk::doInsertAtFront ( const Ptr< const Chunk > &  chunk)
overrideprotectedvirtual

Reimplemented from inet::Chunk.

146 {
147  const auto& otherSliceChunk = staticPtrCast<const SliceChunk>(chunk);
148  CHUNK_CHECK_IMPLEMENTATION(this->chunk == otherSliceChunk->chunk && offset == otherSliceChunk->offset + otherSliceChunk->length);
149  offset -= otherSliceChunk->length;
150  length += otherSliceChunk->length;
151 }

◆ doRemoveAtBack()

void inet::SliceChunk::doRemoveAtBack ( b  length)
overrideprotectedvirtual

Reimplemented from inet::Chunk.

167 {
168  this->length -= length;
169 }

◆ doRemoveAtFront()

void inet::SliceChunk::doRemoveAtFront ( b  length)
overrideprotectedvirtual

Reimplemented from inet::Chunk.

161 {
162  this->offset += length;
163  this->length -= length;
164 }

◆ dup()

virtual SliceChunk* inet::SliceChunk::dup ( ) const
inlineoverridevirtual
61 { return new SliceChunk(*this); }

◆ dupShared()

virtual const Ptr<Chunk> inet::SliceChunk::dupShared ( ) const
inlineoverridevirtual

Returns a mutable copy of this chunk in a shared pointer.

Reimplemented from inet::Chunk.

62 { return makeShared<SliceChunk>(*this); }

◆ forEachChild()

void inet::SliceChunk::forEachChild ( cVisitor *  v)
overridevirtual

Reimplemented from inet::Chunk.

59 {
61  v->visit(const_cast<Chunk *>(chunk.get()));
62 }

◆ getChunk()

const Ptr<Chunk>& inet::SliceChunk::getChunk ( ) const
inline
72 { return chunk; }

◆ getChunkLength()

virtual b inet::SliceChunk::getChunkLength ( ) const
inlineoverridevirtual

Returns the length of data represented by this chunk.

Implements inet::Chunk.

100 { CHUNK_CHECK_IMPLEMENTATION(length >= b(0)); return length; }

Referenced by peekUnchecked(), setLength(), and setOffset().

◆ getChunkType()

virtual ChunkType inet::SliceChunk::getChunkType ( ) const
inlineoverridevirtual

Returns the type of this chunk as an enum member.

This can be used to avoid expensive std::dynamic_cast and dynamicPtrCast operators.

Implements inet::Chunk.

99 { return CT_SLICE; }

◆ getLength()

b inet::SliceChunk::getLength ( ) const
inline
78 { return length; }

◆ getOffset()

b inet::SliceChunk::getOffset ( ) const
inline
75 { return offset; }

◆ isComplete()

virtual bool inet::SliceChunk::isComplete ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

87 { return Chunk::isComplete() && chunk->isComplete(); }

◆ isCorrect()

virtual bool inet::SliceChunk::isCorrect ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

90 { return Chunk::isCorrect() && chunk->isCorrect(); }

◆ isImmutable()

virtual bool inet::SliceChunk::isImmutable ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

85 { return Chunk::isImmutable() && chunk->isImmutable(); }

◆ isImproperlyRepresented()

virtual bool inet::SliceChunk::isImproperlyRepresented ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

94 { return Chunk::isImproperlyRepresented() || chunk->isImproperlyRepresented(); }

◆ isIncomplete()

virtual bool inet::SliceChunk::isIncomplete ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

88 { return Chunk::isIncomplete() || chunk->isIncomplete(); }

◆ isIncorrect()

virtual bool inet::SliceChunk::isIncorrect ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

91 { return Chunk::isIncorrect() || chunk->isIncorrect(); }

◆ isMutable()

virtual bool inet::SliceChunk::isMutable ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

84 { return Chunk::isMutable() || chunk->isMutable(); }

◆ isProperlyRepresented()

virtual bool inet::SliceChunk::isProperlyRepresented ( ) const
inlineoverridevirtual

Reimplemented from inet::Chunk.

93 { return Chunk::isProperlyRepresented() && chunk->isProperlyRepresented(); }

◆ parsimPack()

void inet::SliceChunk::parsimPack ( cCommBuffer *  buffer) const
overridevirtual

Reimplemented from inet::Chunk.

39 {
40  Chunk::parsimPack(buffer);
41  buffer->packObject(chunk.get());
42  buffer->pack(b(offset).get());
43  buffer->pack(b(length).get());
44 }

◆ parsimUnpack()

void inet::SliceChunk::parsimUnpack ( cCommBuffer *  buffer)
overridevirtual

Reimplemented from inet::Chunk.

47 {
48  Chunk::parsimUnpack(buffer);
49  chunk = check_and_cast<Chunk *>(buffer->unpackObject())->shared_from_this();
50  uint64_t o;
51  buffer->unpack(o);
52  offset = b(o);
53  uint64_t l;
54  buffer->unpack(l);
55  length = b(l);
56 }

◆ peekUnchecked()

const Ptr< Chunk > inet::SliceChunk::peekUnchecked ( PeekPredicate  predicate,
PeekConverter  converter,
const Iterator iterator,
b  length,
int  flags 
) const
overrideprotectedvirtual

Implements inet::Chunk.

77 {
78  b chunkLength = getChunkLength();
79  CHUNK_CHECK_USAGE(b(0) <= iterator.getPosition() && iterator.getPosition() <= chunkLength, "iterator is out of range");
80  // 1. peeking an empty part returns nullptr
81  if (length == b(0) || (iterator.getPosition() == chunkLength && length < b(0))) {
82  if (predicate == nullptr || predicate(nullptr))
84  }
85  // 2. peeking the whole part
86  if (iterator.getPosition() == b(0) && (-length >= chunkLength || length == chunkLength)) {
87  // 2.1 peeking the whole part returns the sliced chunk
88  if (offset == b(0) && chunkLength == chunk->getChunkLength()) {
89  if (predicate == nullptr || predicate(chunk))
90  return chunk;
91  }
92  // 2.2 peeking the whole part returns this chunk
93  auto result = const_cast<SliceChunk *>(this)->shared_from_this();
94  if (predicate == nullptr || predicate(result))
95  return result;
96  }
97  // 3. peeking anything else returns what peeking the sliced chunk returns
98  return chunk->peekUnchecked(predicate, converter, ForwardIterator(iterator.getPosition() + offset, -1), length < b(0) ? -std::min(-length, chunkLength - offset) : length, flags);
99 }

◆ printFieldsToStream()

std::ostream & inet::SliceChunk::printFieldsToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
overridevirtual

Prints an optinally formatted human readable string representation of the feilds of this chunk to the given stream.

Reimplemented from inet::Chunk.

172 {
173  if (level <= PRINT_LEVEL_DETAIL) {
174  stream << EV_FIELD(offset);
175  stream << EV_FIELD(chunk, printFieldToString(chunk.get(), level + 1, evFlags));
176  }
177  return stream;
178 }

◆ setChunk()

void inet::SliceChunk::setChunk ( const Ptr< Chunk > &  chunk)
inline
73 { CHUNK_CHECK_USAGE(chunk->isImmutable(), "chunk is mutable"); this->chunk = chunk; }

◆ setLength()

void inet::SliceChunk::setLength ( b  length)
119 {
120  CHUNK_CHECK_USAGE(b(0) <= length && length <= chunk->getChunkLength(), "length is invalid");
121  handleChange();
122  this->length = length;
123 }

◆ setOffset()

void inet::SliceChunk::setOffset ( b  offset)
112 {
113  CHUNK_CHECK_USAGE(b(0) <= offset && offset <= chunk->getChunkLength(), "offset is out of range");
114  handleChange();
115  this->offset = offset;
116 }

Friends And Related Function Documentation

◆ Chunk

friend class Chunk
friend

◆ SliceChunkDescriptor

friend class SliceChunkDescriptor
friend

Member Data Documentation

◆ chunk

Ptr<Chunk> inet::SliceChunk::chunk
protected

The chunk of which this chunk is a slice, or nullptr if not yet specified.

Referenced by peekUnchecked().

◆ length

b inet::SliceChunk::length
protected

◆ offset

b inet::SliceChunk::offset
protected

The documentation for this class was generated from the following files:
CHUNK_CHECK_IMPLEMENTATION
#define CHUNK_CHECK_IMPLEMENTATION(condition)
Definition: Chunk.h:29
inet::Chunk::forEachChild
virtual void forEachChild(cVisitor *v) override
Definition: Chunk.cc:33
inet::IPrintableObject::PRINT_LEVEL_DETAIL
@ PRINT_LEVEL_DETAIL
Definition: IPrintableObject.h:24
inet::SharingRegionTagSet::copyTags
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
inet::Chunk::isIncorrect
virtual bool isIncorrect() const
Definition: Chunk.h:469
inet::Chunk::isCorrect
virtual bool isCorrect() const
Definition: Chunk.h:468
inet::SliceChunk::offset
b offset
The offset measured in bits, or -1 if not yet specified.
Definition: SliceChunk.h:35
inet::Chunk::containsSameData
virtual bool containsSameData(const Chunk &other) const
Returns true if the two chunks represent the same binary data.
Definition: Chunk.h:619
inet::sctp::min
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
inet::SliceChunk::SliceChunk
SliceChunk()
Definition: SliceChunk.cc:15
inet::Chunk::isIncomplete
virtual bool isIncomplete() const
Definition: Chunk.h:461
inet::Chunk::handleChange
virtual void handleChange()
Definition: Chunk.cc:53
inet::printFieldToString
std::string printFieldToString(const IPrintableObject *object, int level, int evFlags=0)
Definition: IPrintableObject.h:98
inet::Chunk::isProperlyRepresented
virtual bool isProperlyRepresented() const
Definition: Chunk.h:476
inet::Chunk::regionTags
SharingRegionTagSet regionTags
The set of region tags attached to the data represented by this chunk.
Definition: Chunk.h:356
CHUNK_CHECK_USAGE
#define CHUNK_CHECK_USAGE(condition, format,...)
Definition: Chunk.h:42
inet::SliceChunk::getChunkLength
virtual b getChunkLength() const override
Returns the length of data represented by this chunk.
Definition: SliceChunk.h:100
inet::Chunk::isImmutable
virtual bool isImmutable() const
Definition: Chunk.h:448
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::Chunk::isMutable
virtual bool isMutable() const
Definition: Chunk.h:447
inet::Chunk::parsimPack
virtual void parsimPack(cCommBuffer *buffer) const override
Definition: Chunk.cc:39
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::evFlags
int evFlags
Definition: INETDefs.cc:12
inet::Chunk::flags
int flags
The boolean chunk flags are merged into a single integer.
Definition: Chunk.h:352
inet::SliceChunk::length
b length
The length measured in bits, or -1 if not yet specified.
Definition: SliceChunk.h:39
inet::Chunk::isComplete
virtual bool isComplete() const
Definition: Chunk.h:460
inet::EmptyChunk::getEmptyChunk
static const Ptr< Chunk > getEmptyChunk(int flags)
Definition: EmptyChunk.h:48
inet::SliceChunk::Chunk
friend class Chunk
Definition: SliceChunk.h:24
inet::Chunk::parsimUnpack
virtual void parsimUnpack(cCommBuffer *buffer) override
Definition: Chunk.cc:46
inet::Chunk::isImproperlyRepresented
virtual bool isImproperlyRepresented() const
Definition: Chunk.h:477
inet::SliceChunk::chunk
Ptr< Chunk > chunk
The chunk of which this chunk is a slice, or nullptr if not yet specified.
Definition: SliceChunk.h:31
inet::Chunk::CT_SLICE
@ CT_SLICE
Definition: Chunk.h:267