![]() |
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_TOOLS_CONSUMER_HPP 00029 #define WNS_LDK_TOOLS_CONSUMER_HPP 00030 00031 #include <WNS/ldk/CommandTypeSpecifier.hpp> 00032 #include <WNS/ldk/HasReceptor.hpp> 00033 #include <WNS/ldk/HasConnector.hpp> 00034 #include <WNS/ldk/HasDeliverer.hpp> 00035 #include <WNS/ldk/Forwarding.hpp> 00036 00037 #include <WNS/pyconfig/View.hpp> 00038 00039 #include <list> 00040 00041 namespace wns { namespace ldk { namespace tools { 00042 00051 class Consumer : 00052 public virtual FunctionalUnit, 00053 public CommandTypeSpecifier<>, 00054 public HasReceptor<>, 00055 public HasConnector<>, 00056 public HasDeliverer<>, 00057 public Cloneable<Consumer> 00058 { 00059 public: 00060 typedef std::list<CompoundPtr> ContainerType; 00061 00062 Consumer(fun::FUN* fuNet, bool _incoming = false, bool _outgoing = false) : 00063 CommandTypeSpecifier<>(fuNet), 00064 HasReceptor<>(), 00065 HasConnector<>(), 00066 HasDeliverer<>(), 00067 Cloneable<Consumer>(), 00068 00069 incoming(_incoming), 00070 outgoing(_outgoing) 00071 {} 00072 00073 Consumer(fun::FUN*, const wns::pyconfig::View&); 00074 00079 void 00080 consumeIncoming(bool choice = true) 00081 { 00082 incoming = choice; 00083 } // consumeIncoming 00084 00085 00090 void 00091 consumeOutgoing(bool choice = true) 00092 { 00093 outgoing = choice; 00094 } // consumeOutgoing 00095 00096 virtual void 00097 doSendData(const CompoundPtr& compound) 00098 { 00099 if(outgoing) { 00100 return; 00101 } 00102 00103 getConnector()->getAcceptor(compound)->sendData(compound); 00104 } // doSendData 00105 00106 00107 virtual void 00108 doOnData(const CompoundPtr& compound) 00109 { 00110 if(incoming) { 00111 return; 00112 } 00113 00114 getDeliverer()->getAcceptor(compound)->onData(compound); 00115 } // doOnData 00116 00117 private: 00118 00119 // 00120 // compound handler interface 00121 // 00122 virtual bool 00123 doIsAccepting(const CompoundPtr& compound) const 00124 { 00125 if(outgoing) 00126 return true; 00127 00128 return getConnector()->hasAcceptor(compound); 00129 } // isAccepting 00130 00131 virtual void 00132 doWakeup() 00133 { 00134 getReceptor()->wakeup(); 00135 } // wakeup 00136 00137 bool incoming; 00138 bool outgoing; 00139 }; 00140 00141 }}} 00142 00143 00144 #endif // NOT defined WNS_LDK_TOOLS_CONSUMER_HPP 00145 00146
1.5.5