X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketRegistry.ih;h=af16278686f7eaa4c79eab77ba88513878d1eb50;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=7d23bfd190c19b02aa51c969e5558b801b139ccc;hpb=c6cca4c701e40b4b5500fd1d4a7730e823d02076;p=senf.git diff --git a/Packets/PacketRegistry.ih b/Packets/PacketRegistry.ih index 7d23bfd..af16278 100644 --- a/Packets/PacketRegistry.ih +++ b/Packets/PacketRegistry.ih @@ -23,18 +23,34 @@ /** \file \brief PacketRegistry internal header */ -#ifndef IH_PacketRegistryImpl_ -#define IH_PacketRegistryImpl_ 1 +#ifndef IH_SENF_Packets_PacketRegistry_ +#define IH_SENF_Packets_PacketRegistry_ 1 // Custom includes +#include #include +#include #include "../Utils/TypeIdValue.hh" ///////////////////////////////ih.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 + virtual std::string name() const = 0; + }; + namespace detail { - + /** \brief Internal: Registry entry implementation for a specific packet type \internal @@ -47,13 +63,33 @@ namespace detail { virtual std::string name() const; }; + /** \brief Internal: Registry implementation base-class and registry of registries + + \internal + */ + class PacketRegistryImplBase + : private boost::noncopyable + { + public: + virtual ~PacketRegistryImplBase(); + + static void dump(std::ostream & os); + + protected: + typedef std::map RegistryMap; + static RegistryMap & registries(); + + private: + virtual void v_dump(std::ostream & os) = 0; + }; + /** \brief Internal: Singleton class implementing the packet registry. \internal */ template - class PacketRegistryImpl - : private boost::noncopyable + class PacketRegistryImpl + : public PacketRegistryImplBase { public: typedef KeyType key_t; @@ -68,15 +104,14 @@ namespace detail { /////////////////////////////////////////////////////////////////////////// // Types + typedef boost::transform_iterator< ::__gnu_cxx::select1st, + typename PacketMap::const_iterator > iterator; + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ - // default default constructor - // no copy constructor - // no copy assignment - // default destructor - // no conversion constructors + PacketRegistryImpl(std::string const & name); ///@} /////////////////////////////////////////////////////////////////////////// @@ -90,9 +125,14 @@ namespace detail { Entry const & lookup(key_t key); Entry const * lookup(key_t key, bool); + iterator begin() const; + iterator end() const; + protected: private: + virtual void v_dump(std::ostream & os); + PacketMap registry_; ReversePacketMap reverseRegistry_; };