X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPPI%2FSocketSource.hh;h=51ffa01c373b5f877c5b1b8094ece39cb023db6e;hb=ab7ff164ab5ae711ec09ce2b24228510f1ffdcff;hp=9000ed616789884a3fd8ff7f6b30cd67455d3d7f;hpb=26610f603ebdd465307b9621f532c1fe19fd5571;p=senf.git diff --git a/senf/PPI/SocketSource.hh b/senf/PPI/SocketSource.hh index 9000ed6..51ffa01 100644 --- a/senf/PPI/SocketSource.hh +++ b/senf/PPI/SocketSource.hh @@ -2,23 +2,28 @@ // // 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 -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// The contents of this file are subject to the Fraunhofer FOKUS Public License +// Version 1.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// http://senf.berlios.de/license.html // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// The Fraunhofer FOKUS Public License Version 1.0 is based on, +// but modifies the Mozilla Public License Version 1.1. +// See the full license text for the amendments. // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +// for the specific language governing rights and limitations under the License. +// +// The Original Code is Fraunhofer FOKUS code. +// +// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. +// (registered association), Hansastraße 27 c, 80686 Munich, Germany. +// All Rights Reserved. +// +// Contributor(s): +// Stefan Bund /** \file \brief SocketSource public header */ @@ -37,7 +42,7 @@ #include "IOEvent.hh" //#include "SocketSource.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { namespace ppi { @@ -46,7 +51,7 @@ namespace ppi { This read helper will read a datagram from a datagram socket. This datagram will then be interpreted as a packet of type \a Packet as defined in the packet library. \a Packet - defaults to DataPacket (type DataPacketType), which will place the data uninterpreted + defaults to DataPacket (type DataPacketType), which will place the data uninterpreted into a packet data structure. */ template @@ -59,7 +64,7 @@ namespace ppi { senf::DatagramFramingPolicy >::policy > Handle; ///< Handle type supported by this reader - Packet operator()(Handle handle); + Packet operator()(Handle & handle); ///< Read packet from \a handle /**< Read a datagram from \a handle and interpret is as packet of type \c Packet. @@ -105,7 +110,7 @@ namespace module { \ingroup io_modules */ template > - class ActiveSocketSource + class ActiveSocketSource : public Module { SENF_PPI_MODULE(ActiveSocketSource); @@ -113,21 +118,22 @@ namespace module { public: typedef typename Reader::Handle Handle; ///< Handle type requested by the reader - connector::ActiveOutput output; + connector::ActiveOutput output; ///< Output connector to which the data received is written - + ActiveSocketSource(); ///< Create non-connected reader /**< The reader will be disabled until a socket is set \pre Requires \a Reader to be default constructible */ explicit ActiveSocketSource(Reader reader); ///< Create non-connected reader /**< The reader will be disabled until a socket is set \pre Requires \a Reader to be copy constructible */ - explicit ActiveSocketSource(Handle handle); ///< Create new reader for the given handle + explicit ActiveSocketSource(Handle const & handle); + ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. \pre Requires \a Reader to be default constructible \param[in] handle Handle to read data from */ - ActiveSocketSource(Handle handle, Reader reader); + ActiveSocketSource(Handle const & handle, Reader reader); ///< Create new reader for the given handle /**< Data will be read from \a handle and be parsed by \a Reader. @@ -136,21 +142,58 @@ namespace module { Reader & reader(); ///< Access Reader helper Handle handle(); ///< Access handle - void handle(Handle handle); ///< Set handle + void handle(Handle const & handle); + ///< Set handle /**< Assigning an empty or in-valid() handle will disable the module until a new, valid handle is assigned. */ - private: + Handle handle_; + IOEvent event_; + Reader reader_; + void read(); - + }; + + + template > + class ActiveBurstSocketSource + : public Module + { + SENF_PPI_MODULE(ActiveBurstSocketSource); + + public: + typedef typename Reader::Handle Handle; ///< Handle type requested by the reader + + connector::ActiveOutput output; + ///< Output connector to which the data received is written + + ActiveBurstSocketSource(unsigned max_burst=0); + explicit ActiveBurstSocketSource(Reader reader, unsigned max_burst=0); + explicit ActiveBurstSocketSource(Handle const & handle, unsigned max_burst=0); + ActiveBurstSocketSource(Handle const & handle, Reader reader, unsigned max_burst=0); + + Reader & reader(); ///< Access Reader helper + Handle handle(); ///< Access handle + void handle(Handle const & handle); + ///< Set handle + /**< Assigning an empty or in-valid() handle will disable + the module until a new, valid handle is assigned. */ + + unsigned maxBurst() const; + void maxBurst(unsigned max_burst); + + private: Handle handle_; IOEvent event_; Reader reader_; + unsigned maxBurst_; + + void read(); }; }}} -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "SocketSource.cci" #include "SocketSource.ct" #include "SocketSource.cti"