4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief QueueingSocketSink public header */
26 #ifndef HH_SENF_PPI_QueueingSocketSink_
27 #define HH_SENF_PPI_QueueingSocketSink_ 1
31 #include "SocketSink.hh"
33 //#include "QueueingSocketSink.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
39 template <typename PacketType=Packet>
40 class QueueingAlgorithm
43 virtual ~QueueingAlgorithm() {};
44 virtual PacketType dequeue() = 0;
45 virtual bool enqueue(PacketType const & packet) = 0;
46 virtual unsigned size() const = 0;
47 virtual void clear() = 0;
50 template <typename PacketType=Packet>
51 class FIFOQueueingAlgorithm : public QueueingAlgorithm<PacketType>
54 FIFOQueueingAlgorithm(unsigned size);
56 virtual PacketType dequeue();
57 virtual bool enqueue(PacketType const & packet);
58 virtual unsigned size() const;
62 std::queue<PacketType> queue_;
69 /** \brief QueueingSocketSink
73 template <class Writer=ConnectedDgramWriter>
74 class PassiveQueueingSocketSink : public Module
76 SENF_PPI_MODULE(PassiveQueueingSocketSink);
79 typedef typename Writer::Handle Handle; ///< Handle type requested by writer
80 typedef typename Writer::PacketType PacketType;
82 connector::PassiveInput<PacketType> input; ///< Input connector from which data is received
84 template <class QAlgorithm>
85 explicit PassiveQueueingSocketSink(Handle handle, QAlgorithm const & qAlgorithm);
87 Writer & writer(); ///< Access the Writer
88 Handle & handle(); ///< Access handle
89 void handle(Handle handle); ///< Set handle
90 /**< Assigning an empty or in-valid() handle will disable
91 the module until a new valid handle is assigned. */
92 QueueingAlgorithm<PacketType> & qAlgorithm();
101 boost::scoped_ptr<QueueingAlgorithm<PacketType> > qAlgo_;
107 ///////////////////////////////hh.e////////////////////////////////////////
108 //#include "QueueingSocketSink.cci"
109 #include "QueueingSocketSink.ct"
110 #include "QueueingSocketSink.cti"
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40