Stride Reference Manual  - generated for commit 9643b11
CliViewer.cpp
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 2018, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "CliViewer.h"
22 
23 #include "calendar/Calendar.h"
24 #include "pop/Population.h"
25 #include "sim/Sim.h"
26 #include "sim/SimRunner.h"
27 
28 #include <boost/property_tree/xml_parser.hpp>
29 #include <sstream>
30 
31 using namespace std;
32 using namespace stride::sim_event;
33 using namespace stride::util;
34 using namespace boost::property_tree;
35 
36 namespace stride {
37 namespace viewers {
38 
39 void CliViewer::Update(const sim_event::Id id)
40 {
41  switch (id) {
42  case Id::AtStart: {
43  const auto sim = m_runner->GetSim();
44  m_logger->info(" SimRunner at start:");
45  ostringstream ss;
46  write_xml(ss, m_runner->GetConfig(), xml_writer_make_settings<ptree::key_type>(' ', 8));
47  m_logger->trace("Run config used:\n {}", ss.str());
48  m_logger->info(" Day: {:4} Done, infected count: {:7}", sim->GetCalendar()->GetSimulationDay(),
49  sim->GetPopulation()->GetInfectedCount());
50  break;
51  }
52  case Id::Stepped: {
53  const auto sim = m_runner->GetSim();
54  m_logger->info(" Day: {:4} Done, infected count: {:7}", sim->GetCalendar()->GetSimulationDay(),
55  sim->GetPopulation()->GetInfectedCount());
56  break;
57  }
58  case Id::Finished: {
59  const auto sim = m_runner->GetSim();
60  m_logger->info(" SimRunner done after: {}", m_runner->GetClock().ToString());
61  break;
62  }
63  default: break;
64  }
65 }
66 
67 } // namespace viewers
68 } // namespace stride
Namespace to manage events signalled by the SimRunner.
Definition: Id.cpp:27
Observer for SimEvents for commandline interface usage.
Utilities for the project.
Id
Enumerates the event.
Definition: Id.h:30
STL namespace.
Header file for the core Population class.
Header for the Simulator class.
Header file for the Calendar class.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
Header for the SimRunner class.