X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.cti;h=ed032da0160e70bf22d74929bec68ac5b752a058;hb=be4e99b96b305cb8f8c6a00a0098392483089812;hp=ce2c0fb07f334d186b9f4736c27b4177611ef195;hpb=6116cb96ea7bdcb42b7d12165a05fcbe0687226d;p=senf.git diff --git a/Packets/Packet.cti b/Packets/Packet.cti index ce2c0fb..ed032da 100644 --- a/Packets/Packet.cti +++ b/Packets/Packet.cti @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// 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 @@ -60,6 +60,8 @@ template prefix_ OtherPacket senf::Packet::as() const { + if (!is()) + throw std::bad_cast(); return OtherPacket(ptr()->as()); } @@ -67,81 +69,30 @@ template prefix_ OtherPacket senf::Packet::next() const { - OtherPacket p (next(nothrow)); - if (!p) throw InvalidPacketChainException(); - return p; -} - - -template -prefix_ OtherPacket senf::Packet::next(NoThrow_t) - const -{ - Packet p (next()); - return p ? p.findNext(nothrow) : OtherPacket(); + Packet p (next()) + return p ? p.as() : OtherPacket(); } template prefix_ OtherPacket senf::Packet::prev() const { - OtherPacket p (prev(nothrow)); - if (!p) throw InvalidPacketChainException(); - return p; -} - -template -prefix_ OtherPacket senf::Packet::prev(NoThrow_t) - const -{ Packet p (prev()); - return p ? p.findPrev(nothrow) : OtherPacket(); -} - -template -prefix_ OtherPacket senf::Packet::findNext() - const -{ - OtherPacket p (findNext(nothrow)); - if (!p) throw InvalidPacketChainException(); - return p; -} - -template -prefix_ OtherPacket senf::Packet::findPrev() - const -{ - OtherPacket p (findPrev(nothrow)); - if (!p) throw InvalidPacketChainException(); - return p; + return p ? p.as() : OtherPacket(); } template prefix_ OtherPacket senf::Packet::last() const { - return last().findPrev(); -} - -template -prefix_ OtherPacket senf::Packet::last(NoThrow_t) - const -{ - return last().findPrev(nothrow); + return last().as(); } template prefix_ OtherPacket senf::Packet::first() const { - return first().findNext(); -} - -template -prefix_ OtherPacket senf::Packet::first(NoThrow_t) - const -{ - return first().findNext(nothrow); + return first().as(); } ///////////////////////////////////////////////////////////////////////////