Vanetza
 
Loading...
Searching...
No Matches
vanetza::CohesivePacket Class Reference

#include <cohesive_packet.hpp>

Public Types

typedef boost::iterator_range< ByteBuffer::iterator > buffer_range
 
typedef boost::iterator_range< ByteBuffer::const_iterator > buffer_const_range
 

Public Member Functions

 CohesivePacket (const ByteBuffer &buffer, OsiLayer layer)
 
 CohesivePacket (ByteBuffer &&buffer, OsiLayer layer)
 
 CohesivePacket (const CohesivePacket &)
 
CohesivePacketoperator= (const CohesivePacket &)
 
 CohesivePacket (CohesivePacket &&)=default
 
CohesivePacketoperator= (CohesivePacket &&)=default
 
buffer_const_range operator[] (OsiLayer layer) const
 
buffer_range operator[] (OsiLayer layer)
 
void set_boundary (OsiLayer, unsigned bytes)
 
void trim (OsiLayer from, unsigned bytes)
 
std::size_t size () const
 
std::size_t size (OsiLayer single_layer) const
 
std::size_t size (OsiLayer from, OsiLayer to) const
 
const ByteBuffer & buffer () const
 

Private Member Functions

void reset_iterators (OsiLayer layer)
 
void rebuild_iterators (const CohesivePacket &)
 
buffer_const_range get (unsigned idx) const
 
buffer_range get (unsigned idx)
 

Private Attributes

ByteBuffer m_buffer
 
std::array< ByteBuffer::iterator, osi_layers.size()+1 > m_iterators
 

Detailed Description

A cohesive packet is stored in contiguous memory

Definition at line 15 of file cohesive_packet.hpp.

Member Typedef Documentation

◆ buffer_const_range

typedef boost::iterator_range<ByteBuffer::const_iterator> vanetza::CohesivePacket::buffer_const_range

Definition at line 19 of file cohesive_packet.hpp.

◆ buffer_range

typedef boost::iterator_range<ByteBuffer::iterator> vanetza::CohesivePacket::buffer_range

Definition at line 18 of file cohesive_packet.hpp.

Constructor & Destructor Documentation

◆ CohesivePacket() [1/3]

vanetza::CohesivePacket::CohesivePacket ( const ByteBuffer &  buffer,
OsiLayer  layer 
)

Create packet from buffer and assign all bytes to given layer

Parameters
buffercopy data from this buffer
layerall bytes belong to this layer (at least at first)

Definition at line 16 of file cohesive_packet.cpp.

◆ CohesivePacket() [2/3]

vanetza::CohesivePacket::CohesivePacket ( ByteBuffer &&  buffer,
OsiLayer  layer 
)

Definition at line 22 of file cohesive_packet.cpp.

◆ CohesivePacket() [3/3]

vanetza::CohesivePacket::CohesivePacket ( const CohesivePacket other)

Definition at line 28 of file cohesive_packet.cpp.

Member Function Documentation

◆ buffer()

const ByteBuffer & vanetza::CohesivePacket::buffer ( ) const
inline

Non-mutable access to internal byte buffer

Returns
const byte buffer reference

Definition at line 84 of file cohesive_packet.hpp.

◆ get() [1/2]

auto vanetza::CohesivePacket::get ( unsigned  idx)
private

Definition at line 121 of file cohesive_packet.cpp.

◆ get() [2/2]

auto vanetza::CohesivePacket::get ( unsigned  idx) const
private

Definition at line 128 of file cohesive_packet.cpp.

◆ operator=()

CohesivePacket & vanetza::CohesivePacket::operator= ( const CohesivePacket other)

Definition at line 34 of file cohesive_packet.cpp.

◆ operator[]() [1/2]

auto vanetza::CohesivePacket::operator[] ( OsiLayer  layer)

Definition at line 46 of file cohesive_packet.cpp.

◆ operator[]() [2/2]

auto vanetza::CohesivePacket::operator[] ( OsiLayer  layer) const

Access a certain sub-range of packet data belonging to a specific layer

Parameters
layerrequested layer data
Returns
buffer range with data, might be empty

Definition at line 41 of file cohesive_packet.cpp.

◆ rebuild_iterators()

void vanetza::CohesivePacket::rebuild_iterators ( const CohesivePacket other)
private

Definition at line 110 of file cohesive_packet.cpp.

◆ reset_iterators()

void vanetza::CohesivePacket::reset_iterators ( OsiLayer  layer)
private

Definition at line 93 of file cohesive_packet.cpp.

◆ set_boundary()

void vanetza::CohesivePacket::set_boundary ( OsiLayer  layer,
unsigned  bytes 
)

Set boundary of layer data. Data beyond boundary belongs to next upper layer afterwards.

Parameters
layerset boundary of this layer
byteslength of layer
Note
Never set boundary larger than previous layer length!

Definition at line 51 of file cohesive_packet.cpp.

◆ size() [1/3]

std::size_t vanetza::CohesivePacket::size ( ) const

Get size of whole packet

Returns
length in bytes

Definition at line 75 of file cohesive_packet.cpp.

◆ size() [2/3]

std::size_t vanetza::CohesivePacket::size ( OsiLayer  from,
OsiLayer  to 
) const

Get size of several layers

Parameters
fromstart counting with this layer
tostop counting after this layer
Returns
length in bytes

Definition at line 85 of file cohesive_packet.cpp.

◆ size() [3/3]

std::size_t vanetza::CohesivePacket::size ( OsiLayer  single_layer) const

Get size of a single layer in packet

Parameters
single_layerwhich layer has to be considered
Returns
length in bytes

Definition at line 80 of file cohesive_packet.cpp.

◆ trim()

void vanetza::CohesivePacket::trim ( OsiLayer  from,
unsigned  bytes 
)

Trim size of packet, i.e. cut bytes at the end if too long.

Parameters
fromstart counting with this layer
bytestarget length in bytes

Definition at line 58 of file cohesive_packet.cpp.

Member Data Documentation

◆ m_buffer

ByteBuffer vanetza::CohesivePacket::m_buffer
private

Definition at line 92 of file cohesive_packet.hpp.

◆ m_iterators

std::array<ByteBuffer::iterator, osi_layers.size() + 1> vanetza::CohesivePacket::m_iterators
private

Definition at line 93 of file cohesive_packet.hpp.


The documentation for this class was generated from the following files: