User Manual, Developers Guide and API Documentation

PhyModeInterface.hpp

Go to the documentation of this file.
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_SERVICE_PHY_PHYMODE_PHYMODEINTERFACE_HPP
00029 #define WNS_SERVICE_PHY_PHYMODE_PHYMODEINTERFACE_HPP
00030 
00031 #include <WNS/pyconfig/View.hpp>
00032 #include <WNS/StaticFactory.hpp>
00033 #include <WNS/IOutputStreamable.hpp>
00034 #include <WNS/PyConfigViewCreator.hpp>
00035 #include <WNS/RefCountable.hpp>
00036 #include <WNS/Cloneable.hpp>
00037 #include <WNS/SmartPtr.hpp>
00038 #include <WNS/PowerRatio.hpp>
00039 #include <WNS/simulator/Time.hpp>
00040 
00041 #include <string>
00042 
00043 namespace wns { namespace service { namespace phy { namespace phymode {
00044 
00045         typedef unsigned int Modulation;
00046         typedef unsigned int Coding;
00047 
00052         class PhyModeInterface :
00053             public virtual wns::IOutputStreamable,
00054             public virtual wns::RefCountable,
00055             public virtual wns::CloneableInterface
00056         {
00057         public:
00058             virtual ~PhyModeInterface() {}
00059 
00061             virtual bool isValid() const = 0;
00062 
00064             virtual bool dataRateIsValid() const = 0;
00065 
00067             friend bool operator== ( const PhyModeInterface& p1, const PhyModeInterface& p2 )
00068             { return (p1.toInt() == p2.toInt()); }
00069             friend bool operator!= ( const PhyModeInterface& p1, const PhyModeInterface& p2 )
00070             { return !(p1==p2); }
00071 
00076             friend bool operator< ( const PhyModeInterface& p1, const PhyModeInterface& p2 )
00077             { return (p1.toInt() < p2.toInt()); }
00078             //{ return (this->getBitsPerSymbol() < right.getBitsPerSymbol()); } // other semantic
00079             friend bool operator> ( const PhyModeInterface& p1, const PhyModeInterface& p2 )
00080             { return !(p1<p2); }
00081 
00083             friend bool PhyModeIsBetter( const PhyModeInterface& p1, const PhyModeInterface& p2 )
00084             { return (p1.getBitsPerSymbol()>p2.getBitsPerSymbol()); }
00085 
00087             virtual unsigned int
00088             getBitCapacityFractional(wns::simulator::Time duration) const = 0;
00089 
00092             virtual double getDataRate() const = 0;
00093 
00095             virtual double getSINR2MI(const wns::Ratio& sinr) const = 0;
00097             virtual double getSINR2MIB(const wns::Ratio& sinr) const = 0;
00099             virtual double getMI2PER(const double mib, unsigned int bits) const = 0;
00101             virtual double getSINR2PER(const wns::Ratio& sinr, unsigned int bits) const = 0;
00103             virtual wns::Ratio getMIB2SINR(const double& mib) const = 0;
00104 
00106             virtual std::string getString() const = 0;
00107 
00109             virtual bool nameMatches(const std::string& name) const = 0;
00110 
00112             virtual Modulation getModulation() const = 0;
00113 
00115             virtual Coding getCoding() const = 0;
00116 
00118             virtual double getBitsPerSymbol() const = 0;
00119 
00120         private:
00122             virtual unsigned int toInt() const = 0;
00123         };
00124 
00128         typedef wns::SmartPtr<const wns::service::phy::phymode::PhyModeInterface> PhyModeInterfacePtr;
00133         typedef const wns::service::phy::phymode::PhyModeInterface& PhyModeInterfaceConstRef;
00134 
00135         typedef wns::PyConfigViewCreator<PhyModeInterface, PhyModeInterface> PhyModeCreator;
00136         typedef wns::StaticFactory<PhyModeCreator> PhyModeFactory;
00137 
00139         inline PhyModeInterface*
00140         createPhyModeNonConst(const wns::pyconfig::View& config)
00141         {
00142             std::string nameInPhyModeFactory = config.get<std::string>("nameInPhyModeFactory");
00143             return PhyModeFactory::creator(nameInPhyModeFactory)->create(config);
00144         }
00145 
00147         inline PhyModeInterfacePtr
00148         createPhyMode(const wns::pyconfig::View& config)
00149         {
00150             std::string nameInPhyModeFactory = config.get<std::string>("nameInPhyModeFactory");
00151             return PhyModeInterfacePtr(PhyModeFactory::creator(nameInPhyModeFactory)->create(config));
00152         }
00153 
00155         inline const PhyModeInterface&
00156         emptyPhyMode()
00157         {
00158             typedef wns::Creator<PhyModeInterface> DefaultPhyModeCreator;
00159             typedef wns::StaticFactory<DefaultPhyModeCreator> DefaultPhyModeFactory;
00160             // done only once for the whole simulation:
00161             static const PhyModeInterface* empty = DefaultPhyModeFactory::creator("rise.PhyMode.Empty")->create();
00162             return *empty;
00163         }
00164 
00166         inline PhyModeInterfacePtr
00167         emptyPhyModePtr()
00168         {
00169             typedef wns::Creator<PhyModeInterface> DefaultPhyModeCreator;
00170             typedef wns::StaticFactory<DefaultPhyModeCreator> DefaultPhyModeFactory;
00171             // done only once for the whole simulation:
00172             static PhyModeInterface* empty = DefaultPhyModeFactory::creator("rise.PhyMode.Empty")->create();
00173             static PhyModeInterfacePtr emptyPtr = PhyModeInterfacePtr(empty);
00174             return emptyPtr;
00175         }
00176 
00177 } // phymode
00178 } // phy
00179 } // service
00180 } // wns
00181 
00182 namespace wns {
00183   // for convenience: wns::PhyModePtr
00184   typedef wns::service::phy::phymode::PhyModeInterfacePtr PhyModePtr;
00185 }
00186 
00187 #endif // WNS_SERVICE_PHY_PHYMODE_PHYMODEINTERFACE_HPP

Generated on Fri May 25 03:31:56 2012 for openWNS by  doxygen 1.5.5