From: g0dil Date: Thu, 22 Jan 2009 10:22:44 +0000 (+0000) Subject: PPI: Add PacketType template argument to MonitorModule X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=7e35699acd77562184ae1b769bf967ffe0109500;p=senf.git PPI: Add PacketType template argument to MonitorModule Packets: Allow const access to annotations git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1070 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/MonitorModule.cc b/PPI/MonitorModule.ct similarity index 73% rename from PPI/MonitorModule.cc rename to PPI/MonitorModule.ct index 2a5420a..1945293 100644 --- a/PPI/MonitorModule.cc +++ b/PPI/MonitorModule.ct @@ -21,40 +21,40 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief MonitorModule non-inline non-template implementation */ + \brief MonitorModule non-inline template implementation */ -#include "MonitorModule.hh" //#include "MonitorModule.ih" // Custom includes -//#include "MonitorModule.mpp" #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +///////////////////////////////ct.p//////////////////////////////////////// -prefix_ void senf::ppi::module::MonitorModule::request() +template +prefix_ void senf::ppi::module::MonitorModule::request() { - Packet p (input()); + PacketType p (input()); v_handlePacket(p); if (output.connected()) output(p); } -prefix_ void senf::ppi::module::MonitorModule::throttle() +template +prefix_ void senf::ppi::module::MonitorModule::throttle() { if (output.connected()) input.throttle(); } -prefix_ void senf::ppi::module::MonitorModule::unthrottle() +template +prefix_ void senf::ppi::module::MonitorModule::unthrottle() { if (output.connected()) input.unthrottle(); } -///////////////////////////////cc.e//////////////////////////////////////// +///////////////////////////////ct.e//////////////////////////////////////// #undef prefix_ -//#include "MonitorModule.mpp" // Local Variables: diff --git a/PPI/MonitorModule.cci b/PPI/MonitorModule.cti similarity index 83% rename from PPI/MonitorModule.cci rename to PPI/MonitorModule.cti index 9c0e62c..e2f101a 100644 --- a/PPI/MonitorModule.cci +++ b/PPI/MonitorModule.cti @@ -21,16 +21,17 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief MonitorModule inline non-template implementation */ + \brief MonitorModule inline template implementation */ //#include "MonitorModule.ih" // Custom includes #define prefix_ inline -///////////////////////////////cci.p/////////////////////////////////////// +///////////////////////////////cti.p/////////////////////////////////////// -prefix_ senf::ppi::module::MonitorModule::MonitorModule() +template +prefix_ senf::ppi::module::MonitorModule::MonitorModule() { route(input, output).autoThrottling(false); input.onRequest(&MonitorModule::request); @@ -38,7 +39,7 @@ prefix_ senf::ppi::module::MonitorModule::MonitorModule() output.onUnthrottle(&MonitorModule::unthrottle); } -///////////////////////////////cci.e/////////////////////////////////////// +///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_ diff --git a/PPI/MonitorModule.hh b/PPI/MonitorModule.hh index c5517eb..30c8ff1 100644 --- a/PPI/MonitorModule.hh +++ b/PPI/MonitorModule.hh @@ -37,16 +37,17 @@ namespace senf { namespace ppi { namespace module { + template class MonitorModule : public Module { public: - senf::ppi::connector::PassiveInput<> input; - senf::ppi::connector::ActiveOutput<> output; + senf::ppi::connector::PassiveInput input; + senf::ppi::connector::ActiveOutput output; protected: MonitorModule(); - virtual void v_handlePacket(Packet const & p) = 0; + virtual void v_handlePacket(PacketType const & p) = 0; private: void request(); @@ -58,9 +59,9 @@ namespace module { }}} ///////////////////////////////hh.e//////////////////////////////////////// -#include "MonitorModule.cci" -//#include "MonitorModule.ct" -//#include "MonitorModule.cti" +//#include "MonitorModule.cci" +#include "MonitorModule.ct" +#include "MonitorModule.cti" #endif diff --git a/PPI/MonitorModule.test.cc b/PPI/MonitorModule.test.cc index b0f47c2..9fd3ee7 100644 --- a/PPI/MonitorModule.test.cc +++ b/PPI/MonitorModule.test.cc @@ -38,7 +38,7 @@ namespace { - class PacketCounter : public senf::ppi::module::MonitorModule + class PacketCounter : public senf::ppi::module::MonitorModule<> { SENF_PPI_MODULE(PacketCounter); public: diff --git a/Packets/Packet.cti b/Packets/Packet.cti index 0eb6ddc..afae606 100644 --- a/Packets/Packet.cti +++ b/Packets/Packet.cti @@ -141,6 +141,13 @@ prefix_ Annotation & senf::Packet::annotation() return ptr()->annotation(); } +template +prefix_ Annotation const & senf::Packet::annotation() + const +{ + return ptr()->annotation(); +} + /////////////////////////////////////////////////////////////////////////// // senf::ConcretePacket diff --git a/Packets/Packet.hh b/Packets/Packet.hh index d3b42a4..4a25789 100644 --- a/Packets/Packet.hh +++ b/Packets/Packet.hh @@ -376,6 +376,10 @@ namespace senf { ///@} + template + Annotation const & annotation() const; ///< Get packet annotation + /**< \see annotation() */ + ///\name Other methods ///@{