admin: Allow SCONS var to override the scons binary to use
[senf.git] / Packets / Packet.cci
index a65c653..ea4f549 100644 (file)
@@ -1,6 +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 <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -45,6 +47,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 +62,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 +83,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 +124,7 @@ prefix_ bool senf::Packet::operator==(Packet other)
 prefix_ void senf::Packet::finalize()
     const
 {
+    last(); // Make sure the packet is complete
     ptr()->finalize();
 }
 
@@ -158,4 +177,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: