4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
30 \brief QueueingSocketSink non-inline non-template implementation */
32 #include "QueueingSocketSink.hh"
33 //#include "QueueingSocketSink.ih"
36 #include <senf/Utils/Console/Variables.hh>
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 SENF_PPI_REGISTER_QALGORITHM( "FIFOQueueingAlgorithm", senf::ppi::FIFOQueueingAlgorithm);
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // senf::ppi::QueueingAlgorithm
46 prefix_ senf::ppi::QueueingAlgorithm::QueueingAlgorithm()
49 namespace fty = console::factory;
50 dir_.add("size", fty::Command( &QueueingAlgorithm::size, this));
51 dir_.add("clear", fty::Command( &QueueingAlgorithm::clear, this));
54 prefix_ senf::console::DirectoryNode & senf::ppi::QueueingAlgorithm::consoleDir()
59 //-/////////////////////////////////////////////////////////////////////////////////////////////////
60 // senf::ppi::QueueingAlgorithmRegistry
62 prefix_ void senf::ppi::QueueingAlgorithmRegistry::dump(std::ostream & os)
65 for (QAlgoMap::const_iterator i = qAlgoMap_.begin(); i != qAlgoMap_.end(); ++i) {
66 os << i->first << std::endl;
70 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::QueueingAlgorithmRegistry::createQAlgorithm(std::string const & key)
73 QAlgoMap::const_iterator i (qAlgoMap_.find( key));
74 if (i != qAlgoMap_.end())
75 return i->second->create();
77 throw Exception("QueueingAlgorithm not registered: ") << key;
80 //-/////////////////////////////////////////////////////////////////////////////////////////////////
81 // senf::ppi::FIFOQueueingAlgorithm
83 prefix_ senf::ppi::FIFOQueueingAlgorithm::FIFOQueueingAlgorithm()
86 consoleDir().add("max-size", console::factory::Variable(max_size_) );
89 prefix_ senf::Packet senf::ppi::FIFOQueueingAlgorithm::v_dequeue()
91 if (queue_.size() > 0) {
92 Packet p (queue_.front());
99 prefix_ bool senf::ppi::FIFOQueueingAlgorithm::v_enqueue(Packet const & packet)
101 if (queue_.size() >= max_size_)
103 queue_.push( packet);
107 prefix_ void senf::ppi::FIFOQueueingAlgorithm::v_clear()
109 while (! queue_.empty())
113 prefix_ senf::ppi::QueueingAlgorithm::ptr senf::ppi::FIFOQueueingAlgorithm::create()
115 return new FIFOQueueingAlgorithm();
118 //-/////////////////////////////////////////////////////////////////////////////////////////////////