From af6b51925cb5032dd2c670bd2c21912b732c6fc1 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Fri, 7 Aug 2015 09:59:14 +0100 Subject: dev: Make serialization in Sinic constant This changeset transitions the Sinic device to the new serialization framework that requires the serialization method to be constant. --- src/dev/pktfifo.hh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/dev/pktfifo.hh') diff --git a/src/dev/pktfifo.hh b/src/dev/pktfifo.hh index 95d46fc76..ea5803026 100644 --- a/src/dev/pktfifo.hh +++ b/src/dev/pktfifo.hh @@ -80,6 +80,7 @@ class PacketFifo typedef std::list fifo_list; typedef fifo_list::iterator iterator; + typedef fifo_list::const_iterator const_iterator; protected: std::list fifo; @@ -112,6 +113,9 @@ class PacketFifo iterator begin() { return fifo.begin(); } iterator end() { return fifo.end(); } + const_iterator begin() const { return fifo.begin(); } + const_iterator end() const { return fifo.end(); } + EthPacketPtr front() { return fifo.begin()->packet; } bool push(EthPacketPtr ptr) @@ -171,25 +175,25 @@ class PacketFifo bool copyout(void *dest, unsigned offset, unsigned len); - int countPacketsBefore(iterator i) + int countPacketsBefore(const_iterator i) const { if (i == fifo.end()) return 0; return i->number - fifo.begin()->number; } - int countPacketsAfter(iterator i) + int countPacketsAfter(const_iterator i) const { - iterator end = fifo.end(); + auto end = fifo.end(); if (i == end) return 0; return (--end)->number - i->number; } - void check() + void check() const { unsigned total = 0; - for (iterator i = begin(); i != end(); ++i) + for (auto i = begin(); i != end(); ++i) total += i->packet->length + i->slack; if (total != _size) -- cgit v1.2.3