![]() |
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_PROCESSOR_HPP 00029 #define WNS_LDK_PROCESSOR_HPP 00030 00031 #include <WNS/ldk/FunctionalUnit.hpp> 00032 #include <WNS/ldk/Receptor.hpp> 00033 00034 namespace wns { namespace ldk { 00035 00048 struct ProcessorInterface : 00049 virtual public FunctionalUnit 00050 { 00057 virtual void processIncoming(const CompoundPtr& compound) = 0; 00058 00064 virtual void processOutgoing(const CompoundPtr&) = 0; 00065 }; 00066 00067 00074 template <typename USER> 00075 class Processor : 00076 public virtual FunctionalUnit, 00077 public virtual ProcessorInterface 00078 { 00079 public: 00080 Processor() : 00081 inWakeup(false) 00082 {} 00083 00084 virtual void 00085 doSendData(const CompoundPtr& compound) 00086 { 00087 processOutgoing(compound); 00088 00089 getConnector()->getAcceptor(compound)->sendData(compound); 00090 } // doSendData 00091 00092 00093 virtual void 00094 doOnData(const CompoundPtr& compound) 00095 { 00096 processIncoming(compound); 00097 00098 if(getDeliverer()->size()) 00099 getDeliverer()->getAcceptor(compound)->onData(compound); 00100 } // doOnData 00101 00102 00103 protected: 00104 virtual bool 00105 doIsAccepting(const CompoundPtr& compound) const 00106 { 00107 return getConnector()->hasAcceptor(compound); 00108 } // isAccepting 00109 00110 private: 00111 00112 virtual void 00113 doWakeup() 00114 { 00115 if (!inWakeup) 00116 { 00117 inWakeup = true; 00118 getReceptor()->wakeup(); 00119 inWakeup = false; 00120 } 00121 } // wakeup 00122 00123 bool inWakeup; 00124 }; 00125 }} 00126 00127 00128 #endif // NOT defined WNS_LDK_PROCESSOR_HPP 00129 00130
1.5.5