User Manual, Developers Guide and API Documentation

ISimulator.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-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/simulator/ISimulator.hpp>
00029 #include <WNS/events/scheduler/Interface.hpp>
00030 
00031 using namespace wns::simulator;
00032 
00033 
00034 ISimulator::~ISimulator()
00035 {
00036 }
00037 
00038 
00039 wns::events::scheduler::Interface*
00040 ISimulator::getEventScheduler() const
00041 {
00042     wns::events::scheduler::Interface* es = this->doGetEventScheduler();
00043     assure(es != NULL, "No EventScheduler available");
00044     return es;
00045 }
00046 
00047 wns::logger::Master*
00048 ISimulator::getMasterLogger() const
00049 {
00050     wns::logger::Master* ml = this->doGetMasterLogger();
00051     assure(ml != NULL, "No MasterLogger available");
00052     return ml;
00053 }
00054 
00055 wns::rng::RNGen*
00056 ISimulator::getRNG() const
00057 {
00058     wns::rng::RNGen* rng = this->doGetRNG();
00059     assure(rng != NULL, "No Random Number Generator available");
00060     return rng;
00061 }
00062 
00063 Registry*
00064 ISimulator::getRegistry() const
00065 {
00066     Registry* ur = this->doGetRegistry();
00067     assure(ur != NULL, "No Registry available");
00068     return ur;
00069 }
00070 
00071 wns::probe::bus::ProbeBusRegistry*
00072 ISimulator::getProbeBusRegistry() const
00073 {
00074     wns::probe::bus::ProbeBusRegistry* pbr = this->doGetProbeBusRegistry();
00075     assure(pbr != NULL, "No ProbeBusRegistry available");
00076     return pbr;
00077 }
00078 
00079 ResetSignal*
00080 ISimulator::getResetSignal() const
00081 {
00082     ResetSignal* rs = this->doGetResetSignal();
00083     assure(rs != NULL, "No ResetSignal available");
00084     return rs;
00085 }
00086 
00087 ShutdownSignal*
00088 ISimulator::getShutdownSignal() const
00089 {
00090     ShutdownSignal* sig = this->doGetShutdownSignal();
00091     assure(sig != NULL, "No ShutdownSignal available");
00092     return sig;
00093 }
00094 
00095 wns::pyconfig::View
00096 ISimulator::getConfiguration() const
00097 {
00098     return this->doGetConfiguration();
00099 }
00100 
00101 void
00102 ISimulator::reset()
00103 {
00104     this->doReset();
00105 }
00106 
00107 Singleton::Singleton() :
00108     simulator_(NULL)
00109 {
00110 }
00111 
00112 Singleton::~Singleton()
00113 {
00114 }
00115 
00116 ISimulator*
00117 Singleton::getInstance()
00118 {
00119     assure(simulator_.get() != NULL, "No Simulator instance available");
00120     return simulator_.get();
00121 }
00122 
00123 void
00124 Singleton::setInstance(ISimulator* simulator)
00125 {
00126     if(simulator != NULL)
00127     {
00128         assure(simulator_.get() == NULL, "cannot set simulator, already set");
00129     }
00130 
00131     simulator_.reset(simulator);
00132 }
00133 
00134 void
00135 Singleton::shutdownInstance()
00136 {
00137     assure(simulator_.get() != NULL, "Nothing to shutdown, no Simulator instance available");
00138 
00139     // if someone is trying to access the Simulator on shutdown of the simulator
00140     // itself, it is already NULL and will thus cause an exception.
00141     ISimulator* tmp = simulator_.release();
00142 
00143     delete tmp;
00144 }
00145 
00146 
00147 wns::simulator::Singleton&
00148 wns::simulator::getSingleton()
00149 {
00150     static Singleton instance;
00151     return instance;
00152 }
00153 
00154 
00155 wns::simulator::ISimulator*
00156 wns::simulator::getInstance()
00157 {
00158     return getSingleton().getInstance();
00159 }
00160 
00161 
00162 wns::events::scheduler::Interface*
00163 wns::simulator::getEventScheduler()
00164 {
00165     return wns::simulator::getInstance()->getEventScheduler();
00166 }
00167 
00168 wns::logger::Master*
00169 wns::simulator::getMasterLogger()
00170 {
00171     return wns::simulator::getInstance()->getMasterLogger();
00172 }
00173 
00174 wns::rng::RNGen*
00175 wns::simulator::getRNG()
00176 {
00177     return wns::simulator::getInstance()->getRNG();
00178 }
00179 
00180 wns::simulator::Registry*
00181 wns::simulator::getRegistry()
00182 {
00183     return wns::simulator::getInstance()->getRegistry();
00184 }
00185 
00186 wns::probe::bus::ProbeBusRegistry*
00187 wns::simulator::getProbeBusRegistry()
00188 {
00189     return wns::simulator::getInstance()->getProbeBusRegistry();
00190 }
00191 
00192 wns::simulator::ResetSignal*
00193 wns::simulator::getResetSignal()
00194 {
00195     return wns::simulator::getInstance()->getResetSignal();
00196 }
00197 
00198 wns::simulator::ShutdownSignal*
00199 wns::simulator::getShutdownSignal()
00200 {
00201     return wns::simulator::getInstance()->getShutdownSignal();
00202 }
00203 
00204 wns::pyconfig::View
00205 wns::simulator::getConfiguration()
00206 {
00207     return wns::simulator::getInstance()->getConfiguration();
00208 }

Generated on Thu May 24 03:31:52 2012 for openWNS by  doxygen 1.5.5