X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketRegistry.hh;h=8f342ebb9004d150f8379d59d2cea0db881b4427;hb=ef4c5558d6a52367bd7040530d40c7616f6f5b71;hp=04e3177d55fa39beb99b0da1f970f3159755a4a4;hpb=0990bd1c4f917855f3645e7329a84b00e54ccd7d;p=senf.git diff --git a/Packets/PacketRegistry.hh b/Packets/PacketRegistry.hh index 04e3177..8f342eb 100644 --- a/Packets/PacketRegistry.hh +++ b/Packets/PacketRegistry.hh @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -33,25 +33,12 @@ #include "../Utils/Exception.hh" #include "Packet.hh" +#include "PacketRegistry.ih" //#include "PacketRegistry.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - /** \brief Registry entry - - Value returned by a registry lookup - */ - struct PkReg_Entry - : public intrusive_refcount - { - virtual ~PkReg_Entry(); - virtual Packet::factory_t factory() const = 0; - ///< Get factory of the registered packet type - }; - - namespace detail { template class PacketRegistryImpl; } - /** \brief Packet registration facility The PacketRegistry provides a generic facility to associate an arbitrary key with @@ -97,6 +84,8 @@ namespace senf { class PacketRegistry { public: + typedef typename detail::PacketRegistryImpl::iterator iterator; + /** \brief Statically register a packet type in a PacketRegistry To use this class, define a global symbol in the following way: @@ -188,6 +177,14 @@ packet of which the key is requested */ static PkReg_Entry const * lookup(typename Tag::key_t key, NoThrow_t); + /** \brief Beginning iterator to list of registered keys + */ + static iterator begin(); + + /** \brief End iterator to list of registered keys + */ + static iterator end(); + private: typedef detail::PacketRegistryImpl Registry; static Registry & registry(); @@ -200,18 +197,25 @@ packet of which the key is requested \hideinitializer */ -# define SENF_PACKET_REGISTRY_REGISTER( registry, value, type ) \ - namespace { \ - senf::PacketRegistry< registry >::RegistrationProxy< type > \ - packetRegistration_ ## __LINE__ ( value ); \ +# define SENF_PACKET_REGISTRY_REGISTER( registry, value, type ) \ + namespace { \ + senf::PacketRegistry< registry >::RegistrationProxy< type > \ + packetRegistration_ ## __LINE__ ( value ); \ } + /** \brief Dump all packet registries + + This command will dump all packet registries to the given stream. This is to help debugging + registration problems. + */ + void dumpPacketRegistries(std::ostream & os); + /** \brief Entry not found in registry This exception is signaled whenever a throwing lookup operation fails. */ - struct PacketTypeNotRegisteredException : public std::exception - { virtual char const * what() const throw() { return "packet type not registered"; } }; + struct PacketTypeNotRegisteredException : public senf::Exception + { PacketTypeNotRegisteredException() : senf::Exception("packet type not registered"){} }; } @@ -219,7 +223,7 @@ packet of which the key is requested #endif #if !defined(HH_Packets__decls_) && !defined(HH_PacketRegistryImpl_i_) #define HH_PacketRegistryImpl_i_ -//#include "PacketRegistry.cci" +#include "PacketRegistry.cci" #include "PacketRegistry.ct" #include "PacketRegistry.cti" #endif