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"
31 #include <senf/Utils/Console/Variables.hh>
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 SENF_PPI_REGISTER_QALGORITHM( "FIFOQueueingAlgorithm", senf::ppi::FIFOQueueingAlgorithm);
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::ppi::QueueingAlgorithm
41 prefix_ senf::ppi::QueueingAlgorithm::QueueingAlgorithm()
44 namespace fty = console::factory;
45 dir_.add("size", fty::Command( &QueueingAlgorithm::size, this));
46 dir_.add("clear", fty::Command( &QueueingAlgorithm::clear, this));
49 prefix_ senf::console::DirectoryNode & senf::ppi::QueueingAlgorithm::consoleDir()
54 //-/////////////////////////////////////////////////////////////////////////////////////////////////
55 // senf::ppi::QueueingAlgorithmRegistry
57 prefix_ void senf::ppi::QueueingAlgorithmRegistry::dump(std::ostream & os)
60 for (QAlgoMap::const_iterator i = qAlgoMap_.begin(); i != qAlgoMap_.end(); ++i) {
61 os << i->first << std::endl;
65 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::QueueingAlgorithmRegistry::createQAlgorithm(std::string const & key)
68 QAlgoMap::const_iterator i (qAlgoMap_.find( key));
69 if (i != qAlgoMap_.end())
70 return i->second->create();
72 throw Exception("QueueingAlgorithm not registered: ") << key;
75 //-/////////////////////////////////////////////////////////////////////////////////////////////////
76 // senf::ppi::FIFOQueueingAlgorithm
78 prefix_ senf::ppi::FIFOQueueingAlgorithm::FIFOQueueingAlgorithm()
81 consoleDir().add("max-size", console::factory::Variable(max_size_) );
84 prefix_ senf::Packet senf::ppi::FIFOQueueingAlgorithm::v_dequeue()
86 if (queue_.size() > 0) {
87 Packet p (queue_.front());
94 prefix_ bool senf::ppi::FIFOQueueingAlgorithm::v_enqueue(Packet const & packet)
96 if (queue_.size() >= max_size_)
102 prefix_ void senf::ppi::FIFOQueueingAlgorithm::v_clear()
104 while (! queue_.empty())
108 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::FIFOQueueingAlgorithm::create()
110 return new FIFOQueueingAlgorithm();
113 //-/////////////////////////////////////////////////////////////////////////////////////////////////