![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * DLLBase (DLL Base classes to create FUN-based DLL) * 00003 * __________________________________________________________________________ * 00004 * * 00005 * Copyright (C) 2006 * 00006 * Chair of Communication Networks (ComNets) * 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany * 00008 * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242 * 00009 * email: wns@comnets.rwth-aachen.de * 00010 * www: http://wns.comnets.rwth-aachen.de * 00011 ******************************************************************************/ 00012 00013 #include <DLL/StationManager.hpp> 00014 #include <DLL/UpperConvergence.hpp> 00015 #include <DLL/RANG.hpp> 00016 #include <DLL/Layer2.hpp> 00017 00018 #include <WNS/node/Node.hpp> 00019 #include <WNS/Functor.hpp> 00020 #include <WNS/Assure.hpp> 00021 00022 00023 using namespace dll; 00024 00025 StationManager::StationManager() : 00026 macAdrLookup(), 00027 layerLookup() 00028 {} 00029 00030 StationManager::~StationManager() 00031 { 00032 } // ~StationManager 00033 00034 void 00035 StationManager::registerStation(ILayer2::StationIDType id, 00036 wns::service::dll::UnicastAddress adr, 00037 ILayer2* layer) 00038 { 00039 //assure(! layerLookup.knows(id), "Station already registered."); 00040 00041 assure(! macAdrLookup.knows(adr), "Station already registered."); 00042 macAdrLookup.insert(adr, layer); 00043 00044 if (layerLookup.knows(id)) 00045 { 00046 // id is already known -> station has more than one address 00047 assure(this->getStationByID(id) == layer, "A station with id " << id << " is already registered using a differend ILayer2*"); 00048 } 00049 else 00050 { 00051 layerLookup.insert(id, layer); 00052 } 00053 00054 if(nodeLookup.knows(layer->getNode())) 00055 { 00056 assure(this->getStationByNode(layer->getNode()) == layer, "A station with this node is already registered using a different ILayer2*"); 00057 } 00058 else 00059 { 00060 nodeLookup.insert(layer->getNode(), layer); 00061 } 00062 } // registerStation 00063 00064 00065 ILayer2* 00066 StationManager::getStationByID(ILayer2::StationIDType id) const 00067 { 00068 return layerLookup.find(id); 00069 } // getStationByID 00070 00071 ILayer2* 00072 StationManager::getStationByNode(wns::node::Interface* node) const 00073 { 00074 return nodeLookup.find(node); 00075 } 00076 00077 00078 wns::node::Interface* 00079 StationManager::getNodeByID(ILayer2::StationIDType id) const 00080 { 00081 return this->getStationByID(id)->getNode(); 00082 } // getStationByID 00083 00084 00085 ILayer2* 00086 StationManager::getStationByMAC(wns::service::dll::UnicastAddress adr) const 00087 { 00088 assure(adr.getInteger()>0,"getStationByMAC("<<adr<<"): bad address"); 00089 return macAdrLookup.find(adr); 00090 } 00091 00092 NodeList 00093 StationManager::getNodeList() const 00094 { 00095 NodeList nodeList; 00096 for(NodeLookup::const_iterator iter = nodeLookup.begin(); iter != nodeLookup.end(); ++iter) 00097 { 00098 nodeList.push_back(iter->first); 00099 } 00100 return nodeList; 00101 } 00102
1.5.5