Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
cli.cpp
Go to the documentation of this file.
1#include "cli.h"
2
18
19namespace storm {
20namespace cli {
21
22bool parseOptions(const int argc, const char* argv[]) {
23 try {
25 } catch (storm::exceptions::OptionParserException&) {
26 STORM_LOG_ERROR("Unable to parse command line options. Type '" + std::string(argv[0]) + " --help' or '" + std::string(argv[0]) +
27 " --help all' for help.");
28 return false;
29 }
30
32 bool terminate = false;
33 if (general.isHelpSet()) {
35 terminate = true;
36 }
37
38 if (general.isVersionSet()) {
40 terminate = true;
41 }
42 if (terminate) {
43 exit(0); // Terminate after help and version output with success.
44 // TODO: Issue 674 discusses that this may not be ideal.
45 }
46
47 return true;
48}
49
52
53 // If we were given a time limit, we put it in place now.
54 if (resources.isTimeoutSet()) {
56 }
57
58 // register signal handler to handle aborts
60}
61
68
73
74 if (general.isVerboseSet()) {
75 storm::utility::setLogLevel(l3pp::LogLevel::INFO);
76 }
77 if (debug.isDebugSet()) {
78 storm::utility::setLogLevel(l3pp::LogLevel::DEBUG);
79 }
80 if (debug.isTraceSet()) {
81 storm::utility::setLogLevel(l3pp::LogLevel::TRACE);
82 }
83
84 // Statistics and progress messages live on their own log channels so they can be enabled
85 // independently of general verbosity.
86 if (core.isShowStatisticsSet()) {
87 storm::utility::setStatisticsLogLevel(l3pp::LogLevel::INFO);
88 }
89 if (general.isShowProgressSet()) {
90 storm::utility::setProgressLogLevel(l3pp::LogLevel::INFO);
91 }
92
94}
95
96int process(std::string const& name, std::string const& executableName, std::function<void(std::string const&, std::string const&)> initSettingsFunc,
97 std::function<void(void)> processOptionsFunc, const int argc, const char** argv) {
99 storm::cli::printHeader(name, argc, argv);
100
101 // Initialize settings
102 initSettingsFunc(name, executableName);
103
104 storm::utility::Stopwatch totalTimer(true);
105 if (!parseOptions(argc, argv)) {
106 return -1;
107 }
108
109 // Start by setting some urgent options (log levels, resources, etc.)
111 setLogLevel();
113 // Set output precision
115
116 // Process options and start computations
117 processOptionsFunc();
118
119 totalTimer.stop();
122 }
123
124 // All operations have been performed, so we clean up everything and terminate.
126 return 0;
127}
128
129} // namespace cli
130} // namespace storm
void setFromCommandLine(int const argc, char const *const argv[])
This function parses the given command line arguments and sets all registered options accordingly.
void printHelp(std::string const &filter="frequent") const
This function prints a help message to the standard output.
This class represents the core settings.
bool isShowStatisticsSet() const
Retrieves whether statistics are to be shown.
This class represents the debug settings.
bool isDebugSet() const
Retrieves whether the debug option was set.
bool isLogfileSet() const
Retrieves whether the logfile option was set.
std::string getLogfilename() const
Retrieves the name of the log file if the logfile option was set.
bool isTraceSet() const
Retrieves whether the trace option was set.
This class represents the general settings.
bool isHelpSet() const
Retrieves whether the help option was set.
bool isVerboseSet() const
Retrieves whether the verbose option was set.
bool isVersionSet() const
Retrieves whether the version option was set.
bool isShowProgressSet() const
Retrieves whether the progress option was set.
std::string getHelpFilterExpression() const
Retrieves the name of the module for which to show the help or "all" to indicate that the full help n...
This class represents the resource settings.
uint_fast64_t getTimeoutInSeconds() const
Retrieves the time after which the computation has to be aborted in case the timeout option was set.
bool isTimeoutSet() const
Retrieves whether the timeout option was set.
A class that provides convenience operations to display run times.
Definition Stopwatch.h:13
MilisecondType getTimeInMilliseconds() const
Gets the measured time in milliseconds.
Definition Stopwatch.cpp:21
void stop()
Stop stopwatch and add measured time to total time.
Definition Stopwatch.cpp:42
#define STORM_LOG_ERROR(message)
Definition logging.h:29
void setResourceLimits()
Definition cli.cpp:50
void setFileLogging()
Definition cli.cpp:62
void printTimeAndMemoryStatistics(uint64_t wallclockMilliseconds)
Definition print.cpp:154
void printHeader(std::string const &name, const int argc, const char **argv)
Definition print.cpp:57
void printVersion()
Definition print.cpp:79
bool parseOptions(const int argc, const char *argv[])
Definition cli.cpp:22
void setLogLevel()
Definition cli.cpp:69
SettingsType const & getModule()
Get module.
SettingsManager const & manager()
Retrieves the settings manager.
SettingsManager & mutableManager()
Retrieves the settings manager.
void setTimeoutAlarm(uint_fast64_t timeout)
Set timeout by raising an alarm after timeout seconds.
void installSignalHandler(int maximalWaitTime)
Register some signal handlers to detect and correctly handle abortion (due to timeout for example).
void setProgressLogLevel(l3pp::LogLevel level)
Set the log level for the progress channel, independently of the global log level.
void initializeFileLogging(std::string const &logfileName)
Sets up the logging to file.
void cleanUp()
Performs some necessary clean-up.
void setLogLevel(l3pp::LogLevel level)
Set the global log level.
void setUp()
Performs some necessary initializations.
void setOutputDigitsFromGeneralPrecision(double precision)
Set number of digits for printing output from given precision requirement.
void setStatisticsLogLevel(l3pp::LogLevel level)
Set the log level for the statistics channel, independently of the global log level.
void process()