MIHMessageRegistry.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_80221Bundle_MIHMessageRegistry_
18 #define HH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 1
19 
20 // Custom includes
21 #include <boost/ptr_container/ptr_map.hpp>
22 #include <senf/Utils/singleton.hh>
23 #include <senf/Packets/Packets.hh>
24 
25 #include "MIHMessageRegistry.ih"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 namespace senf {
28 
30  : public senf::singleton<MIHMessageRegistry>
31  {
32  public:
33  typedef boost::uint16_t key_t;
34 
35  private:
36  MIHMessageRegistry() {};
37 
38  typedef boost::ptr_map<key_t, detail::MIHMessageRegistry_EntryBase > Map;
39  Map map_;
40 
41  public:
44 
45  template <typename MIHPacket>
47  RegistrationProxy(key_t messageId);
48  };
49 
50  template <typename MIHPacket>
51  void registerMessageType(key_t messageId);
52 
53  void validate(key_t messageId, senf::Packet message);
54 
56  const_iterator begin() const;
57  const_iterator end() const;
58  };
59 
60 
61 # define SENF_MIH_PACKET_REGISTRY_REGISTER( packet, messageId ) \
62  SENF_PACKET_REGISTRY_REGISTER( \
63  senf::MIHMessageRegistry, messageId, packet ) \
64  namespace { \
65  senf::MIHMessageRegistry::RegistrationProxy< packet > \
66  BOOST_PP_CAT(mihPacketRegistration_, __LINE__) (messageId); \
67  }
68 
69 }
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 //#include "MIHMessageRegistry.cci"
72 #include "MIHMessageRegistry.ct"
73 //#include "MIHMessageRegistry.cti"
74 #endif
75 
76 
77 
78 // Local Variables:
79 // mode: c++
80 // fill-column: 100
81 // c-file-style: "senf"
82 // indent-tabs-mode: nil
83 // ispell-local-dictionary: "american"
84 // compile-command: "scons -u test"
85 // comment-column: 40
86 // End:
void validate(key_t messageId, senf::Packet message)
Packets public header.
const_iterator begin() const
raw_container::const_iterator const_iterator
Definition: PacketTypes.hh:70
Main Packet class.
Definition: Packet.hh:131
void registerMessageType(key_t messageId)
const_iterator end() const
Map::const_iterator const_iterator