User Manual, Developers Guide and API Documentation

StationManager.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-2009
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * email: info@openwns.org
00009  * www: http://www.openwns.org
00010  * _____________________________________________________________________________
00011  *
00012  * openWNS is free software; you can redistribute it and/or modify it under the
00013  * terms of the GNU Lesser General Public License version 2 as published by the
00014  * Free Software Foundation;
00015  *
00016  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00017  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00018  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00019  * details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023  *
00024  ******************************************************************************/
00025 #include <WIMAC/StationManager.hpp>
00026 
00027 #include <WNS/node/Node.hpp>
00028 #include <WNS/Functor.hpp>
00029 #include <WNS/Assure.hpp>
00030 
00031 #include <WIMAC/Component.hpp>
00032 
00033 using namespace wimac;
00034 
00035 void
00036 StationManager::registerStation(StationID id,
00037                                 wns::service::dll::UnicastAddress adr,
00038                                 Component* layer)
00039 {
00040     assure(!macAdrLookup.knows(adr), "Station already registered.");
00041     macAdrLookup.insert(adr, layer);
00042 
00043     if (layerLookup.knows(id))
00044     {
00045         // id is already known -> station has more than one address
00046         wns::Exception e;
00047         e << "A station with id " << id << " is already registered using a different Component";
00048         throw e;
00049     }
00050     layerLookup.insert(id, layer);
00051 
00052     if(nodeLookup.knows(layer->getNode()))
00053     {
00054         wns::Exception e;
00055         e << "A station with this node is already registered using a different Component*";
00056         throw e;
00057     }
00058     nodeLookup.insert(layer->getNode(), layer);
00059 }
00060 
00061 
00062 Component*
00063 StationManager::getStationByID(StationID id) const
00064 {
00065     return layerLookup.find(id);
00066 }
00067 
00068 Component*
00069 StationManager::getStationByNode(wns::node::Interface* node) const
00070 {
00071     return nodeLookup.find(node);
00072 }
00073 
00074 
00075 wns::node::Interface*
00076 StationManager::getNodeByID(StationID id) const
00077 {
00078     return this->getStationByID(id)->getNode();
00079 }
00080 
00081 
00082 Component*
00083 StationManager::getStationByMAC(wns::service::dll::UnicastAddress adr) const
00084 {
00085     return macAdrLookup.find(adr);
00086 }
00087 
00088 

Generated on Sun May 27 03:31:37 2012 for openWNS by  doxygen 1.5.5