1#ifndef CBF_PACKET_BUFFER_HPP_MU3RK5V1
2#define CBF_PACKET_BUFFER_HPP_MU3RK5V1
4#include <vanetza/common/clock.hpp>
5#include <vanetza/geonet/cbf_packet_identifier.hpp>
6#include <vanetza/geonet/packet.hpp>
7#include <vanetza/geonet/pending_packet.hpp>
8#include <vanetza/geonet/pdu_variant.hpp>
9#include <boost/bimap/bimap.hpp>
10#include <boost/bimap/multiset_of.hpp>
11#include <boost/bimap/unordered_set_of.hpp>
12#include <boost/optional/optional.hpp>
71 std::size_t
length()
const;
88 using Identifier = CbfPacketIdentifier;
112 bool remove(
const Identifier&
id);
119 void update(
const Identifier&
id, Clock::duration timeout);
130 boost::optional<CbfPacket>
fetch(
const Identifier&
id);
145 std::size_t
counter(
const Identifier& packet)
const;
154 bool operator<(
const Timer&)
const;
156 Clock::time_point expiry;
157 Clock::time_point start;
160 using timer_bimap = boost::bimaps::bimap<
161 boost::bimaps::multiset_of<Timer>,
162 boost::bimaps::unordered_set_of<Identifier, std::hash<Identifier>>,
163 boost::bimaps::with_info<std::list<CbfPacket>::iterator>
174 void remove_timer(
typename timer_bimap::left_map::iterator);
189 std::list<CbfPacket> m_packets;
190 timer_bimap m_timers;
192 std::unique_ptr<CbfCounter> m_counter;
193 const std::size_t m_capacity_bytes;
194 std::size_t m_stored_bytes;
195 TimerCallback m_timer_callback;
std::size_t counter(const Identifier &packet) const
boost::optional< CbfPacket > fetch(const Identifier &id)
void remove_timer(typename timer_bimap::left_map::iterator)
bool remove(const Identifier &id)
void update(const Identifier &id, Clock::duration timeout)
void add(CbfPacket &&packet, Clock::duration timeout)
const CbfPacket * find(const Identifier &id) const
bool reduce_lifetime(const Timer &, CbfPacket &) const
std::size_t length() const
Clock::duration reduce_lifetime(Clock::duration d)
const MacAddress & sender() const
SequenceNumber sequence_number() const
const Address & source() const