![]() |
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 RISE_SCENARIO_OBSTRUCTION_HPP 00029 #define RISE_SCENARIO_OBSTRUCTION_HPP 00030 00031 #include <WNS/geometry/LineSegment.hpp> 00032 #include <WNS/geometry/AxisParallelRectangle.hpp> 00033 #include <WNS/SmartPtr.hpp> 00034 #include <WNS/PowerRatio.hpp> 00035 #include <WNS/pyconfig/View.hpp> 00036 #include <WNS/StaticFactory.hpp> 00037 00038 #include <list> 00039 00040 namespace rise { namespace scenario { 00041 00042 class IObstruction : 00043 virtual public wns::RefCountable 00044 { 00045 public: 00046 virtual 00047 ~IObstruction() 00048 {}; 00049 00050 const wns::Ratio& 00051 getAttenuationFactor() const 00052 { 00053 return attenuation; 00054 } 00055 00056 void 00057 setAttenuationFactor(const wns::Ratio& _attenuation) 00058 { 00059 this->attenuation = _attenuation; 00060 } 00061 00062 virtual wns::Ratio 00063 getAttenuation(const wns::geometry::LineSegment& signalPath) const = 0; 00064 00065 protected: 00066 explicit 00067 IObstruction(const wns::Ratio& attenuation) : 00068 attenuation(attenuation) 00069 {} 00070 00071 wns::Ratio attenuation; 00072 }; 00073 00074 typedef std::list<IObstruction*> ObstructionList; 00075 00076 template <typename T, typename KIND = T> 00077 class IObstructionCreator: 00078 public IObstructionCreator<KIND, KIND> 00079 { 00080 public: 00081 virtual 00082 KIND* create(const wns::pyconfig::View& _config) 00083 { 00084 return new T(_config); 00085 } 00086 }; 00087 template <typename KIND> 00088 class IObstructionCreator<KIND, KIND> 00089 { 00090 public: 00091 virtual 00092 ~IObstructionCreator() {}; 00093 virtual KIND* 00094 create(const wns::pyconfig::View& _config) = 0; 00095 }; 00096 typedef IObstructionCreator<IObstruction> ObstructionCreator; 00097 typedef wns::StaticFactory<ObstructionCreator> ObstructionFactory; 00098 00099 00100 00101 template<class SHAPE> 00102 class Obstructing : 00103 public IObstruction, 00104 public SHAPE 00105 { 00106 public: 00107 Obstructing(const wns::pyconfig::View& config): 00108 IObstruction(config.get<wns::Ratio>("attenuation")), 00109 SHAPE(config) 00110 {} 00111 00112 Obstructing(const SHAPE& shape, const wns::Ratio& attenuation) : 00113 IObstruction(attenuation), 00114 SHAPE(shape) 00115 {} 00116 00117 virtual wns::Ratio 00118 getAttenuation(const wns::geometry::LineSegment& signalPath) const 00119 { 00120 return wns::Ratio::from_dB( 00121 SHAPE::countBorderIntersections(signalPath) * attenuation.get_dB()); 00122 00123 } 00124 }; 00125 00126 } // scenario 00127 } // rise 00128 00129 #endif // NOT defined RISE_SCENARIO_OBSTRUCTION_HPP
1.5.5