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 PacketRegistry inline template implementation */
17 #include "PacketRegistry.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::PacketRegistry<Tag>::ScopedRegistrationProxy<PacketType>
28 template <class PacketType>
29 prefix_ senf::PacketRegistry<Tag>::ScopedRegistrationProxy<PacketType>::
30 ScopedRegistrationProxy(typename Tag::key_t key, int priority)
32 PacketRegistry<Tag>::template registerPacket<PacketType>(key,priority);
36 template <class PacketType>
37 prefix_ senf::PacketRegistry<Tag>::ScopedRegistrationProxy<PacketType>::~ScopedRegistrationProxy()
40 PacketRegistry<Tag>::template unregisterPacket<PacketType>();
42 catch (PacketTypeNotRegisteredException & ex)
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // senf::PacketRegistry<Tag>
50 template <class PacketType>
51 prefix_ void senf::PacketRegistry<Tag>::registerPacket(typename Tag::key_t key, int priority)
53 registry().template registerPacket<PacketType>(key, priority);
57 template <class PacketType>
58 prefix_ void senf::PacketRegistry<Tag>::unregisterPacket()
61 registry().template unregisterPacket<PacketType>();
65 prefix_ void senf::PacketRegistry<Tag>::unregisterPacket(typename Tag::key_t key, int priority)
68 registry().unregisterPacket(key, priority);
72 template <class PacketType>
73 prefix_ typename Tag::key_t senf::PacketRegistry<Tag>::key()
75 return registry().key(senf::typeIdValue<PacketType>());
79 template <class PacketType>
80 prefix_ typename boost::optional<typename Tag::key_t> senf::PacketRegistry<Tag>::key(NoThrow_t)
82 return registry().key(senf::typeIdValue<PacketType>(),true);
86 prefix_ typename Tag::key_t senf::PacketRegistry<Tag>::key(Packet const & packet)
88 return registry().key(packet.typeId());
92 prefix_ typename boost::optional<typename Tag::key_t>
93 senf::PacketRegistry<Tag>::key(Packet const & packet, NoThrow_t)
95 return registry().key(packet.typeId(),true);
99 prefix_ typename senf::PacketRegistry<Tag>::Entry const &
100 senf::PacketRegistry<Tag>::lookup(typename Tag::key_t key)
102 return registry().lookup(key);
106 prefix_ typename senf::PacketRegistry<Tag>::Entry const *
107 senf::PacketRegistry<Tag>::lookup(typename Tag::key_t key, NoThrow_t)
109 return registry().lookup(key,true);
113 prefix_ typename senf::PacketRegistry<Tag>::iterator senf::PacketRegistry<Tag>::begin()
115 return registry().begin();
119 prefix_ typename senf::PacketRegistry<Tag>::iterator senf::PacketRegistry<Tag>::end()
121 return registry().end();
125 prefix_ senf::PacketRegistry<Tag>::PacketRegistry()
126 : registry_ (prettyName(typeid(Tag)))
130 prefix_ typename senf::PacketRegistry<Tag>::Registry &
131 senf::PacketRegistry<Tag>::registry()
133 return instance().registry_;
136 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 // senf::detail::PacketRegistryImpl<KeyType>
139 template <class KeyType>
140 prefix_ senf::detail::PacketRegistryImpl<KeyType>::PacketRegistryImpl(std::string const & name)
141 : registryByKey_( registry_.template get<ByKey>()),
142 registryByType_( registry_.template get<ByType>())
144 registries()[name] = this;
147 template <class KeyType>
148 prefix_ typename senf::detail::PacketRegistryImpl<KeyType>::iterator
149 senf::detail::PacketRegistryImpl<KeyType>::begin()
152 return registry_.begin();
155 template <class KeyType>
156 prefix_ typename senf::detail::PacketRegistryImpl<KeyType>::iterator
157 senf::detail::PacketRegistryImpl<KeyType>::end()
160 return registry_.end();
163 //-/////////////////////////////////////////////////////////////////////////////////////////////////
170 // c-file-style: "senf"
171 // indent-tabs-mode: nil
172 // ispell-local-dictionary: "american"
173 // compile-command: "scons -u test"
174 // comment-column: 40