X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketRegistry.ih;h=94b9169d903513cbff4c452544d1c7dc29335275;hb=2c10a733c69cd95e10a312a471c84d07d52b7755;hp=1a017093abf0ef9a3598bf9296e22d6d367816bb;hpb=85ab07d100a382467a42e19d741d403a7a96c951;p=senf.git diff --git a/Packets/PacketRegistry.ih b/Packets/PacketRegistry.ih index 1a01709..94b9169 100644 --- a/Packets/PacketRegistry.ih +++ b/Packets/PacketRegistry.ih @@ -24,34 +24,24 @@ #define IH_PacketRegistryImpl_ 1 // Custom includes -#include "Packet.hh" -#include "DataPacket.hh" +#include #include "typeidvalue.hh" ///////////////////////////////ih.p//////////////////////////////////////// namespace senf { +namespace detail { -namespace impl { - - struct PkReg_Entry { - virtual ~PkReg_Entry() {} - virtual void registerInterpreter(Packet const * p, - Packet::iterator b, Packet::iterator e) = 0; - virtual Packet::ptr reinterpret(Packet * p) = 0; - }; - - template + template struct PkReg_EntryImpl : public PkReg_Entry { - virtual void registerInterpreter(Packet const * p, Packet::iterator b, Packet::iterator e); - virtual Packet::ptr reinterpret(Packet * p); + virtual PacketInterpreterBase::factory_t factory() const; }; - template - class PacketRegistryImpl : private boost::noncopyable + class PacketRegistryImpl + : private boost::noncopyable { public: /////////////////////////////////////////////////////////////////////////// @@ -59,7 +49,7 @@ namespace impl { typedef KeyType key_t; - typedef impl::PkReg_Entry Entry; + typedef PkReg_Entry Entry; /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members @@ -74,20 +64,19 @@ namespace impl { ///@} /////////////////////////////////////////////////////////////////////////// - template + template void registerPacket(key_t key); key_t key(senf::TypeIdValue const & type); + boost::optional key(senf::TypeIdValue const & type, bool); - Entry * lookup(key_t key); + Entry const & lookup(key_t key); + Entry const * lookup(key_t key, bool); protected: private: - template - static void registerInterpreter(Packet * p, Packet::iterator b, Packet::iterator e); - - typedef boost::shared_ptr Entry_ptr; + typedef boost::intrusive_ptr Entry_ptr; typedef std::map PacketMap; typedef std::map ReversePacketMap; @@ -95,8 +84,6 @@ namespace impl { ReversePacketMap reverseRegistry_; }; - extern PkReg_EntryImpl pkreg_dataEntry; - }} ///////////////////////////////ih.e//////////////////////////////////////// @@ -109,4 +96,6 @@ namespace impl { // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: