User Manual, Developers Guide and API Documentation

FilterFrameType.cpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiFiMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2007
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 16, 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 #include <WIFIMAC/helper/FilterFrameType.hpp>
00030 #include <DLL/compoundSwitch/CompoundSwitch.hpp>
00031 #include <WNS/Exception.hpp>
00032 
00033 using namespace wifimac::helper;
00034 
00035 STATIC_FACTORY_REGISTER_WITH_CREATOR(FilterFrameType,
00036                                      dll::compoundSwitch::Filter,
00037                                      "wifimac.helper.FilterFrameType",
00038                                      dll::compoundSwitch::CompoundSwitchConfigCreator);
00039 
00040 FilterFrameType::FilterFrameType(dll::compoundSwitch::CompoundSwitch* compoundSwitch, wns::pyconfig::View& config) :
00041     dll::compoundSwitch::Filter(compoundSwitch, config)
00042 {
00043     this->commandReader = this->compoundSwitch_->getFUN()->getCommandReader(config.get<std::string>("commandName"));
00044 
00045     // set accepting frame type
00046     std::string frameTypeString = config.get<std::string>("fType");
00047 
00048     // convert to lower case
00049     std::transform(frameTypeString.begin(), frameTypeString.end(), frameTypeString.begin (), (int(*)(int)) std::tolower);
00050 
00051     // .compare == 0 --> no differences between the strings
00052     if(frameTypeString.compare("preamble") == 0)
00053     {
00054         this->acceptingFrameType = PREAMBLE;
00055         return;
00056     }
00057 
00058     if(frameTypeString.compare("data") == 0)
00059     {
00060         this->acceptingFrameType = DATA;
00061         return;
00062     }
00063 
00064     if(frameTypeString.compare("data_txop") == 0)
00065     {
00066         this->acceptingFrameType = DATA_TXOP;
00067         return;
00068     }
00069 
00070     if(frameTypeString.compare("ack") == 0)
00071     {
00072         this->acceptingFrameType = ACK;
00073         return;
00074     }
00075 
00076     if(frameTypeString.compare("beacon") == 0)
00077     {
00078         this->acceptingFrameType = BEACON;
00079         return;
00080     }
00081 
00082     wns::Exception e;
00083     e << "Unknown frame type \"" << frameTypeString << " - forgot to implement conversion from string to frame type for new type?";
00084     throw wns::Exception(e);
00085 }
00086 FilterFrameType::~FilterFrameType()
00087 {
00088 }
00089 
00090 void
00091 FilterFrameType::onFUNCreated()
00092 {
00093 }
00094 
00095 bool
00096 FilterFrameType::filter(const wns::ldk::CompoundPtr& compound) const
00097 {
00098     return(this->commandReader->readCommand<wifimac::IKnowsFrameTypeCommand>(compound->getCommandPool())->getFrameType() == this->acceptingFrameType);
00099 }

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