X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FDebugModules.hh;h=27212c65843c83e1dd470ee5d1ea2301a779a289;hb=d1d92fb783dc558dcf7bdc34ee933c10e1c8d227;hp=60ac7e5447869a0f64ef45563cbb541c15784341;hpb=416cdd1c85cdf2669785e93a71426a3206166758;p=senf.git diff --git a/PPI/DebugModules.hh b/PPI/DebugModules.hh index 60ac7e5..27212c6 100644 --- a/PPI/DebugModules.hh +++ b/PPI/DebugModules.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Copyright (C) 2007 +// 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 @@ -23,14 +23,14 @@ /** \file \brief DebugModules public header */ -#ifndef HH_DebugModules_ -#define HH_DebugModules_ 1 +#ifndef HH_SENF_PPI_DebugModules_ +#define HH_SENF_PPI_DebugModules_ 1 // Custom includes #include #include "../Utils/safe_bool.hh" #include "../Packets/Packets.hh" -#include "Module.hh" +#include "MonitorModule.hh" #include "ActiveFeeder.hh" #include "../Utils/Logger/SenfLog.hh" @@ -41,7 +41,7 @@ namespace senf { namespace ppi { namespace module { namespace debug { - + /** \namespace senf::ppi::module::debug \brief Debug modules @@ -49,7 +49,7 @@ namespace debug { manually pass packets into a network and read back the output packets. There are three categories of modules: - + \li Active modules (ActiveSource, ActiveSink) are triggered by external calls. Calling \c submit() / \c request() will send the request into the module network synchronously. From this it follows, that senf::ppi::run() should \e not be @@ -74,7 +74,7 @@ namespace debug { signaled in the network. */ class ActiveSource - : public Module, + : public Module, public safe_bool { SENF_PPI_MODULE(ActiveSource); @@ -84,14 +84,14 @@ namespace debug { ActiveSource(); - void submit(Packet packet); ///< Submit packet + void submit(Packet const & packet); ///< Submit packet /**< \pre boolean_test() is \c true */ bool boolean_test() const; ///< \c true if \a output is not throttled }; /** \brief Debug packet source with passive output - + This module provides a queue of packets for reading by the network. Each submit() call adds a packet to the queue which will be sent into the network when requested. The output is automatically throttled when the queue becomes empty. @@ -105,26 +105,26 @@ namespace debug { public: typedef Queue::size_type size_type; - + connector::PassiveOutput<> output; PassiveSource(); void throttle(); ///< Throttle output connector void unthrottle(); ///< Unthrottle output connector - - void submit(Packet packet); ///< Enqueue packet + + void submit(Packet const & packet); ///< Enqueue packet bool empty(); ///< \c true if queue is empty size_type size(); ///< Number of packets in queue private: void request(); - void init(); - + virtual void v_init(); + Queue packets_; }; - + /** \brief Debug packet sink with active input This module requests packets from the network. Each call to request() will pass a packet @@ -191,7 +191,7 @@ namespace debug { }; /** \brief Active, queue-based packet source - + The ActiveFeederSource contains a packet queue containing the packets to be precessed. These packets are actively fed into the network when it is run with senf::ppi::run() until it is empty, when senf::ppi::run() will return. @@ -212,7 +212,7 @@ namespace debug { public: typedef PassiveSource::size_type size_type; - + connector::ActiveOutput<> & output; ActiveFeederSource(); @@ -223,18 +223,18 @@ namespace debug { }; /** \brief Active, queue-based packet sink - + The ActiveFeederSink contains a packet queue to receive the packets from the network. The ActiveFeederSink will actively request packets from the network until it's input is throttled. \note ActiveFeederSink does \e not have a termination condition like ActiveFeederSource, it - relies on the network to throttle it's input. Also, the same not as for - ActiveFeederSource applies here too: You need to ensure, that no events are active - eventually or senf::ppi::run will not return. + relies on the network to throttle it's input. Additionally, the restrictions of + ActiveFeederSource apply here too: You need to ensure, that no (additional) events are + active (eventually) or senf::ppi::run will not return. ActiveFeederSink is not a module but a collection of two modules: a PassiveSink and an - ActiveFeeder. + ActiveFeeder. */ class ActiveFeederSink { @@ -247,7 +247,7 @@ namespace debug { typedef PassiveSink::iterator iterator; connector::ActiveInput<> & input; - + ActiveFeederSink(); bool empty(); @@ -260,27 +260,27 @@ namespace debug { void clear(); }; - + /** \brief Log received packets This module will log all packets sent to it's input using SENF_LOG to the given log \a Stream, \a Area and \a Level. */ - template < class Stream = log::Debug, - class Area = log::DefaultArea, + template < class Stream = log::Debug, + class Area = log::DefaultArea, class Level = log::VERBOSE > - class LogSink - : public module::Module + class Logger + : public MonitorModule<> { - SENF_PPI_MODULE(LogSink); + SENF_PPI_MODULE(Logger); public: - - connector::PassiveInput<> input; - - LogSink(); + Logger(); + explicit Logger(std::string label); private: - void request(); + virtual void v_handlePacket(Packet const & packet); + + std::string label_; }; }}}}