Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

DebugModules.hh

Go to the documentation of this file.
00001 // $Id: DebugModules.hh 1772 2011-03-10 12:45:21Z tho $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_PPI_DebugModules_
00027 #define HH_SENF_PPI_DebugModules_ 1
00028 
00029 // Custom includes
00030 #include <deque>
00031 #include <senf/Utils/safe_bool.hh>
00032 #include "MonitorModule.hh"
00033 #include "ActiveFeeder.hh"
00034 #include <senf/Utils/Logger/SenfLog.hh>
00035 
00036 //#include "DebugModules.mpp"
00037 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00038 
00039 namespace senf {
00040 namespace ppi {
00041 namespace module {
00042 namespace debug {
00043 
00075     class ActiveSource
00076         : public Module,
00077           public safe_bool<ActiveSource>
00078     {
00079         SENF_PPI_MODULE(ActiveSource);
00080 
00081     public:
00082         connector::ActiveOutput<> output;
00083 
00084         ActiveSource();
00085 
00086         void submit(Packet const & packet);     
00087 
00089         bool boolean_test() const;      
00090     };
00091 
00098     class PassiveSource
00099         : public Module
00100     {
00101         SENF_PPI_MODULE(PassiveSource);
00102 
00103         typedef std::deque<Packet> Queue;
00104 
00105     public:
00106         typedef Queue::size_type size_type;
00107 
00108         connector::PassiveOutput<> output;
00109 
00110         PassiveSource();
00111 
00112         void throttle();                
00113         void unthrottle();              
00114 
00115         void submit(Packet const & packet);     
00116 
00117         bool empty();                   
00118         size_type size();               
00119 
00120     private:
00121         void request();
00122         virtual void v_init();
00123 
00124         Queue packets_;
00125     };
00126 
00136     class ActiveSink
00137         : public Module,
00138           public safe_bool<ActiveSink>
00139     {
00140         SENF_PPI_MODULE(ActiveSink);
00141 
00142     public:
00143         connector::ActiveInput<> input;
00144 
00145         ActiveSink();
00146 
00147         Packet request();               
00148 
00150         bool boolean_test() const;      
00151     };
00152 
00158     class PassiveSink
00159         : public Module
00160     {
00161         SENF_PPI_MODULE(PassiveSink);
00162 
00163         typedef std::deque<Packet> Queue;
00164 
00165     public:
00166         typedef Queue::size_type size_type;
00167         typedef Queue::const_iterator iterator;
00168 
00169         connector::PassiveInput<> input;
00170 
00171         PassiveSink();
00172 
00173         void throttle();                
00174         void unthrottle();              
00175 
00176         bool empty();                   
00177         size_type size();               
00178         iterator begin();               
00179         iterator end();                 
00180 
00181         Packet front();                 
00182         Packet pop_front();             
00183 
00184         void clear();                   
00185 
00186     private:
00187         void request();
00188 
00189         Queue packets_;
00190     };
00191 
00206     class ActiveFeederSource
00207     {
00208     private:
00209         PassiveSource source;
00210         ActiveFeeder feeder;
00211 
00212     public:
00213         typedef PassiveSource::size_type size_type;
00214 
00215         connector::ActiveOutput<> & output;
00216 
00217         ActiveFeederSource();
00218 
00219         void submit(Packet packet);     
00220         bool empty();                   
00221         size_type size();               
00222     };
00223 
00238     class ActiveFeederSink
00239     {
00240     private:
00241         PassiveSink sink;
00242         ActiveFeeder feeder;
00243 
00244     public:
00245         typedef PassiveSink::size_type size_type;
00246         typedef PassiveSink::iterator iterator;
00247 
00248         connector::ActiveInput<> & input;
00249 
00250         ActiveFeederSink();
00251 
00252         bool empty();
00253         size_type size();
00254         iterator begin();
00255         iterator end();
00256 
00257         Packet front();
00258         Packet pop_front();
00259 
00260         void clear();
00261     };
00262 
00268     template < class Stream = log::Debug,
00269                class Area   = log::DefaultArea,
00270                class Level  = log::VERBOSE >
00271     class Logger
00272         : public MonitorModule<>
00273     {
00274         SENF_PPI_MODULE(Logger);
00275     public:
00276         Logger();
00277         explicit Logger(std::string label);
00278 
00279     private:
00280         virtual void v_handlePacket(Packet const & packet);
00281 
00282         std::string label_;
00283     };
00284 
00285 }}}}
00286 
00287 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00288 #include "DebugModules.cci"
00289 //#include "DebugModules.ct"
00290 #include "DebugModules.cti"
00291 #endif
00292 
00293 
00294 // Local Variables:
00295 // mode: c++
00296 // fill-column: 100
00297 // comment-column: 40
00298 // c-file-style: "senf"
00299 // indent-tabs-mode: nil
00300 // ispell-local-dictionary: "american"
00301 // compile-command: "scons -u test"
00302 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research