![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef WNS_LDK_DROPPER_HPP 00029 #define WNS_LDK_DROPPER_HPP 00030 00031 #include <WNS/ldk/FunctionalUnit.hpp> 00032 #include <WNS/ldk/Receptor.hpp> 00033 00034 namespace wns { namespace ldk { 00035 00046 struct DropperInterface : 00047 virtual public FunctionalUnit 00048 { 00053 virtual bool wouldDrop(const CompoundPtr& compound) const = 0; 00054 00061 virtual void processIncoming(const CompoundPtr& compound) = 0; 00062 00068 virtual void processOutgoing(const CompoundPtr& compound) = 0; 00069 00075 virtual void processDropping(const CompoundPtr& compound) = 0; 00076 }; 00077 00078 00085 template <typename USER> 00086 class Dropper : 00087 public virtual FunctionalUnit, 00088 public virtual DropperInterface 00089 { 00090 public: 00091 00092 virtual void 00093 doSendData(const CompoundPtr& compound) 00094 { 00095 assure(isAccepting(compound), "sendData called although the FunctionalUnit is not accepting!"); 00096 assure(getConnector()->hasAcceptor(compound), "noone accepts the PDU i accepted."); 00097 00098 if(wouldDrop(compound)) { 00099 processDropping(compound); 00100 } else { 00101 processOutgoing(compound); 00102 00103 getConnector()->getAcceptor(compound)->sendData(compound); 00104 } 00105 } // doSendData 00106 00107 00108 virtual void 00109 doOnData(const CompoundPtr& compound) 00110 { 00111 processIncoming(compound); 00112 00113 if(getDeliverer()->size()) 00114 getDeliverer()->getAcceptor(compound)->onData(compound); 00115 } // doOnData 00116 00117 00118 private: 00119 virtual bool 00120 doIsAccepting(const CompoundPtr& compound) const 00121 { 00122 return wouldDrop(compound) 00123 || getConnector()->hasAcceptor(compound); 00124 } // isAccepting 00125 00126 00127 virtual void 00128 doWakeup() 00129 { 00130 getReceptor()->wakeup(); 00131 } // wakeup 00132 }; 00133 }} 00134 00135 00136 #endif // NOT defined WNS_LDK_DROPPER_HPP 00137 00138
1.5.5