User Manual, Developers Guide and API Documentation

FilterTxOPType.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiMeMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2011
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 5, D-52074 Aachen, Germany
00009  * phone: ++49-241-80-27910,
00010  * fax: ++49-241-80-22242
00011  * email: info@openwns.org
00012  * www: http://www.openwns.org
00013  * _____________________________________________________________________________
00014  *
00015  * openWNS is free software; you can redistribute it and/or modify it under the
00016  * terms of the GNU Lesser General Public License version 2 as published by the
00017  * Free Software Foundation;
00018  *
00019  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00021  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00022  * details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00026  *
00027  ******************************************************************************/
00028  
00029 
00030 #include <WIMEMAC/helper/FilterTxOPType.hpp>
00031 #include <DLL/compoundSwitch/CompoundSwitch.hpp>
00032 #include <WNS/Exception.hpp>
00033 
00034 using namespace wimemac::helper;
00035 
00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(FilterTxOPType,
00037                                     dll::compoundSwitch::Filter,
00038                                     "wimemac.helper.FilterTxOPType",
00039                                     dll::compoundSwitch::CompoundSwitchConfigCreator);
00040 
00041 FilterTxOPType::FilterTxOPType(dll::compoundSwitch::CompoundSwitch* compoundSwitch, wns::pyconfig::View& config) :
00042     dll::compoundSwitch::Filter(compoundSwitch, config)
00043 {
00044     this->commandReader = this->compoundSwitch_->getFUN()->getCommandReader(config.get<std::string>("commandName"));
00045 
00046     // set accepting txOP type
00047     std::string txOPTypeString = config.get<std::string>("txOPType");
00048 
00049     // convert to lower case
00050     std::transform(txOPTypeString.begin(), txOPTypeString.end(), txOPTypeString.begin (), (int(*)(int)) std::tolower);
00051 
00052     // .compare == 0 --> no differences between the strings
00053     if(txOPTypeString.compare("data") == 0)
00054     {
00055         this->acceptingTxOPType = DATA;
00056         return;
00057     }
00058 
00059     if(txOPTypeString.compare("data_txop") == 0)
00060     {
00061         this->acceptingTxOPType = DATA_TXOP;
00062         return;
00063     }
00064 
00065     wns::Exception e;
00066     e << "Unknown tx type \"" << txOPTypeString << " - forgot to implement conversion from string to txOP type for new type?";
00067     throw wns::Exception(e);
00068 }
00069 FilterTxOPType::~FilterTxOPType()
00070 {
00071 }
00072 
00073 void
00074 FilterTxOPType::onFUNCreated()
00075 {
00076 }
00077 
00078 bool
00079 FilterTxOPType::filter(const wns::ldk::CompoundPtr& compound) const
00080 {
00081     return(this->commandReader->readCommand<wimemac::IKnowsFrameTypeCommand>(compound->getCommandPool())->getCompoundType() == this->acceptingTxOPType);
00082 }

Generated on Thu May 24 03:32:13 2012 for openWNS by  doxygen 1.5.5