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.
25 \brief QueueingSocketSink non-inline non-template implementation */
27 #include "QueueingSocketSink.hh"
28 //#include "QueueingSocketSink.ih"
33 ///////////////////////////////cc.p////////////////////////////////////////
35 SENF_PPI_REGISTER_QALGORITHM( "FIFOQueueingAlgorithm", senf::ppi::FIFOQueueingAlgorithm);
37 ///////////////////////////////////////////////////////////////////////////
38 // senf::ppi::QueueingAlgorithm
40 prefix_ senf::ppi::QueueingAlgorithm::QueueingAlgorithm()
43 namespace fty = console::factory;
44 dir_.add("size", fty::Command( &QueueingAlgorithm::size, this));
45 dir_.add("clear", fty::Command( &QueueingAlgorithm::clear, this));
48 prefix_ senf::console::DirectoryNode & senf::ppi::QueueingAlgorithm::consoleDir()
53 /////////////////////////////////////////////////////////////////////////////
54 // senf::ppi::QueueingAlgorithmRegistry
56 prefix_ void senf::ppi::QueueingAlgorithmRegistry::dump(std::ostream & os)
59 for (QAlgoMap::const_iterator i = qAlgoMap_.begin(); i != qAlgoMap_.end(); ++i) {
60 os << i->first << std::endl;
64 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::QueueingAlgorithmRegistry::createQAlgorithm(std::string const & key)
67 QAlgoMap::const_iterator i (qAlgoMap_.find( key));
68 if (i != qAlgoMap_.end())
69 return i->second->create();
71 throw Exception("QueueingAlgorithm not registered: ") << key;
74 ///////////////////////////////////////////////////////////////////////////
75 // senf::ppi::FIFOQueueingAlgorithm
77 prefix_ senf::ppi::FIFOQueueingAlgorithm::FIFOQueueingAlgorithm()
80 consoleDir().add("max-size", console::factory::Variable(max_size_) );
83 prefix_ senf::Packet senf::ppi::FIFOQueueingAlgorithm::v_dequeue()
85 if (queue_.size() > 0) {
86 Packet p (queue_.front());
93 prefix_ bool senf::ppi::FIFOQueueingAlgorithm::v_enqueue(Packet const & packet)
95 if (queue_.size() >= max_size_)
101 prefix_ void senf::ppi::FIFOQueueingAlgorithm::v_clear()
103 while (! queue_.empty())
107 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::FIFOQueueingAlgorithm::create()
109 return new FIFOQueueingAlgorithm();
112 ///////////////////////////////cc.e////////////////////////////////////////