Stride Reference Manual  - generated for commit 9643b11
ControlHelper.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, 2018, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #pragma once
22 
23 #include "util/RnMan.h"
24 #include "util/Stopwatch.h"
25 
26 #include <boost/property_tree/ptree.hpp>
27 #include <memory>
28 #include <spdlog/spdlog.h>
29 #include <string>
30 
31 namespace stride {
32 
33 class SimRunner;
34 
46 {
47 public:
49  explicit ControlHelper(const boost::property_tree::ptree& config, std::string name);
50 
53 
54 protected:
56  explicit ControlHelper();
57 
59  void CheckEnv();
60 
61  // Output_prefix: if it's a string not containing any / it gets interpreted as a
62  // filename prefix; otherwise we 'll create the corresponding directory.
63  void CheckOutputPrefix();
64 
66  void InstallLogger();
67 
69  void LogStartup();
70 
72  void RegisterViewers(std::shared_ptr<SimRunner> runner);
73 
75  void Shutdown();
76 
77 protected:
78  boost::property_tree::ptree m_config;
79  std::string m_name;
80  std::string m_output_prefix;
82  std::shared_ptr<spdlog::logger> m_stride_logger;
84 };
85 
86 } // namespace stride
void RegisterViewers(std::shared_ptr< SimRunner > runner)
Register the viewers of the SimRunner.
~ControlHelper()
Simple destructor.
boost::property_tree::ptree m_config
Main configuration for run and sim.
Definition: ControlHelper.h:78
std::string m_output_prefix
Prefix to output (name prefix or prefix dir)
Definition: ControlHelper.h:80
void CheckEnv()
Check install environment.
bool m_use_install_dirs
Working dir or install dir mode.
Definition: ControlHelper.h:83
std::shared_ptr< spdlog::logger > m_stride_logger
General logger.
Definition: ControlHelper.h:82
void LogStartup()
Logs info on setup for cli environment to stride_logger.
ControlHelper()
Empty controller: used as target for delegation.
Provides a stopwatch interface to time: it accumulates time between start/stop pairs.
Definition: Stopwatch.h:35
Definition of Stopwatch.
Interface of RnMan.
util::Stopwatch m_run_clock
Stopwatch for timing the computation.
Definition: ControlHelper.h:81
std::string m_name
Contoller&#39;s name.
Definition: ControlHelper.h:79
void Shutdown()
Logs info on setup for cli environment to stride_logger.
Controls a simulation run initiated with the command line interface (cli).
Definition: ControlHelper.h:45
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
void InstallLogger()
Make the appropriate logger for cli environment and register as stride_logger.