SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Settings.h
Go to the documentation of this file.
1 /**
2  * @file Settings.h
3  * @author Gereon Kremer <gereon.kremer@cs.rwth-aachen.de>
4  */
5 
6 #pragma once
7 
9 #include <carl-common/memory/Singleton.h>
10 #include <carl-settings/Settings.h>
11 
12 #include <any>
13 #include <cassert>
14 #include <chrono>
15 #include <ctime>
16 #include <fstream>
17 #include <map>
18 #include <memory>
19 
20 namespace benchmax {
21 
22 // Predeclaration.
23 class SettingsParser;
24 
25 namespace settings {
26 
27 /// Core settings.
28 struct CoreSettings {
29  /// Whether to show the command-line help.
30  bool show_help;
31  /// Whether to show the configured settings.
33  /// Whether to be more verbose.
34  bool be_verbose;
35  /// Whether to be more quiet.
36  bool be_quiet;
37  /// Path of an optional config file.
38  std::string config_file;
39 
40  /// Timestamp the binary was started.
41  long start_time = std::time(nullptr);
42 };
43 
44 /// Operation settings.
46  /// Name of the backend to be used.
47  std::string backend;
48  /// Name of the operation mode.
49  std::string mode;
50  /// Name of the xml file to convert to an ods file.
51  std::string convert_ods_filename;
52  /// Name of the xslt filter used for ods import.
53  std::string convert_ods_filter;
54  /// Use temporary directory.
55  bool use_temp;
56 };
57 
58 /**
59  * Generic class to manage runtime settings.
60  * Essentially stores all (named) settings in a map<string,any> and retrieves settings classes when requested.
61  */
62 struct Settings: public carl::Singleton<Settings>, public carl::settings::Settings {
63  friend carl::Singleton<Settings>;
64 private:
66  get<CoreSettings>("core");
67  get<OperationSettings>("operation");
68  };
69 };
70 
71 }
72 
73 /// Helper function to obtain settings by name and type.
74 template<typename T>
75 inline const auto& settings_get(const std::string& name) {
76  static const auto& s = settings::Settings::getInstance().get<T>(name);
77  return s;
78 }
79 
80 /// Retrieved core settings.
81 inline const auto& settings_core() {
82  return settings_get<settings::CoreSettings>("core");
83 }
84 /// Retrieved operation settings.
85 inline const auto& settings_operation() {
86  return settings_get<settings::OperationSettings>("operation");
87 }
88 
89 }
const auto & settings_get(const std::string &name)
Helper function to obtain settings by name and type.
Definition: Settings.h:75
const auto & settings_core()
Retrieved core settings.
Definition: Settings.h:81
const auto & settings_operation()
Retrieved operation settings.
Definition: Settings.h:85
const settings::Settings & Settings()
Definition: Settings.h:96
bool be_quiet
Whether to be more quiet.
Definition: Settings.h:36
long start_time
Timestamp the binary was started.
Definition: Settings.h:41
bool be_verbose
Whether to be more verbose.
Definition: Settings.h:34
bool show_settings
Whether to show the configured settings.
Definition: Settings.h:32
bool show_help
Whether to show the command-line help.
Definition: Settings.h:30
std::string config_file
Path of an optional config file.
Definition: Settings.h:38
std::string backend
Name of the backend to be used.
Definition: Settings.h:47
std::string convert_ods_filename
Name of the xml file to convert to an ods file.
Definition: Settings.h:51
std::string convert_ods_filter
Name of the xslt filter used for ods import.
Definition: Settings.h:53
std::string mode
Name of the operation mode.
Definition: Settings.h:49
bool use_temp
Use temporary directory.
Definition: Settings.h:55
Generic class to manage runtime settings.
Definition: Settings.h:62