// $Id$ // // 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 // 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. /** \file \brief PacketType inline template implementation */ //#include "PacketType.ih" // Custom includes #include #include "PacketRegistry.hh" #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketTypeBase template prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeBase::factory() { return PacketInterpreter::factory(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketTypeMixin template prefix_ senf::PacketInterpreterBase::optional_range senf::PacketTypeMixin::nextPacketRange(ConcretePacket const & p) { // Call the member defined in the specialization below return PacketTypeMixin::nextPacketRange(p); } template prefix_ senf::PacketInterpreterBase::factory_t senf::PacketTypeMixin::nextPacketType(ConcretePacket const & p) { if (p.data().size() < Self::initSize()) return Self::no_factory(); return lookup( Self::nextPacketKey(p) ); } template prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin::initSize() { return senf::init_bytes< typename Self::parser >::value; } template prefix_ void senf::PacketTypeMixin::init(ConcretePacket const & p) { p->init(); } template prefix_ typename senf::PacketTypeMixin::optional_key_t senf::PacketTypeMixin::key(Packet const & p) { return p ? PacketRegistry::key(p, nothrow) : optional_key_t(); } template prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeMixin::lookup(key_t key) { typename PacketRegistry::Entry const * entry ( PacketRegistry::lookup( key, senf::nothrow )); return entry ? entry->factory() : PacketTypeBase::no_factory(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::PacketTypeMixin template prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin::initSize() { return senf::init_bytes< typename Self::parser >::value; } template prefix_ void senf::PacketTypeMixin::init(ConcretePacket const & p) { p->init(); } //-///////////////////////////////////////////////////////////////////////////////////////////////// #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: