MIHMessageRegistry.ct
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 
14 /** \file
15  \brief MIH Message-Registry non-inline template implementation */
16 
17 // Custom includes
18 #include "Exceptions.hh"
19 
20 #define prefix_
21 //-/////////////////////////////////////////////////////////////////////////////////////////////////
22 // senf::MIHMessageRegistry
23 
24 template <typename MIHPacket>
25 prefix_ void senf::MIHMessageRegistry::registerMessageType(key_t messageId)
26 {
27  map_.insert(messageId, new detail::MIHMessageRegistryEntry<MIHPacket>() );
28 }
29 
30 template <typename MIHPacket>
31 prefix_ senf::MIHMessageRegistry::RegistrationProxy<MIHPacket>::RegistrationProxy(key_t messageId)
32 {
33  MIHMessageRegistry::instance().registerMessageType<MIHPacket>(messageId);
34 }
35 
36 template <typename MIHPacket>
37 prefix_ void senf::detail::MIHMessageRegistryEntry<MIHPacket, true>::validate(senf::Packet message)
38  const
39 {
40  if (! message.is<MIHPacket>())
41  throw InvalidMIHPacketException("invalid packet chain: ")
42  << (message ? message.typeId().prettyName() : "invalid packet")
43  << " != " << prettyName(typeid(MIHPacket));
44  MIHPacket::type::validate(message.as<MIHPacket>());
45 }
46 
47 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 #undef prefix_
49 
50 
51 // Local Variables:
52 // mode: c++
53 // fill-column: 100
54 // comment-column: 40
55 // c-file-style: "senf"
56 // indent-tabs-mode: nil
57 // ispell-local-dictionary: "american"
58 // compile-command: "scons -u test"
59 // End: