X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FPacketRegistry.hh;h=beb33847ee24b98092d1da6f62417ad635db57a1;hb=4d90b955bf3590e215488395d1c9cec827476e07;hp=932dfec5416b9b0f11cc559cf980e351b3510e62;hpb=26610f603ebdd465307b9621f532c1fe19fd5571;p=senf.git diff --git a/senf/Packets/PacketRegistry.hh b/senf/Packets/PacketRegistry.hh index 932dfec..beb3384 100644 --- a/senf/Packets/PacketRegistry.hh +++ b/senf/Packets/PacketRegistry.hh @@ -79,6 +79,11 @@ namespace senf { this inclusion, you should not put packet registrations into a library but into an object file. + To simplify static registration the SENF_PACKET_REGISTRY_REGISTER macro can be used: + \code + SENF_PACKET_REGISTRY_REGISTER(SomeTag, SomePacket, key_of_somePacket); + \endcode + \ingroup packet_module */ template @@ -86,6 +91,7 @@ namespace senf { { public: typedef typename detail::PacketRegistryImpl::iterator iterator; + typedef typename detail::PacketRegistryImpl::Entry Entry; /** \brief Statically register a packet type in a PacketRegistry @@ -104,6 +110,7 @@ namespace senf { struct RegistrationProxy { RegistrationProxy(typename Tag::key_t key); + ~RegistrationProxy(); }; /** \brief Register new packet type @@ -121,6 +128,10 @@ namespace senf { template static void registerPacket(typename Tag::key_t key); + template + static void unregisterPacket(); + static void unregisterPacket(typename Tag::key_t key); + /** \brief Find key of a packet type Return the key of \a PacketType as registered in the \a Tag registry @@ -170,13 +181,13 @@ namespace senf { \throws PacketTypeNotRegistered if the \a key is not found in the registry \return %Packet entry for given \a key */ - static PkReg_Entry const & lookup(typename Tag::key_t key); + static Entry const & lookup(typename Tag::key_t key); /** \brief Lookup a packet by it's key \return Pointer to packet entry for given \a key or 0, if the key is not found in the registry. */ - static PkReg_Entry const * lookup(typename Tag::key_t key, NoThrow_t); + static Entry const * lookup(typename Tag::key_t key, NoThrow_t); /** \brief Beginning iterator to list of registered keys */ @@ -196,6 +207,7 @@ namespace senf { This macro will declare an anonymous global variable in such a way, that constructing this variable will add a registration to the given packet registry. + \ingroup packet_module \hideinitializer */ # define SENF_PACKET_REGISTRY_REGISTER( registry, value, type ) \ @@ -216,7 +228,7 @@ namespace senf { This exception is signaled whenever a throwing lookup operation fails. */ struct PacketTypeNotRegisteredException : public senf::Exception - { PacketTypeNotRegisteredException() : senf::Exception("packet type not registered"){} }; + { PacketTypeNotRegisteredException() : senf::Exception("packet type not registered") {} }; } @@ -229,7 +241,7 @@ namespace senf { #include "PacketRegistry.cti" #endif - + // Local Variables: // mode: c++ // fill-column: 100 @@ -239,4 +251,3 @@ namespace senf { // compile-command: "scons -u test" // comment-column: 40 // End: -