Stride Reference Manual  - generated for commit 9643b11
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimRunner.h
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2017, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #pragma once
22 
23 #include "sim/event/Id.h"
24 #include "sim/event/Subject.h"
25 #include "util/Stopwatch.h"
26 
27 #include <boost/property_tree/ptree.hpp>
28 #include <memory>
29 #include <string>
30 
31 namespace stride {
32 
33 class Sim;
34 class Population;
35 
44 class SimRunner : public util::Subject<stride::sim_event::Id>
45 {
46 public:
49  explicit SimRunner(const boost::property_tree::ptree& configPt, std::shared_ptr<Sim> sim);
50 
52  ~SimRunner() override = default;
53 
55  const util::Stopwatch<>& GetClock() const { return m_clock; }
56 
58  const boost::property_tree::ptree& GetConfig() const { return m_config; }
59 
61  std::shared_ptr<Sim> GetSim() const { return m_sim; }
62 
64  void Run();
65 
67  void Run(unsigned int numSteps);
68 
69 private:
71  boost::property_tree::ptree m_config;
72  std::shared_ptr<Sim> m_sim;
73 };
74 
75 } // namespace stride
const boost::property_tree::ptree & GetConfig() const
Return the run & sim configuration.
Definition: SimRunner.h:58
SimRunner(const boost::property_tree::ptree &configPt, std::shared_ptr< Sim > sim)
Initialization with property tree.
Definition: SimRunner.cpp:33
Definition of Subject/Observer for SimEvents.
std::shared_ptr< Sim > GetSim() const
Return the Simulator.
Definition: SimRunner.h:61
Provides a stopwatch interface to time: it accumulates time between start/stop pairs.
Definition: Stopwatch.h:35
Definition of Stopwatch.
void Run()
Run simulator for as many steps/days as indicated in config.
Definition: SimRunner.cpp:76
std::shared_ptr< Sim > m_sim
Simulator object.
Definition: SimRunner.h:72
~SimRunner() override=default
Destructor.
const util::Stopwatch & GetClock() const
Return the run & sim configuration.
Definition: SimRunner.h:55
The simulation runner drive simulator throufgh time steps.
Definition: SimRunner.h:44
util::Stopwatch m_clock
Stopwatch for timing the computation.
Definition: SimRunner.h:70
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
boost::property_tree::ptree m_config
Ptree with configuration.
Definition: SimRunner.h:71
Definition of EventId.
Template for Subject/Observer (or Publish/Subscribe).
Definition: util/Subject.h:37