Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PacketType.cti

Go to the documentation of this file.
00001 // $Id: PacketType.cti 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 //#include "PacketType.ih"
00027 
00028 // Custom includes
00029 #include <boost/utility.hpp>
00030 #include "PacketRegistry.hh"
00031 
00032 #define prefix_ inline
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 // senf::PacketTypeBase
00037 
00038 template <class PacketType>
00039 prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeBase::factory()
00040 {
00041     return PacketInterpreter<PacketType>::factory();
00042 }
00043 
00044 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00045 // senf::PacketTypeMixin<Self,Registry>
00046 
00047 template <class Self, class Registry>
00048 prefix_ senf::PacketInterpreterBase::optional_range
00049 senf::PacketTypeMixin<Self,Registry>::nextPacketRange(ConcretePacket<Self> const & p)
00050 {
00051     // Call the member defined in the specialization below
00052     return PacketTypeMixin<Self>::nextPacketRange(p);
00053 }
00054 
00055 template <class Self, class Registry>
00056 prefix_ senf::PacketInterpreterBase::factory_t
00057 senf::PacketTypeMixin<Self,Registry>::nextPacketType(ConcretePacket<Self> const & p)
00058 {
00059     if (p.data().size() < Self::initSize())
00060         return Self::no_factory();
00061     return lookup( Self::nextPacketKey(p) );
00062 }
00063 
00064 template <class Self, class Registry>
00065 prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,Registry>::initSize()
00066 {
00067     return senf::init_bytes< typename Self::parser >::value;
00068 }
00069 
00070 template <class Self, class Registry>
00071 prefix_ void senf::PacketTypeMixin<Self,Registry>::init(ConcretePacket<Self> const & p)
00072 {
00073     p->init();
00074 }
00075 
00076 template <class Self, class Registry>
00077 prefix_ typename senf::PacketTypeMixin<Self,Registry>::optional_key_t
00078 senf::PacketTypeMixin<Self,Registry>::key(Packet const & p)
00079 {
00080     return p ? PacketRegistry<Registry>::key(p, nothrow) : optional_key_t();
00081 }
00082 
00083 template <class Self, class Registry>
00084 prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeMixin<Self,Registry>::lookup(key_t key)
00085 {
00086     typename PacketRegistry<Registry>::Entry const * entry (
00087         PacketRegistry<Registry>::lookup( key, senf::nothrow ));
00088     return entry ? entry->factory() : PacketTypeBase::no_factory();
00089 }
00090 
00091 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00092 // senf::PacketTypeMixin<Self,void>
00093 
00094 template <class Self>
00095 prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin<Self,void>::initSize()
00096 {
00097     return senf::init_bytes< typename Self::parser >::value;
00098 }
00099 
00100 template <class Self>
00101 prefix_ void senf::PacketTypeMixin<Self,void>::init(ConcretePacket<Self> const & p)
00102 {
00103     p->init();
00104 }
00105 
00106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00107 #undef prefix_
00108 
00109 
00110 // Local Variables:
00111 // mode: c++
00112 // fill-column: 100
00113 // c-file-style: "senf"
00114 // indent-tabs-mode: nil
00115 // ispell-local-dictionary: "american"
00116 // compile-command: "scons -u test"
00117 // comment-column: 40
00118 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research