PacketType.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Packets_PacketType_
18 #define HH_SENF_Packets_PacketType_ 1
19 
20 // Custom includes
21 #include <iosfwd>
22 #include "PacketTypes.hh"
23 #include "PacketData.hh"
24 #include "PacketParser.hh"
25 #include "Packet.hh"
26 
27 //#include "PacketType.mpp"
28 //-/////////////////////////////////////////////////////////////////////////////////////////////////
29 
30 namespace senf {
31 
101  {
102  typedef Packet packet;
103 
109 
113 
114  static optional_range no_range();
115  static factory_t no_factory();
116  template <class PacketType> static factory_t factory();
117 
120 
125  static size_type initSize();
127 
131  static size_type initHeadSize();
133 
144  static void init(packet p);
146 
156  static optional_range nextPacketRange(packet p);
158 
174  static factory_t nextPacketType(packet p);
176 
189  static void finalize(packet p);
191 
198  static void dump(packet p, std::ostream & os);
200 
205  };
206 
207 
299  template <class Self, class Registry=void>
301  {
302  public:
303  typedef typename Registry::key_t key_t;
304  typedef boost::optional<key_t> optional_key_t;
305 
306  static optional_key_t key (Packet const & p);
307 
319  static PacketTypeBase::factory_t lookup (key_t key);
320 
324  //\{
326 
330  static void init (ConcretePacket<Self> const & p);
331 
332  //\}
333  };
334 
335 # ifndef DOXYGEN
336 
337  template <class Self>
338  class PacketTypeMixin<Self,void>
339  {
340  public:
343  static void init (ConcretePacket<Self> const & p);
344  };
345 
346 # endif
347 
348 }
349 
350 //-/////////////////////////////////////////////////////////////////////////////////////////////////
351 #endif
352 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketType_i_)
353 #define HH_SENF_Packets_PacketType_i_
354 #include "PacketType.cci"
355 #include "PacketType.ct"
356 #include "PacketType.cti"
357 #endif
358 
359 
360 // Local Variables:
361 // mode: c++
362 // fill-column: 100
363 // c-file-style: "senf"
364 // indent-tabs-mode: nil
365 // ispell-local-dictionary: "american"
366 // compile-command: "scons -u test"
367 // comment-column: 40
368 // End:
369 
static optional_range no_range()
senf::detail::packet::byte byte
Definition: PacketType.hh:108
PacketParser public header.
PacketInterpreterBase::optional_range optional_range
Definition: PacketType.hh:111
PacketTypes public header.
Mixin to provide standard implementations for nextPacketRange and nextPacketType. ...
Definition: PacketType.hh:300
PacketData public header.
VoidPacketParser parser
Parser to parser packet fields.
Definition: PacketType.hh:118
boost::optional< key_t > optional_key_t
Definition: PacketType.hh:304
static void init(packet p)
Initialize new packet.
static factory_t factory()
raw_container::const_iterator const_iterator
Definition: PacketTypes.hh:70
static size_type initSize()
Get size of new (empty) packet.
Main Packet class.
Definition: Packet.hh:131
Protocol specific packet handle.
Definition: Packet.hh:87
Helper base-class implementing the PacketType interface.
Definition: PacketType.hh:100
static size_type initHeadSize()
Get size of new (empty) packet header.
raw_container::size_type size_type
Definition: PacketTypes.hh:66
static optional_range nextPacketRange(packet p)
Get next packet placement.
Default parser parsing nothing.
raw_container::iterator iterator
Definition: PacketTypes.hh:69
senf::detail::packet::size_type size_type
Definition: PacketType.hh:106
Packet public header.
static factory_t nextPacketType(packet p)
Get type of next packet.
senf::detail::packet::difference_type difference_type
Definition: PacketType.hh:107
PacketInterpreterBase::range range
Definition: PacketType.hh:110
static void finalize(packet p)
Finalize packet.
senf::detail::packet::iterator iterator
Definition: PacketType.hh:104
senf::detail::packet::const_iterator const_iterator
Definition: PacketType.hh:105
raw_container::difference_type difference_type
Definition: PacketTypes.hh:67
boost::optional< range > optional_range
static factory_t no_factory()
senf::detail::packet::size_type size_type
boost::iterator_range< iterator > range
boost::uint8_t byte
Definition: PacketTypes.hh:60
PacketInterpreterBase::factory_t factory_t
Definition: PacketType.hh:112
static void dump(packet p, std::ostream &os)
Dump packet data in readable form.
Registry::key_t key_t
Definition: PacketType.hh:303