![]() |
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. 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 <RISE/medium/PhysicalResource.hpp> 00029 #include <RISE/RISE.hpp> 00030 00031 #include <WNS/pyconfig/View.hpp> 00032 00033 #include <sstream> 00034 00035 using namespace rise; 00036 using namespace rise::medium; 00037 00038 PhysicalResource::PhysicalResource(double f, double b) : 00039 frequency(f), 00040 bandwidth(b), 00041 frequencyRange(Range::Between(f - (b/2)).And(f + (b/2))), 00042 receivers(), 00043 transmissionObjects(), 00044 log("") 00045 { 00046 std::stringstream location; 00047 location << "PhysicalResource f: " << frequency << " b: " << bandwidth; 00048 log=RISELogger(location.str()); 00049 if(RISE::getPyConfigView().get<bool>("debug.physicalResource")) { 00050 log.switchOn(); 00051 } else { 00052 log.switchOff(); 00053 } 00054 } 00055 00056 PhysicalResource::~PhysicalResource() 00057 { 00058 receivers.clear(); 00059 transmissionObjects.clear(); 00060 } 00061 00062 void PhysicalResource::attach(PhysicalResourceObserver* r) 00063 { 00064 assure(std::find(receivers.begin(), receivers.end(), r) == receivers.end(), 00065 "PhysicalResourceObserver already in list!"); 00066 00067 MESSAGE_BEGIN(NORMAL, log, m, "Attaching PhysicalResourceObserver!"); 00068 MESSAGE_END(); 00069 00070 00071 receivers.push_front(r); 00072 } 00073 00074 void PhysicalResource::detach(PhysicalResourceObserver* r) 00075 { 00076 assure(std::find(receivers.begin(), receivers.end(), r) != receivers.end(), 00077 "PhysicalResourceObserver is not in list!"); 00078 00079 MESSAGE_BEGIN(NORMAL, log, m, "Detaching PhysicalResourceObserver!"); 00080 MESSAGE_END(); 00081 00082 receivers.remove(r); 00083 } 00084 00085
1.5.5