// $Id$ // // Copyright (C) 2006 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // 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 // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Definition of non-inline template functions #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(); } 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); } ///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // End: