X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FPacketRegistry.ct;h=ab0de44ea45a80d859b34f0485efc207d3db5dc3;hb=92f8630b75f3ef50e73c48cde58645dcd1534e27;hp=a0bf61cf4fd8afd20a6e90644bc3da9df9401ad0;hpb=914af680a37d303da51e3877972ca9bd68d6190b;p=senf.git diff --git a/Packets/PacketRegistry.ct b/Packets/PacketRegistry.ct index a0bf61c..ab0de44 100644 --- a/Packets/PacketRegistry.ct +++ b/Packets/PacketRegistry.ct @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -26,11 +26,16 @@ #include "PacketRegistry.ih" // Custom includes +#include "../Utils/senfassert.hh" #include +#include "../Utils/TypeInfo.hh" #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +// senf::detail::PkReg_EntryImpl + template prefix_ senf::PacketInterpreterBase::factory_t senf::detail::PkReg_EntryImpl::factory() const @@ -38,11 +43,32 @@ prefix_ senf::PacketInterpreterBase::factory_t senf::detail::PkReg_EntryImpl +prefix_ std::string senf::detail::PkReg_EntryImpl::name() + const +{ + return prettyName(typeid(PacketType)); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::PacketRegistry + +template +prefix_ typename senf::PacketRegistry::Registry & +senf::PacketRegistry::registry() +{ + static Registry registry (prettyName(typeid(Tag))); + return registry; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::detail::PacketRegistryImpl: + template template prefix_ void senf::detail::PacketRegistryImpl::registerPacket(key_t key) { -#ifdef NDEBUG +#ifndef SENF_DEBUG registry_.insert(std::make_pair(key, Entry_ptr(new detail::PkReg_EntryImpl()))); reverseRegistry_.insert(std::make_pair(senf::typeIdValue(), key)); #else @@ -50,12 +76,12 @@ prefix_ void senf::detail::PacketRegistryImpl::registerPacket(key_t key registry_.insert( std::make_pair(key, Entry_ptr(new detail::PkReg_EntryImpl()))).second); // If this assertion fails, a Packet was registered with an already known key - BOOST_ASSERT( isUnique ); + SENF_ASSERT( isUnique ); bool isNew ( reverseRegistry_.insert( std::make_pair(senf::typeIdValue(), key)).second); // If this assertion fails, the same Packet was registered with two different keys - BOOST_ASSERT( isNew ); + SENF_ASSERT( isNew ); #endif } @@ -99,12 +125,13 @@ senf::detail::PacketRegistryImpl::lookup(key_t key, bool) return i->second.get(); } -template -prefix_ typename senf::PacketRegistry::Registry & -senf::PacketRegistry::registry() +template +prefix_ void senf::detail::PacketRegistryImpl::v_dump(std::ostream & os) { - static Registry registry; - return registry; + typename PacketMap::const_iterator i (registry_.begin()); + typename PacketMap::const_iterator const i_end (registry_.end()); + for (; i != i_end; ++i) + os << i->first << " " << i->second->name() << "\n"; } ///////////////////////////////ct.e////////////////////////////////////////