![]() |
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/ProbeBus.hpp> 00029 #include <WNS/probe/bus/ProbeBusRegistry.hpp> 00030 #include <WNS/probe/bus/detail/SubjectPimpl.hpp> 00031 #include <WNS/probe/bus/detail/ObserverPimpl.hpp> 00032 #include <WNS/simulator/ISimulator.hpp> 00033 00034 #include <iostream> 00035 00036 using namespace wns::probe::bus; 00037 00038 ProbeBus::ProbeBus(): 00039 subject_( new detail::SubjectPimpl() ), 00040 observer_( new detail::ObserverPimpl(this) ) 00041 { 00042 } 00043 00044 ProbeBus::~ProbeBus() 00045 { 00046 assure(subject_ != NULL, "This ProbeBus instance has no implementation of the subject detail"); 00047 delete subject_; 00048 assure(observer_ != NULL, "This ProbeBus instance has no implementation of the observer detail"); 00049 delete observer_; 00050 } 00051 00052 void 00053 ProbeBus::forwardMeasurement(const wns::simulator::Time& timestamp, 00054 const double& aValue, 00055 const IContext& theRegistry) 00056 { 00057 if (this->accepts(timestamp, theRegistry)) 00058 { 00059 this->onMeasurement(timestamp, aValue, theRegistry); 00060 00061 assure(subject_ != NULL, "This ProbeBus instance has no implementation of the subject detail"); 00062 subject_->forwardMeasurement(timestamp, aValue, theRegistry); 00063 } 00064 } 00065 00066 void 00067 ProbeBus::forwardOutput() 00068 { 00069 this->output(); 00070 00071 assure(subject_ != NULL, "This ProbeBus instance has no implementation of the subject detail"); 00072 subject_->forwardOutput(); 00073 } 00074 00075 void 00076 ProbeBus::startObserving(ProbeBus* other) 00077 { 00078 assure(observer_ != NULL, "This ProbeBus instance has no implementation of the observer detail"); 00079 observer_->startObserving( other->subject_ ); 00080 } 00081 00082 void 00083 ProbeBus::stopObserving(ProbeBus* other) 00084 { 00085 assure(observer_ != NULL, "This ProbeBus instance has no implementation of the observer detail"); 00086 observer_->stopObserving( other->subject_ ); 00087 } 00088 00089 bool 00090 ProbeBus::hasObservers() const 00091 { 00092 return subject_->hasObservers(); 00093 }
1.5.5