![]() |
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_HASCONNECTORRECEPTACLE_HPP 00014 #define WNS_LDK_HASCONNECTORRECEPTACLE_HPP 00015 00016 #include <WNS/ldk/IConnectorReceptacle.hpp> 00017 #include <WNS/ldk/ConnectorReceptacleRegistry.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 HasConnectorReceptacle 00032 : public virtual ConnectorReceptacleRegistry 00033 { 00034 public: 00035 HasConnectorReceptacle(CLASS* fu) 00036 : ConnectorReceptacleRegistry(), 00037 connectorReceptacle_(new ConnectorReceptacle(fu)) 00038 { 00039 addToConnectorReceptacleRegistry(PORTID().name, connectorReceptacle_); 00040 } 00041 00042 HasConnectorReceptacle(const HasConnectorReceptacle&) 00043 { 00044 wns::Exception e; 00045 e << "The copy constructor of class HasConnectorReceptacle must not be called!"; 00046 throw e; 00047 } 00048 00049 virtual 00050 ~HasConnectorReceptacle() 00051 { 00052 delete connectorReceptacle_; 00053 } 00054 00055 class ConnectorReceptacle 00056 : public virtual IConnectorReceptacle 00057 { 00058 public: 00059 ConnectorReceptacle(CLASS* fu) 00060 : fu_(fu) 00061 {} 00062 00063 virtual 00064 ~ConnectorReceptacle() 00065 {} 00066 00067 virtual void 00068 sendData(const CompoundPtr& compound) 00069 { 00070 fu_->getFUN()->getLinkHandler()->sendData(this, compound); 00071 } 00072 00073 virtual void 00074 doSendData(const CompoundPtr& compound) 00075 { 00076 fu_->doSendData(compound, Port<PORTID>()); 00077 } 00078 00079 virtual bool 00080 isAccepting(const CompoundPtr& compound) 00081 { 00082 return fu_->getFUN()->getLinkHandler()->isAccepting(this, compound); 00083 } 00084 00085 virtual bool 00086 doIsAccepting(const CompoundPtr& compound) 00087 { 00088 return fu_->doIsAccepting(compound, Port<PORTID>()); 00089 } 00090 00091 virtual FunctionalUnit* 00092 getFU() 00093 { 00094 return fu_; 00095 } 00096 00097 private: 00098 CLASS* fu_; 00099 }; 00100 00101 private: 00102 HasConnectorReceptacle() 00103 {} 00104 00105 ConnectorReceptacle* connectorReceptacle_; 00106 }; 00107 00108 00109 template <typename CLASS> 00110 class HasConnectorReceptacle<CLASS, SinglePort> 00111 : public virtual IConnectorReceptacle, 00112 public virtual ConnectorReceptacleRegistry, 00113 public virtual CommandTypeSpecifierInterface 00114 { 00115 public: 00116 HasConnectorReceptacle() 00117 : ConnectorReceptacleRegistry() 00118 { 00119 addToConnectorReceptacleRegistry(SinglePort().name, this); 00120 } 00121 00122 HasConnectorReceptacle(FunctionalUnit*) 00123 : ConnectorReceptacleRegistry() 00124 { 00125 addToConnectorReceptacleRegistry(SinglePort().name, this); 00126 } 00127 00128 HasConnectorReceptacle(const HasConnectorReceptacle&) 00129 : ConnectorReceptacleRegistry() 00130 { 00131 addToConnectorReceptacleRegistry(SinglePort().name, this); 00132 } 00133 00134 virtual 00135 ~HasConnectorReceptacle() 00136 {} 00137 00138 virtual void 00139 sendData(const CompoundPtr& compound) 00140 { 00141 getFUN()->getLinkHandler()->sendData(this, compound); 00142 } 00143 00144 virtual bool 00145 isAccepting(const CompoundPtr& compound) 00146 { 00147 getFUN()->getLinkHandler()->isAccepting(this, compound); 00148 } 00149 00150 virtual FunctionalUnit* 00151 getFU() 00152 { 00153 return dynamic_cast<CLASS*>(this); 00154 } 00155 }; 00156 00157 00158 } // ldk 00159 } // wns 00160 00161 #endif // NOT defined WNS_LDK_HASCONNECTORRECEPTACLE_HPP
1.5.5