![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WNS (Wireless Network Simulator) * 00003 * __________________________________________________________________________ * 00004 * * 00005 * Copyright (C) 2004-2008 * 00006 * Chair of Communication Networks (ComNets) * 00007 * Kopernikusstr. 1, D-52074 Aachen, Germany * 00008 * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242 * 00009 * email: wns@comnets.rwth-aachen.de * 00010 * www: http://wns.comnets.rwth-aachen.de * 00011 ******************************************************************************/ 00012 00013 #ifndef WNS_LDK_HASRECEPTORRECEPTACLE_HPP 00014 #define WNS_LDK_HASRECEPTORRECEPTACLE_HPP 00015 00016 #include <WNS/ldk/IReceptorReceptacle.hpp> 00017 #include <WNS/ldk/ReceptorReceptacleRegistry.hpp> 00018 #include <WNS/ldk/LinkHandlerInterface.hpp> 00019 #include <WNS/ldk/SinglePort.hpp> 00020 #include <WNS/ldk/Port.hpp> 00021 #include <WNS/ldk/fun/FUN.hpp> 00022 #include <WNS/ldk/CommandTypeSpecifierInterface.hpp> 00023 00024 #include <WNS/Assure.hpp> 00025 00026 #include <string> 00027 00028 namespace wns { namespace ldk { 00029 00030 template <typename CLASS, typename PORTID = SinglePort> 00031 class HasReceptorReceptacle 00032 : public virtual ReceptorReceptacleRegistry 00033 { 00034 public: 00035 HasReceptorReceptacle(CLASS* fu) 00036 : ReceptorReceptacleRegistry(), 00037 receptorReceptacle_(new ReceptorReceptacle(fu)) 00038 { 00039 addToReceptorReceptacleRegistry(PORTID().name, receptorReceptacle_); 00040 } 00041 00042 HasReceptorReceptacle(const HasReceptorReceptacle&) 00043 { 00044 wns::Exception e; 00045 e << "The copy constructor of class HasReceptorReceptacle must not be called!"; 00046 throw e; 00047 } 00048 00049 virtual 00050 ~HasReceptorReceptacle() 00051 { 00052 delete receptorReceptacle_; 00053 } 00054 00055 class ReceptorReceptacle 00056 : public virtual IReceptorReceptacle 00057 { 00058 public: 00059 ReceptorReceptacle(CLASS* fu) 00060 : fu_(fu) 00061 {} 00062 00063 virtual 00064 ~ReceptorReceptacle() 00065 {} 00066 00067 virtual void 00068 wakeup() 00069 { 00070 fu_->getFUN()->getLinkHandler()->wakeup(this); 00071 } 00072 00073 virtual void 00074 doWakeup() 00075 { 00076 fu_->doWakeup(Port<PORTID>()); 00077 } 00078 00079 virtual FunctionalUnit* 00080 getFU() 00081 { 00082 return fu_; 00083 } 00084 00085 private: 00086 CLASS* fu_; 00087 }; 00088 00089 private: 00090 HasReceptorReceptacle() 00091 {} 00092 00093 ReceptorReceptacle* receptorReceptacle_; 00094 }; 00095 00096 00097 template <typename CLASS> 00098 class HasReceptorReceptacle<CLASS, SinglePort> 00099 : public virtual IReceptorReceptacle, 00100 public virtual ReceptorReceptacleRegistry, 00101 public virtual CommandTypeSpecifierInterface 00102 { 00103 public: 00104 HasReceptorReceptacle() 00105 : ReceptorReceptacleRegistry() 00106 { 00107 addToReceptorReceptacleRegistry(SinglePort().name, this); 00108 } 00109 00110 HasReceptorReceptacle(FunctionalUnit*) 00111 : ReceptorReceptacleRegistry() 00112 { 00113 addToReceptorReceptacleRegistry(SinglePort().name, this); 00114 } 00115 00116 HasReceptorReceptacle(const HasReceptorReceptacle&) 00117 : ReceptorReceptacleRegistry() 00118 { 00119 addToReceptorReceptacleRegistry(SinglePort().name, this); 00120 } 00121 00122 virtual 00123 ~HasReceptorReceptacle() 00124 {} 00125 00126 virtual void 00127 wakeup() 00128 { 00129 getFUN()->getLinkHandler()->wakeup(this); 00130 } 00131 00132 virtual FunctionalUnit* 00133 getFU() 00134 { 00135 return dynamic_cast<CLASS*>(this); 00136 } 00137 }; 00138 00139 00140 } // ldk 00141 } // wns 00142 00143 #endif // NOT defined WNS_LDK_HASRECEPTORRECEPTACLE_HPP
1.5.5