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

SocketSource.hh

Go to the documentation of this file.
00001 // $Id: SocketSource.hh 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 #ifndef HH_SENF_PPI_SocketSource_
00027 #define HH_SENF_PPI_SocketSource_ 1
00028 
00029 // Custom includes
00030 #include <senf/Packets/Packets.hh>
00031 #include <senf/Socket/ClientSocketHandle.hh>
00032 #include <senf/Socket/SocketPolicy.hh>
00033 #include <senf/Socket/ReadWritePolicy.hh>
00034 #include <senf/Socket/FramingPolicy.hh>
00035 #include "Module.hh"
00036 #include "Connectors.hh"
00037 #include "IOEvent.hh"
00038 
00039 //#include "SocketSource.mpp"
00040 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00041 
00042 namespace senf {
00043 namespace ppi {
00044 
00052     template <class Packet=DataPacket, unsigned MaxSize=0u>
00053     class DgramReader
00054     {
00055     public:
00056         typedef Packet PacketType;
00057         typedef senf::ClientSocketHandle<
00058             senf::MakeSocketPolicy< senf::ReadablePolicy,
00059                                     senf::DatagramFramingPolicy >::policy > Handle;
00061 
00062         Packet operator()(Handle & handle);
00064 
00069     };
00070 
00071 }}
00072 
00073 namespace senf {
00074 namespace ppi {
00075 namespace module {
00076 
00107     template <class Reader=DgramReader<> >
00108     class ActiveSocketSource
00109         : public Module
00110     {
00111         SENF_PPI_MODULE(ActiveSocketSource);
00112 
00113     public:
00114         typedef typename Reader::Handle Handle; 
00115 
00116         connector::ActiveOutput<typename Reader::PacketType> output;
00118 
00119         ActiveSocketSource();           
00120 
00122         explicit ActiveSocketSource(Reader reader); 
00123 
00125         explicit ActiveSocketSource(Handle const & handle);
00127 
00131         ActiveSocketSource(Handle const & handle, Reader reader);
00133 
00138         Reader & reader();              
00139         Handle handle();                
00140         void handle(Handle const & handle);
00142 
00144     private:
00145         Handle handle_;
00146         IOEvent event_;
00147         Reader reader_;
00148 
00149         void read();
00150     };
00151 
00152 
00153     template <class Reader=DgramReader<> >
00154     class ActiveBurstSocketSource
00155         : public Module
00156     {
00157         SENF_PPI_MODULE(ActiveBurstSocketSource);
00158 
00159     public:
00160         typedef typename Reader::Handle Handle; 
00161 
00162         connector::ActiveOutput<typename Reader::PacketType> output;
00164 
00165         ActiveBurstSocketSource(unsigned max_burst=0);
00166         explicit ActiveBurstSocketSource(Reader reader, unsigned max_burst=0);
00167         explicit ActiveBurstSocketSource(Handle const & handle, unsigned max_burst=0);
00168         ActiveBurstSocketSource(Handle const & handle, Reader reader, unsigned max_burst=0);
00169 
00170         Reader & reader();              
00171         Handle handle();                
00172         void handle(Handle const & handle);
00174 
00177         unsigned maxBurst() const;
00178         void maxBurst(unsigned max_burst);
00179 
00180     private:
00181         Handle handle_;
00182         IOEvent event_;
00183         Reader reader_;
00184         unsigned maxBurst_;
00185 
00186         void read();
00187     };
00188 
00189 }}}
00190 
00191 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00192 //#include "SocketSource.cci"
00193 #include "SocketSource.ct"
00194 #include "SocketSource.cti"
00195 #endif
00196 
00197 
00198 // Local Variables:
00199 // mode: c++
00200 // fill-column: 100
00201 // c-file-style: "senf"
00202 // indent-tabs-mode: nil
00203 // ispell-local-dictionary: "american"
00204 // compile-command: "scons -u test"
00205 // comment-column: 40
00206 // End:

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