User Manual, Developers Guide and API Documentation

Simulator.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/Simulator.hpp>
00029 #include <WNS/events/scheduler/Interface.hpp>
00030 #include <WNS/logger/Master.hpp>
00031 #include <WNS/rng/RNGen.hpp>
00032 #include <WNS/Assure.hpp>
00033 #include <WNS/probe/bus/ProbeBusRegistry.hpp>
00034 
00035 using namespace wns::simulator;
00036 
00037 
00038 Simulator::Simulator(const wns::pyconfig::View& configuration) :
00039     configuration_(configuration),
00040     eventScheduler_(NULL),
00041     masterLogger_(NULL),
00042     rng_(NULL),
00043     registry_(new Registry()),
00044     probeBusRegistry_(NULL),
00045     resetSignal_(new ResetSignal()),
00046     shutdownSignal_(new ShutdownSignal())
00047 {
00048     this->configureEventScheduler(configuration_.getView("environment.eventScheduler"));
00049     this->configureMasterLogger(configuration_.getView("environment.masterLogger"));
00050     this->configureRNG(configuration_.getView("environment.rng"));
00051     this->configureProbeBusRegistry(configuration_.getView("environment.probeBusRegistry"));
00052 }
00053 
00054 Simulator::~Simulator()
00055 {
00056 }
00057 
00058 wns::events::scheduler::Interface*
00059 Simulator::doGetEventScheduler() const
00060 {
00061     return eventScheduler_.get();
00062 }
00063 
00064 wns::logger::Master*
00065 Simulator::doGetMasterLogger() const
00066 {
00067     return masterLogger_.get();
00068 }
00069 
00070 wns::rng::RNGen*
00071 Simulator::doGetRNG() const
00072 {
00073     return rng_.get();
00074 }
00075 
00076 Registry*
00077 Simulator::doGetRegistry() const
00078 {
00079     return registry_.get();
00080 }
00081 
00082 wns::probe::bus::ProbeBusRegistry*
00083 Simulator::doGetProbeBusRegistry() const
00084 {
00085     return probeBusRegistry_.get();
00086 }
00087 
00088 
00089 ResetSignal*
00090 Simulator::doGetResetSignal() const
00091 {
00092     return resetSignal_.get();
00093 }
00094 
00095 ShutdownSignal*
00096 Simulator::doGetShutdownSignal() const
00097 {
00098     return shutdownSignal_.get();
00099 }
00100 
00101 wns::pyconfig::View
00102 Simulator::doGetConfiguration() const
00103 {
00104     return configuration_;
00105 }
00106 
00107 void
00108 Simulator::doReset()
00109 {
00110     throw Exception("Reset is not allowed in normal operation (simulation run)!");
00111 }
00112 
00113 void
00114 Simulator::configureEventScheduler(
00115     const pyconfig::View& eventSchedulerConfiguration)
00116 {
00117     assure(eventScheduler_.get() == NULL, "EventScheduler already set / configured");
00118 
00119     std::string sched = eventSchedulerConfiguration.get<std::string>("type");
00120     wns::events::scheduler::Creator* creator = wns::events::scheduler::Factory::creator(sched);
00121     eventScheduler_.reset(creator->create());
00122 }
00123 
00124 void
00125 Simulator::configureMasterLogger(
00126     const pyconfig::View& masterLoggerConfiguration)
00127 {
00128     assure(masterLogger_.get() == NULL, "MasterLogger already set / configured");
00129     masterLogger_.reset(new wns::logger::Master(masterLoggerConfiguration));
00130 }
00131 
00132 void
00133 Simulator::configureRNG(
00134     const pyconfig::View& rngConfiguration)
00135 {
00136     assure(rng_.get() == NULL, "RNG already set / configured");
00137     rng_.reset(new wns::rng::RNGen());
00138     rng_->seed(rngConfiguration.get<unsigned long int>("seed"));
00139 }
00140 
00141 void
00142 Simulator::configureProbeBusRegistry(
00143     const pyconfig::View& pbrConfiguration)
00144 {
00145 
00146     assure(probeBusRegistry_.get() == NULL, "ProbeBusRegistry already set / configured");
00147 
00148     assure(masterLogger_.get() != NULL, "MasterLogger not available");
00149 
00150     probeBusRegistry_.reset(new wns::probe::bus::ProbeBusRegistry(pbrConfiguration,
00151                                                                   masterLogger_.get()));
00152 }

Generated on Fri May 25 03:31:56 2012 for openWNS by  doxygen 1.5.5