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

SocketSink.ct

Go to the documentation of this file.
00001 // $Id: SocketSink.ct 1742 2010-11-04 14:51:56Z g0dil $
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 //#include "SocketSink.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::ppi::module::ActiveSocketSink<Writer>
00035 
00036 template <class Writer>
00037 prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink()
00038 {
00039     registerEvent( event_, &ActiveSocketSink::write );
00040     route(input, event_);
00041 }
00042 
00043 template <class Writer>
00044 prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Writer const & writer)
00045     : writer_ (writer)
00046 {
00047     registerEvent( event_, &ActiveSocketSink::write );
00048     route(input, event_);
00049 }
00050 
00051 template <class Writer>
00052 prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Handle const &  handle)
00053     : handle_(handle), event_(handle_, IOEvent::Write), writer_()
00054 {
00055     registerEvent( event_, &ActiveSocketSink::write );
00056     route(input, event_);
00057 }
00058 
00059 template <class Writer>
00060 prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Handle const & handle,
00061                                                                     Writer const & writer)
00062     : handle_(handle), event_(handle_, IOEvent::Write), writer_(writer)
00063 {
00064     registerEvent( event_, &ActiveSocketSink::write );
00065     route(input, event_);
00066 }
00067 
00068 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00069 // private members
00070 
00071 template <class Writer>
00072 prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::write()
00073 {
00074     writer_(handle_,input());
00075 }
00076 
00077 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00078 // senf::ppi::module::PassiveSocketSink<Writer>
00079 
00080 template <class Writer>
00081 prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink()
00082 {
00083     noroute(input);
00084     input.onRequest(&PassiveSocketSink::write);
00085     checkThrottle();
00086 }
00087 
00088 template <class Writer>
00089 prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Writer const & writer)
00090     : writer_ (writer)
00091 {
00092     noroute(input);
00093     input.onRequest(&PassiveSocketSink::write);
00094     checkThrottle();
00095 }
00096 
00097 template <class Writer>
00098 prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle const & handle)
00099     : handle_(handle), writer_()
00100 {
00101     noroute(input);
00102     input.onRequest(&PassiveSocketSink::write);
00103     checkThrottle();
00104 }
00105 
00106 template <class Writer>
00107 prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle const & handle,
00108                                                                       Writer const & writer)
00109     : handle_(handle), writer_(writer)
00110 {
00111     noroute(input);
00112     input.onRequest(&PassiveSocketSink::write);
00113     checkThrottle();
00114 }
00115 
00116 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00117 // private members
00118 
00119 template <class Writer>
00120 prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::write()
00121 {
00122     writer_(handle_,input());
00123 }
00124 
00125 template <class Writer>
00126 prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::checkThrottle()
00127 {
00128     if (handle_.valid())
00129         input.unthrottle();
00130     else
00131         input.throttle();
00132 }
00133 
00134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00135 #undef prefix_
00136 
00137 
00138 // Local Variables:
00139 // mode: c++
00140 // fill-column: 100
00141 // comment-column: 40
00142 // c-file-style: "senf"
00143 // indent-tabs-mode: nil
00144 // ispell-local-dictionary: "american"
00145 // compile-command: "scons -u test"
00146 // End:

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