User Manual, Developers Guide and API Documentation

Kernel.cpp

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 #include <RISE/antenna/pattern/kernel/Kernel.hpp>
00029 #include <RISE/antenna/pattern/kernel/TwoDimensional.hpp>
00030 #include <RISE/antenna/pattern/kernel/ThreeDimensional.hpp>
00031 #include <RISE/antenna/pattern/kernel/Planet.hpp>
00032 #include <RISE/RISE.hpp>
00033 
00034 using namespace rise::antenna::pattern::kernel;
00035 
00036 Kernel::Kernel()
00037     : type(""),
00038       pattern(""),
00039       log("PatternKernel"),
00040       pd_gain()
00041 
00042 {}
00043 Kernel::Kernel(const std::string t, const std::string p)
00044     : type(t),
00045       pattern(p),
00046       log("PatternKernel"),
00047       pd_gain()
00048 {
00049     if(RISE::getPyConfigView().get<bool>("debug.antennaPatterns")) {
00050         log.switchOn();
00051     } else {
00052         log.switchOff();
00053     }
00054 }
00055 Kernel::~Kernel()
00056 {}
00057 
00058 Kernel* Kernel::getPatternKernel(const wns::pyconfig::View& antennaView)
00059 {
00060     std::string type = antennaView.get<std::string>("__plugin__");
00061     std::string pattern = antennaView.get<std::string>("pattern");
00062     PKContainer::iterator patternItr = p_availablePatterns.find(pattern);
00063     if(patternItr == p_availablePatterns.end()) {
00064         Kernel* pk =
00065             Kernel::createPatternKernel(std::string(type.c_str()),
00066                                                      std::string(pattern.c_str()));
00067         p_availablePatterns[pattern] = pk;
00068         return pk;
00069     } else {
00070         return patternItr->second;
00071     }
00072 
00073 }
00074 
00075 Kernel* Kernel::createPatternKernel(const std::string type,
00076                                                   const std::string pattern)
00077 {
00078     Kernel* pk = 0;
00079     if (type == std::string("Internal"))
00080         pk = TwoDimensional::createPatternKernel(type, pattern);
00081     else if (type == std::string("Antenna3D"))
00082         pk = ThreeDimensional::createPatternKernel(type, pattern);
00083     else if (type == std::string("Planet"))
00084         pk = Planet::createPatternKernel(type, pattern);
00085     else
00086         throw wns::Exception(std::string("PatternKernel: No such static antenna pattern type: ") + type);
00087     return pk;
00088 }
00089 
00090 Kernel::PKContainer Kernel::p_availablePatterns = Kernel::PKContainer();
00091 
00092 

Generated on Thu May 24 03:31:53 2012 for openWNS by  doxygen 1.5.5