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.hh

Go to the documentation of this file.
00001 // $Id: PacketType.hh 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 #ifndef HH_SENF_Packets_PacketType_
00027 #define HH_SENF_Packets_PacketType_ 1
00028 
00029 // Custom includes
00030 #include <iostream>
00031 #include "PacketTypes.hh"
00032 #include "PacketData.hh"
00033 #include "PacketParser.hh"
00034 #include "Packet.hh"
00035 
00036 //#include "PacketType.mpp"
00037 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00038 
00039 namespace senf {
00040 
00109     struct PacketTypeBase
00110     {
00111         typedef Packet packet;
00112 
00113         typedef senf::detail::packet::iterator iterator;
00114         typedef senf::detail::packet::const_iterator const_iterator;
00115         typedef senf::detail::packet::size_type size_type;
00116         typedef senf::detail::packet::difference_type difference_type;
00117         typedef senf::detail::packet::byte byte;
00118 
00119         typedef PacketInterpreterBase::range range;
00120         typedef PacketInterpreterBase::optional_range optional_range;
00121         typedef PacketInterpreterBase::factory_t factory_t;
00122 
00123         static optional_range no_range();
00124         static factory_t no_factory();
00125         template <class PacketType> static factory_t factory();
00126 
00127         typedef VoidPacketParser parser;
00129 
00134         static size_type initSize();
00136 
00140         static size_type initHeadSize();
00142 
00153         static void init(packet p);
00155 
00165         static optional_range nextPacketRange(packet p);
00167 
00183         static factory_t nextPacketType(packet p);
00185 
00198         static void finalize(packet p);
00200 
00207         static void dump(packet p, std::ostream & os);
00209 
00214     };
00215 
00216 
00308     template <class Self, class Registry=void>
00309     class PacketTypeMixin
00310     {
00311     public:
00312         typedef typename Registry::key_t key_t;
00313         typedef boost::optional<key_t> optional_key_t;
00314 
00315         static optional_key_t key (Packet const & p); 
00316 
00328         static PacketTypeBase::factory_t lookup (key_t key); 
00329 
00333 
00334         //\{
00335 
00336         static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket<Self> const & p);
00337         static PacketInterpreterBase::factory_t      nextPacketType  (ConcretePacket<Self> const & p);
00338         static PacketInterpreterBase::size_type      initSize        ();
00339         static void                                  init            (ConcretePacket<Self> const & p);
00340 
00341         //\}
00342     };
00343 
00344 #   ifndef DOXYGEN
00345 
00346     template <class Self>
00347     class PacketTypeMixin<Self,void>
00348     {
00349     public:
00350         static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket<Self> const & p);
00351         static PacketInterpreterBase::size_type      initSize        ();
00352         static void                                  init            (ConcretePacket<Self> const & p);
00353     };
00354 
00355 #   endif
00356 
00357 }
00358 
00359 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00360 #endif
00361 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketType_i_)
00362 #define HH_SENF_Packets_PacketType_i_
00363 #include "PacketType.cci"
00364 #include "PacketType.ct"
00365 #include "PacketType.cti"
00366 #endif
00367 
00368 
00369 // Local Variables:
00370 // mode: c++
00371 // fill-column: 100
00372 // c-file-style: "senf"
00373 // indent-tabs-mode: nil
00374 // ispell-local-dictionary: "american"
00375 // compile-command: "scons -u test"
00376 // comment-column: 40
00377 // End:
00378 

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