X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacket.ct;h=073a9f8a935746cc5f9862f68681a825d6d036a4;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=57f43551145f583f58a7a3be482f6efbced604ed;hpb=85ab07d100a382467a42e19d741d403a7a96c951;p=senf.git diff --git a/Packets/Packet.ct b/Packets/Packet.ct index 57f4355..073a9f8 100644 --- a/Packets/Packet.ct +++ b/Packets/Packet.ct @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -20,126 +20,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; -} - -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) - 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; -} - -#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() - const -{ - ptr p (next()); - while (p && !p->is()) - p = p->next(); - return p->as(); -} +/////////////////////////////////////////////////////////////////////////// +// senf::Packet template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::find_prev() +prefix_ OtherPacket senf::Packet::find(NoThrow_t) const { - ptr p (prev()); - while (p && !p->is()) - p = p->prev(); - return p->as(); + Packet p (*this); + while (p && ! p.is()) + p = p.next(nothrow); + if (p) + return p.as(); + else + return OtherPacket(); } template -prefix_ typename senf::Packet::ptr_t::ptr senf::Packet::get_next() +prefix_ OtherPacket senf::Packet::rfind(NoThrow_t) 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(nothrow); + if (p) + return p.as(); + else + return OtherPacket(); } ///////////////////////////////ct.e//////////////////////////////////////// @@ -152,4 +69,6 @@ prefix_ void senf::Packet::insert(iterator pos, InputIterator f, InputIterator l // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: