![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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. 16, 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 <DLL/compoundSwitch/CompoundSwitchDeliverer.hpp> 00029 00030 #include <DLL/compoundSwitch/Filter.hpp> 00031 00032 #include <algorithm> 00033 00034 using namespace dll::compoundSwitch; 00035 00036 CompoundSwitchDeliverer::~CompoundSwitchDeliverer() 00037 { 00038 while ( !filters_.empty() ) 00039 { 00040 delete *(filters_.begin()); 00041 filters_.erase(filters_.begin()); 00042 } 00043 } 00044 00045 void 00046 CompoundSwitchDeliverer::addFilter(compoundSwitch::IFilter* filter) 00047 { 00048 // check for double entries 00049 for(Filters::iterator it = filters_.begin(); it != filters_.end(); ++it) 00050 { 00051 if ((*it)->getName() == filter->getName()) 00052 { 00053 std::ostringstream errorLog; 00054 errorLog << "wns::ldk::compoundSwitch::CompoundSwitchDeliverer: Double entry found in UL or DL Filter list: " 00055 << filter->getName(); 00056 assure( 0, errorLog.str() ); 00057 } 00058 } 00059 00060 // add Filter 00061 filters_.push_back( filter ); 00062 } 00063 00064 void 00065 CompoundSwitchDeliverer::onFUNCreated() 00066 { 00067 // Call onFUNCreated of every filter 00068 for(Filters::iterator it = filters_.begin(); 00069 it != filters_.end(); ++it) 00070 { 00071 (*it)->onFUNCreated(); 00072 } 00073 } 00074 00075 IFilter* 00076 CompoundSwitchDeliverer::getFilter(const wns::ldk::CompoundPtr& compound) const 00077 { 00078 for(Filters::const_iterator it = filters_.begin(); 00079 it != filters_.end(); ++it) 00080 { 00081 if( (*it)->filter(compound) ) 00082 { 00083 return (*it); 00084 break; 00085 } 00086 } 00087 assure (0, "CompoundSwitchDeliverer::getFilter: No filter found for this compound. \n"); 00088 return filters_.back(); 00089 } // getFilter 00090 00091 const CompoundSwitchDeliverer::Filters 00092 CompoundSwitchDeliverer::getAllFilter() const 00093 { 00094 Filters result; 00095 for(Filters::const_iterator it = filters_.begin(); 00096 it != filters_.end(); ++it) 00097 { 00098 result.push_back(*it); 00099 } 00100 return result; 00101 } // getAllFilter() 00102 00103 void 00104 CompoundSwitchDeliverer::add(wns::ldk::IDelivererReceptacle* fu) 00105 { 00106 fus.push_back(fu); 00107 } // add 00108 00109 void 00110 CompoundSwitchDeliverer::clear() 00111 { 00112 fus.clear(); 00113 } // clear 00114 00115 00116 unsigned long int 00117 CompoundSwitchDeliverer::size() const 00118 { 00119 return fus.size(); 00120 } // size 00121 00122 const wns::ldk::Link<wns::ldk::IDelivererReceptacle>::ExchangeContainer 00123 CompoundSwitchDeliverer::get() const 00124 { 00125 wns::ldk::Link<wns::ldk::IDelivererReceptacle>::ExchangeContainer result; 00126 00127 for(wns::ldk::Link<wns::ldk::IDelivererReceptacle>::ExchangeContainer::const_iterator it = fus.begin(); 00128 it != fus.end(); 00129 ++it) { 00130 result.push_back(*it); 00131 } 00132 00133 return result; 00134 } // get 00135 00136 00137 void 00138 CompoundSwitchDeliverer::set(const wns::ldk::Link<wns::ldk::IDelivererReceptacle>::ExchangeContainer& src) 00139 { 00140 fus.clear(); 00141 00142 for(wns::ldk::Link<wns::ldk::IDelivererReceptacle>::ExchangeContainer::const_iterator it = src.begin(); 00143 it != src.end(); 00144 ++it) { 00145 fus.push_back(*it); 00146 } 00147 } // set 00148 00149 00150 00151 wns::ldk::IDelivererReceptacle* 00152 CompoundSwitchDeliverer::getAcceptor(const wns::ldk::CompoundPtr& compound) 00153 { 00154 int i = 0; 00155 for(Filters::const_iterator it = filters_.begin(); 00156 it != filters_.end(); ++it) 00157 { 00158 if( dynamic_cast<IFilter*>(*it)->filter(compound) ) 00159 { 00160 return fus.at(i); 00161 break; 00162 } 00163 ++i; 00164 } 00165 assure (0, "CompoundSwitchDeliverer::getAcceptor: No filter found for this compound. \n"); 00166 return fus.back(); 00167 } // getAcceptor
1.5.5