![]() |
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-2009 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * email: info@openwns.org 00009 * www: http://www.openwns.org 00010 * _____________________________________________________________________________ 00011 * 00012 * openWNS is free software; you can redistribute it and/or modify it under the 00013 * terms of the GNU Lesser General Public License version 2 as published by the 00014 * Free Software Foundation; 00015 * 00016 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00018 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00019 * details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 * 00024 ******************************************************************************/ 00025 00030 #ifndef WIMAC_RELAYMAPPER_HPP 00031 #define WIMAC_RELAYMAPPER_HPP 00032 00033 #include <WNS/ldk/ldk.hpp> 00034 #include <WNS/Cloneable.hpp> 00035 #include <WNS/ldk/HasDeliverer.hpp> 00036 #include <WNS/ldk/HasConnector.hpp> 00037 #include <WNS/ldk/HasReceptor.hpp> 00038 #include <WNS/ldk/Processor.hpp> 00039 #include <WNS/ldk/FunctionalUnit.hpp> 00040 #include <WNS/ldk/Command.hpp> 00041 #include <WNS/ldk/CommandTypeSpecifier.hpp> 00042 #include <WIMAC/ConnectionIdentifier.hpp> 00043 00044 namespace wimac { 00045 00046 namespace service { 00047 class ConnectionManager; 00048 } 00049 00050 class ConnectionClassifier; 00051 class ACKSwitch; 00052 namespace relay { 00053 00054 00055 class RelayMapperCommand : 00056 public wns::ldk::Command 00057 { 00058 public: 00065 enum Direction { 00066 Down, 00067 Up 00068 }; 00069 struct {} local; 00070 struct { 00071 int direction_; 00072 } peer; 00073 struct {} magic; 00074 }; 00075 00080 class RelayMapper : 00081 public virtual wns::ldk::ProcessorInterface, 00082 public wns::ldk::CommandTypeSpecifier<RelayMapperCommand> 00083 { 00084 public: 00085 RelayMapper( wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config ); 00086 00087 }; 00088 00092 class BSRelayMapper : 00093 public RelayMapper, 00094 public wns::ldk::HasConnector<>, 00095 public wns::ldk::HasReceptor<>, 00096 public wns::ldk::HasDeliverer<>, 00097 public wns::ldk::Processor<BSRelayMapper>, 00098 public wns::Cloneable<BSRelayMapper> 00099 { 00100 public: 00101 BSRelayMapper( wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config ); 00102 00103 void onFUNCreated() {} 00104 00108 void processIncoming( const wns::ldk::CompoundPtr& ) {} 00109 00113 void processOutgoing( const wns::ldk::CompoundPtr& ); 00114 }; 00115 00119 class RSRelayMapper : 00120 public RelayMapper, 00121 public wns::ldk::HasConnector<>, 00122 public wns::ldk::HasReceptor<>, 00123 public wns::ldk::HasDeliverer<>, 00124 public wns::ldk::Processor<RSRelayMapper>, 00125 public wns::Cloneable<RSRelayMapper> 00126 { 00127 public: 00128 RSRelayMapper( wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config ); 00129 00130 void onFUNCreated(); 00131 00135 void processIncoming( const wns::ldk::CompoundPtr& compound ); 00136 00140 void processOutgoing( const wns::ldk::CompoundPtr& ); 00141 00145 class RelayMapping 00146 { 00147 public: 00148 RelayMapping(): upperConnection_(0), lowerConnection_(0) {} 00149 00150 RelayMapping( ConnectionIdentifier::CID upperConnection, 00151 ConnectionIdentifier::CID lowerConnection ) : 00152 upperConnection_(upperConnection), 00153 lowerConnection_(lowerConnection){} 00154 00155 bool operator==( const RelayMapping& rhs ) const; 00156 bool operator!=( const RelayMapping& rhs ) const 00157 { 00158 return !operator==( rhs ); 00159 } 00160 private: 00161 ConnectionIdentifier::CID upperConnection_; 00162 ConnectionIdentifier::CID lowerConnection_; 00163 00164 friend class RSRelayMapper; 00165 }; 00166 00167 private: 00168 wns::ldk::FunctionalUnit* downRelayInject_; 00169 wns::ldk::FunctionalUnit* upRelayInject_; 00170 wimac::ConnectionClassifier* classifier_; 00171 service::ConnectionManager* connectionManager_; 00172 wimac::ACKSwitch* ackSwitch_; 00173 00177 wns::ldk::FunctionalUnit* copyThreshold_; 00178 std::string copyThresholdName_; 00179 00180 public: 00181 RelayMapping findMapping( const ConnectionIdentifier::CID& id ) const; 00182 00183 void addMapping( const RelayMapping& mapping ); 00184 00185 private: 00186 typedef std::list<RelayMapping> Mappings; 00187 Mappings mappings_; 00188 }; 00189 00190 class SSRelayMapper : 00191 public RelayMapper, 00192 public wns::ldk::HasConnector<>, 00193 public wns::ldk::HasReceptor<>, 00194 public wns::ldk::HasDeliverer<>, 00195 public wns::ldk::Processor<SSRelayMapper>, 00196 public wns::Cloneable<SSRelayMapper> 00197 { 00198 public: 00199 SSRelayMapper( wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config ); 00200 00201 void onFUNCreated(){} 00202 00206 void processIncoming( const wns::ldk::CompoundPtr& ) {} 00207 00211 void processOutgoing( const wns::ldk::CompoundPtr& ); 00212 }; 00213 } 00214 } 00215 #endif 00216 00217
1.5.5