User Manual, Developers Guide and API Documentation

Best.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 <LTE/macg/modeselection/Best.hpp>
00029 #include <LTE/helper/Route.hpp>
00030 
00031 using namespace lte::macg::modeselection;
00032 
00033 STATIC_FACTORY_REGISTER(Best, Strategy, "lte.macg.strategy.Best");
00034 
00035 lte::helper::Route
00036 Best::getRoute(const wns::ldk::CompoundPtr& compound, LayerContainer layers, ScorerContainer scorers)
00037 {
00038     lte::helper::Route route;
00039     lte::helper::Route preferredRoute;
00040 
00041     for(unsigned int modeCounter = 0 ; modeCounter < layers.size(); ++modeCounter)
00042     {
00043         route = scorers.at(modeCounter)->score(compound);
00044 
00045         // first check the association (route is valid only if association of the mode exists)
00046         // then check the compound is accepting
00047         if (route.valid())
00048         {
00049             if (layers.at(modeCounter)->isAccepting(compound))
00050             {
00051                 route.mode = modeCounter;
00052                 if (route.score > preferredRoute.score)
00053                 // update preferredRoute which always has the best score
00054                 preferredRoute = route;
00055             } // else do nothing.
00056         }
00057     }
00058 
00059     return preferredRoute;
00060 } // getRoute
00061 
00062 

Generated on Mon May 21 03:32:07 2012 for openWNS by  doxygen 1.5.5