X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.cci;h=813ab10e4c62104c2bfe2a99eb3a015e77910e66;hb=1b1d76302a5d61e918ef71f1c8e11f80ac1262e2;hp=a65c653ee0f5d35c04ad9c85bf60420175c036c5;hpb=47368f306a577d1e46df69a7f729bd3893cbe5e7;p=senf.git diff --git a/Packets/Packet.cci b/Packets/Packet.cci index a65c653..813ab10 100644 --- a/Packets/Packet.cci +++ b/Packets/Packet.cci @@ -1,6 +1,8 @@ -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// $Id$ +// +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -22,6 +24,7 @@ \brief Packet inline non-template implementation */ // Custom includes +#include "../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// @@ -45,6 +48,14 @@ prefix_ senf::Packet senf::Packet::clone() prefix_ senf::Packet senf::Packet::next() const { + Packet p (next(nothrow)); + if (!p) throw InvalidPacketChainException(); + return p; +} + +prefix_ senf::Packet senf::Packet::next(NoThrow_t) + const +{ PacketInterpreterBase::ptr p (ptr()->next()); return !p && ptr()->nextPacketRange() ? checkNext() : Packet(p); } @@ -52,6 +63,14 @@ prefix_ senf::Packet senf::Packet::next() prefix_ senf::Packet senf::Packet::prev() const { + Packet p (prev(nothrow)); + if (!p) throw InvalidPacketChainException(); + return p; +} + +prefix_ senf::Packet senf::Packet::prev(NoThrow_t) + const +{ return Packet(ptr()->prev()); } @@ -65,7 +84,7 @@ prefix_ senf::Packet senf::Packet::last() const { Packet p (ptr()->last()); - return p.next() ? checkLast() : p; + return p.next(nothrow) ? checkLast() : p; } prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory) @@ -106,6 +125,7 @@ prefix_ bool senf::Packet::operator==(Packet other) prefix_ void senf::Packet::finalize() const { + last(); // Make sure the packet is complete ptr()->finalize(); } @@ -143,7 +163,7 @@ prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr packet) prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr() const { - BOOST_ASSERT(packet_); + SENF_ASSERT(packet_); return packet_; } @@ -158,4 +178,5 @@ prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr() // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" +// comment-column: 40 // End: