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
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
15 \brief MIH Message-Registry internal header */
17 #ifndef IH_SENF_Packets_80221Bundle_MIHMessageRegistry_
18 #define IH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 1
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 template<class T, typename Signature>
28 struct has_static_validate_member
34 static char test(helper<&U::validate> *);
37 static char (&test(...))[2];
39 static const bool value = sizeof(test<T>(0))==1;
43 struct MIHMessageRegistry_EntryBase
44 : private boost::noncopyable
46 virtual ~MIHMessageRegistry_EntryBase() {}
47 virtual void validate(senf::Packet message) const = 0;
48 virtual std::string name() const = 0;
52 template <class MIHPacket,
53 bool use_validate_member = has_static_validate_member<typename MIHPacket::type, void(MIHPacket)>::value>
54 struct MIHMessageRegistryEntry : MIHMessageRegistry_EntryBase
56 virtual void validate(senf::Packet message) const {}
57 virtual std::string name() const {
58 return senf::prettyName(typeid(MIHPacket));
62 template <class MIHPacket>
63 struct MIHMessageRegistryEntry<MIHPacket, true> : MIHMessageRegistry_EntryBase
65 virtual void validate(senf::Packet message) const;
66 virtual std::string name() const {
67 return senf::prettyName(typeid(MIHPacket));
73 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 // c-file-style: "senf"
82 // indent-tabs-mode: nil
83 // ispell-local-dictionary: "american"
84 // compile-command: "scons -u test"