![]() |
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 <WNS/probe/bus/ContextCollector.hpp> 00029 #include <WNS/events/scheduler/Interface.hpp> 00030 00031 using namespace wns::probe::bus; 00032 00033 ContextCollector::ContextCollector(std::string probeBusId) : 00034 contextProviders_(ContextProviderCollection()), 00035 probeBus_(wns::simulator::getProbeBusRegistry()->getMeasurementSource(probeBusId)) 00036 {} 00037 00038 ContextCollector::ContextCollector(ContextProviderCollection contextProviders, 00039 std::string probeBusId) : 00040 contextProviders_(contextProviders), 00041 probeBus_(wns::simulator::getProbeBusRegistry()->getMeasurementSource(probeBusId)) 00042 {} 00043 00044 bool 00045 ContextCollector::hasObservers() const 00046 { 00047 return probeBus_->hasObservers(); 00048 } 00049 00050 void 00051 ContextCollector::put(const wns::osi::PDUPtr& compound, double value) const 00052 { 00053 // early return if no one is listening 00054 if (!probeBus_->hasObservers()) 00055 { 00056 return; 00057 } 00058 00059 // Create vanilla Context object 00060 Context c; 00061 00062 // Ask all ContextProviders to provide their input to the context 00063 contextProviders_.fillContext(c, compound); 00064 00065 // determine simTime 00066 wns::simulator::Time t = wns::simulator::getEventScheduler()->getTime(); 00067 probeBus_->forwardMeasurement(t, value, c); 00068 } 00069 00070 void 00071 ContextCollector::put(double value) const 00072 { 00073 // early return if no one is listening 00074 if (!probeBus_->hasObservers()) 00075 { 00076 return; 00077 } 00078 // Create vanilla Context object 00079 Context c; 00080 00081 // Ask all ContextProviders to provide their input to the context 00082 contextProviders_.fillContext(c); 00083 00084 // determine simTime 00085 wns::simulator::Time t = wns::simulator::getEventScheduler()->getTime(); 00086 probeBus_->forwardMeasurement(t, value, c); 00087 } 00088
1.5.5