![]() |
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_STUB_HPP 00029 #define WNS_LDK_TOOLS_STUB_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/Command.hpp> 00036 00037 #include <WNS/Cloneable.hpp> 00038 #include <WNS/pyconfig/View.hpp> 00039 00040 #include <deque> 00041 00042 00043 namespace wns { namespace ldk { namespace tools { 00044 00051 class StubCommand : 00052 public wns::ldk::Command 00053 { 00054 public: 00055 StubCommand() 00056 { 00057 // initialize to something invalid 00058 this->magic.sendDataTime = -1.0; 00059 // initialize to something invalid 00060 this->magic.onDataTime = -1.0; 00061 this->magic.sequenceNumber = 0; 00062 } 00063 00064 struct { 00065 } local; 00066 00067 struct { 00068 } peer; 00069 00070 struct { 00071 // when has sendData been called? 00072 simTimeType sendDataTime; 00073 // when has onData been called? 00074 simTimeType onDataTime; 00075 int sequenceNumber; 00076 } magic; 00077 }; 00078 00082 class StubBase : 00083 public virtual FunctionalUnit, 00084 public HasReceptor<>, 00085 public HasConnector<>, 00086 public HasDeliverer<> 00087 { 00088 public: 00089 typedef std::deque<CompoundPtr> ContainerType; 00090 00091 virtual 00092 ~StubBase(); 00093 00097 void 00098 setStepping(bool _stepping); 00099 00103 void 00104 setSizes(Bit addToPCISize, Bit addToPDUSize); 00105 00109 void 00110 setAcceptanceSize(Bit compoundSize); 00111 00115 void 00116 flush(); 00117 00122 void 00123 open(bool wakeup = true); 00124 00129 void 00130 close(); 00131 00136 void 00137 step(); 00138 00139 virtual void 00140 calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00141 00142 virtual void 00143 onFUNCreated(); 00144 00145 bool 00146 integrityCheck(); 00147 00151 ContainerType received; 00152 00156 ContainerType sent; 00157 00161 long wakeupCalled; 00162 00166 long onFUNCreatedCalled; 00167 00168 protected: 00169 StubBase(); 00170 00171 protected: 00172 // CompoundHandlerInterface 00173 virtual void 00174 doSendData(const CompoundPtr& sdu); 00175 00176 virtual void 00177 doOnData(const CompoundPtr& compound); 00178 00179 virtual bool 00180 doIsAccepting(const CompoundPtr& compound) const; 00181 00182 virtual void 00183 doWakeup(); 00184 00185 bool stepping; 00186 bool accepting; 00187 00188 int addToPCISize; 00189 int addToPDUSize; 00190 int compoundAcceptanceSize; 00191 }; // StubBase 00192 00193 00203 class Stub : 00204 public StubBase, 00205 public CommandTypeSpecifier<StubCommand>, 00206 public Cloneable<Stub> 00207 { 00208 public: 00213 Stub(fun::FUN* fuNet, const pyconfig::View& config); 00214 00215 // we need a unique overrider 00216 virtual void 00217 calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const 00218 { 00219 StubBase::calculateSizes(commandPool, commandPoolSize, dataSize); 00220 } // calculateSizes 00221 00222 private: 00223 virtual void 00224 doSendData(const CompoundPtr& sdu); 00225 00226 virtual void 00227 doOnData(const CompoundPtr& sdu); 00228 00229 int sequenceNumber; 00230 }; // Stub 00231 00232 }}} 00233 00234 00235 #endif // NOT defined WNS_LDK_TOOLS_STUB_HPP 00236 00237
1.5.5