// $Id$ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \file \brief PacketInterpreter inline template implementation */ //#include "PacketInterpreter.ih" // Custom includes #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketInterpreterBase // Interpreter chain access template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreterBase::as() { // ensure that the template argument is included in the corresponding object file when linking: { static typename PacketInterpreter::factory_t _ (PacketInterpreter::factory()); (void) _;} return typename PacketInterpreter::ptr( static_cast< PacketInterpreter* >(this)); } template prefix_ Annotation & senf::PacketInterpreterBase::annotation() { return impl().annotation(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketInterpreter template prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreter::factory() { return & factory_; } // Create completely new packet template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create() { return create(initSize()); } template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create(senf::NoInit_t) { return create(0,senf::noinit); } template template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create(ForwardReadableRange const & range) { detail::PacketImpl::Guard p (new detail::PacketImpl(boost::begin(range),boost::end(range))); ptr pi (create(p.p,p.p->begin(),p.p->end(),Append)); return pi; } // Create packet as new packet after a given packet template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet) { return createAfter(packet, initSize()); } template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::createAfter(PacketInterpreterBase::ptr const & packet, senf::NoInit_t) { return createAfter(packet, 0, senf::noinit); } // Create clone of current packet template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::clone() { return boost::static_pointer_cast(PacketInterpreterBase::clone()); } // Packet field access template prefix_ typename senf::PacketInterpreter::parser senf::PacketInterpreter::fields() { return parser (data().begin(),&data()); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // private members // Private structors template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create(detail::PacketImpl * impl, iterator b, iterator e, Append_t) { return ptr(new PacketInterpreter(impl,b,e,Append)); } template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create(detail::PacketImpl * impl, iterator b, iterator e, Prepend_t) { return ptr(new PacketInterpreter(impl,b,e,Prepend)); } template prefix_ typename senf::PacketInterpreter::ptr senf::PacketInterpreter::create(detail::PacketImpl * impl, iterator b, iterator e, PacketInterpreterBase::ptr const & before) { return ptr(new PacketInterpreter(impl,b,e,before)); } template prefix_ senf::PacketInterpreter::PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, Append_t) : PacketInterpreterBase(impl,b,e,Append) {} template prefix_ senf::PacketInterpreter::PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, Prepend_t) : PacketInterpreterBase(impl,b,e,Prepend) {} template prefix_ senf::PacketInterpreter::PacketInterpreter(detail::PacketImpl * impl, iterator b, iterator e, PacketInterpreterBase::ptr const & before) : PacketInterpreterBase(impl,b,e,before) {} // PacketType access template prefix_ senf::PacketInterpreterBase::size_type senf::PacketInterpreter::initSize() { return type::initSize(); } template prefix_ senf::PacketInterpreterBase::size_type senf::PacketInterpreter::initHeadSize() { size_type sz (type::initHeadSize()); return sz == size_type(-1) ? initSize() : sz ; } template prefix_ void senf::PacketInterpreter::init() { return type::init(ConcretePacket(ptr(this))); } //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // comment-column: 40 // End: