From: g0dil Date: Sun, 10 Feb 2008 18:30:58 +0000 (+0000) Subject: Packets: Add 'name()' member to packet registry entries X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=c6cca4c701e40b4b5500fd1d4a7730e823d02076;p=senf.git Packets: Add 'name()' member to packet registry entries git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@678 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/PacketRegistry.ct b/Packets/PacketRegistry.ct index 2f598ce..2cd02f8 100644 --- a/Packets/PacketRegistry.ct +++ b/Packets/PacketRegistry.ct @@ -28,6 +28,7 @@ // Custom includes #include "../Utils/senfassert.hh" #include +#include "../Utils/TypeInfo.hh" #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// @@ -39,6 +40,13 @@ prefix_ senf::PacketInterpreterBase::factory_t senf::detail::PkReg_EntryImpl +prefix_ std::string senf::detail::PkReg_EntryImpl::name() + const +{ + return prettyName(typeid(PacketType)); +} + template template prefix_ void senf::detail::PacketRegistryImpl::registerPacket(key_t key) diff --git a/Packets/PacketRegistry.hh b/Packets/PacketRegistry.hh index 8233d66..2ae1fa3 100644 --- a/Packets/PacketRegistry.hh +++ b/Packets/PacketRegistry.hh @@ -48,6 +48,7 @@ namespace senf { virtual ~PkReg_Entry(); virtual Packet::factory_t factory() const = 0; ///< Get factory of the registered packet type + virtual std::string name() const = 0; }; namespace detail { template class PacketRegistryImpl; } diff --git a/Packets/PacketRegistry.ih b/Packets/PacketRegistry.ih index 0055983..7d23bfd 100644 --- a/Packets/PacketRegistry.ih +++ b/Packets/PacketRegistry.ih @@ -44,6 +44,7 @@ namespace detail { : public PkReg_Entry { virtual Packet::factory_t factory() const; + virtual std::string name() const; }; /** \brief Internal: Singleton class implementing the packet registry. @@ -55,13 +56,18 @@ namespace detail { : private boost::noncopyable { public: - /////////////////////////////////////////////////////////////////////////// - // Types - typedef KeyType key_t; - typedef PkReg_Entry Entry; + private: + typedef boost::intrusive_ptr Entry_ptr; + typedef std::map PacketMap; + typedef std::map ReversePacketMap; + + public: + /////////////////////////////////////////////////////////////////////////// + // Types + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -87,10 +93,6 @@ namespace detail { protected: private: - typedef boost::intrusive_ptr Entry_ptr; - typedef std::map PacketMap; - typedef std::map ReversePacketMap; - PacketMap registry_; ReversePacketMap reverseRegistry_; };