X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.ct;h=e293a5ebaceeccfd024bacc4464263eb59f80218;hb=81ffa1c459b96dd44472bcef37e1e373934ee138;hp=734c4afd09258518217d0e7fd1ec809943e2aa5a;hpb=31d85cd6b8e03c5ecc924ca8892906be1bab702f;p=senf.git diff --git a/Packets/Packet.ct b/Packets/Packet.ct index 734c4af..e293a5e 100644 --- a/Packets/Packet.ct +++ b/Packets/Packet.ct @@ -1,9 +1,7 @@ -// $Id$ -// -// Copyright (C) 2006 +// Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,126 +18,43 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline template functions +/** \file + \brief Packet non-inline template implementation */ -#include "Packet.ih" +//#include "Packet.ih" // Custom includes -#include -#include "ParserBase.hh" #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// -template -prefix_ typename senf::Packet::ptr_t::ptr -senf::Packet::create(InputIterator b, InputIterator e) -{ - boost::intrusive_ptr impl (new impl::PacketImpl(b,e),false); - if (!check(impl->data_.begin(),impl->data_.end())) - throw TruncatedPacketException(); - typename ptr_t::ptr p (new OtherPacket(PacketOp_set(impl.get())), false); - return p; -} +/////////////////////////////////////////////////////////////////////////// +// senf::Packet template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::create() -{ - boost::intrusive_ptr impl ( - new impl::PacketImpl(min_bytes(),0)); - typename ptr_t::ptr p (new OtherPacket(PacketOp_set(impl.get())), false); - p->init(); - return p; -} - -template -prefix_ typename senf::Packet::ptr_t::ptr -senf::Packet::create(Packet::ptr payload) -{ - /** \todo should I instead of using head() throw away all - interpreters before payload? ... probably yes ... */ - payload->insert(payload->head()->begin(),min_bytes(),0); - typename ptr_t::ptr p (new OuterPacket(PacketOp_set(payload->impl_))); - p->init(); - return p; -} - -template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::reinterpret() -{ - // THIS INVALIDATES this !!!!!!! - if (!check(begin(),end())) - throw TruncatedPacketException(); - typename ptr_t::ptr p (new OtherPacket(PacketOp_replace(this)),false); - return p; -} - -template -prefix_ typename senf::Packet::ptr_t::ptr -senf::Packet::registerInterpreter(raw_container::iterator begin, - raw_container::iterator end) +prefix_ OtherPacket senf::Packet::findNext(NoThrow_t) const { - if (!check(begin,end)) - throw TruncatedPacketException(); - typename ptr_t::ptr p ( - new OtherPacket(PacketOp_register(begin-impl_->data_.begin(), - end-impl_->data_.begin(), - this)), - false); - return p; + Packet p (*this); + while (p && ! p.is()) + p = p.next(); + if (p) + return p.as(); + else + return OtherPacket(); } -#define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 9, "Packets/Packet.mpp", 4)) -#include BOOST_PP_ITERATE() - template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::find_next() +prefix_ OtherPacket senf::Packet::findPrev(NoThrow_t) const { - ptr p (next()); - while (p && !p->is()) - p = p->next(); - return p->as(); -} - -template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::find_prev() - const -{ - ptr p (prev()); - while (p && !p->is()) - p = p->prev(); - return p->as(); -} - -template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::get_next() - const -{ - typename ptr_t::ptr p (find_next()); - BOOST_ASSERT(p); - return p; -} - -template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::get_prev() - const -{ - typename ptr_t::ptr p (find_prev()); - BOOST_ASSERT(p); - return p; -} - -template -prefix_ void senf::Packet::insert(iterator pos, InputIterator f, InputIterator l, - Whence whence) -{ - size_type index(pos-impl_->data_.begin()); - BOOST_ASSERT( index >= begin_ && index <= end_ ); - size_type sz (impl_->data_.size()); - impl_->data_.insert(pos,f,l); - impl_->updateIterators(index,impl_->data_.size()-sz,self_,whence); + Packet p (*this); + while (p && ! p.is()) + p = p.prev(); + if (p) + return p.as(); + else + return OtherPacket(); } ///////////////////////////////ct.e//////////////////////////////////////// @@ -153,4 +68,5 @@ prefix_ void senf::Packet::insert(iterator pos, InputIterator f, InputIterator l // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" +// comment-column: 40 // End: