Eclipse SUMO - Simulation of Urban MObility
SystemFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A set of actions common to all applications
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include "SystemFrame.h"
25 #include <string>
26 #include <utils/xml/XMLSubSys.h>
27 #include <utils/common/StdDefs.h>
31 #include "RandHelper.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
37 void
39  oc.addOptionSubTopic("Configuration");
40 
41  oc.doRegister("configuration-file", 'c', new Option_FileName());
42  oc.addSynonyme("configuration-file", "configuration");
43  oc.addDescription("configuration-file", "Configuration", "Loads the named config on startup");
44  oc.addXMLDefault("configuration-file");
45 
46  oc.doRegister("save-configuration", 'C', new Option_FileName());
47  oc.addSynonyme("save-config", "save-configuration");
48  oc.addDescription("save-configuration", "Configuration", "Saves current configuration into FILE");
49 
50  oc.doRegister("save-template", new Option_FileName());
51  oc.addDescription("save-template", "Configuration", "Saves a configuration template (empty) into FILE");
52 
53  oc.doRegister("save-schema", new Option_FileName());
54  oc.addDescription("save-schema", "Configuration", "Saves the configuration schema into FILE");
55 
56  oc.doRegister("save-commented", new Option_Bool(false));
57  oc.addSynonyme("save-commented", "save-template.commented");
58  oc.addDescription("save-commented", "Configuration", "Adds comments to saved template, configuration, or schema");
59 }
60 
61 
62 void
64  oc.addOptionSubTopic("Report");
65 
66  oc.doRegister("verbose", 'v', new Option_Bool(false));
67  oc.addDescription("verbose", "Report", "Switches to verbose output");
68 
69  oc.doRegister("print-options", new Option_Bool(false));
70  oc.addDescription("print-options", "Report", "Prints option values before processing");
71 
72  oc.doRegister("help", '?', new Option_BoolExtended(false));
73  oc.addDescription("help", "Report", "Prints this screen or selected topics");
74 
75  oc.doRegister("version", 'V', new Option_Bool(false));
76  oc.addDescription("version", "Report", "Prints the current version");
77 
78  oc.doRegister("xml-validation", 'X', new Option_String("auto"));
79  oc.addDescription("xml-validation", "Report", "Set schema validation scheme of XML inputs (\"never\", \"auto\" or \"always\")");
80 
81  if (oc.exists("net-file")) {
82  oc.doRegister("xml-validation.net", new Option_String("never"));
83  oc.addDescription("xml-validation.net", "Report", "Set schema validation scheme of SUMO network inputs (\"never\", \"auto\" or \"always\")");
84  }
85 
86  if (oc.exists("route-files")) {
87  oc.doRegister("xml-validation.routes", new Option_String("auto"));
88  oc.addDescription("xml-validation.routes", "Report", "Set schema validation scheme of SUMO route inputs (\"never\", \"auto\" or \"always\")");
89  }
90 
91  oc.doRegister("no-warnings", 'W', new Option_Bool(false));
92  oc.addSynonyme("no-warnings", "suppress-warnings", true);
93  oc.addDescription("no-warnings", "Report", "Disables output of warnings");
94 
95  oc.doRegister("aggregate-warnings", new Option_Integer(-1));
96  oc.addDescription("aggregate-warnings", "Report", "Aggregate warnings of the same type whenever more than INT occur");
97 
98  oc.doRegister("log", 'l', new Option_FileName());
99  oc.addSynonyme("log", "log-file");
100  oc.addDescription("log", "Report", "Writes all messages to FILE (implies verbose)");
101 
102  oc.doRegister("message-log", new Option_FileName());
103  oc.addDescription("message-log", "Report", "Writes all non-error messages to FILE (implies verbose)");
104 
105  oc.doRegister("error-log", new Option_FileName());
106  oc.addDescription("error-log", "Report", "Writes all warnings and errors to FILE");
107 
108  oc.doRegister("write-license", new Option_Bool(false));
109  oc.addDescription("write-license", "Output", "Include license info into every output file");
110 
111  oc.doRegister("output-prefix", new Option_String());
112  oc.addDescription("output-prefix", "Output", "Prefix which is applied to all output files. The special string 'TIME' is replaced by the current time.");
113 
114  oc.doRegister("precision", new Option_Integer(2));
115  oc.addDescription("precision", "Output", "Defines the number of digits after the comma for floating point output");
116 
117  oc.doRegister("precision.geo", new Option_Integer(6));
118  oc.addDescription("precision.geo", "Output", "Defines the number of digits after the comma for lon,lat output");
119 
120  oc.doRegister("human-readable-time", 'H', new Option_Bool(false));
121  oc.addDescription("human-readable-time", "Output", "Write time values as hour:minute:second or day:hour:minute:second rather than seconds");
122 }
123 
124 
125 bool
128  gPrecision = oc.getInt("precision");
129  gPrecisionGeo = oc.getInt("precision.geo");
130  gHumanReadableTime = oc.getBool("human-readable-time");
131  if (oc.exists("weights.random-factor")) {
132  gWeightsRandomFactor = oc.getFloat("weights.random-factor");
133  }
134  if (oc.exists("persontrip.walk-opposite-factor")) {
135  gWeightsWalkOppositeFactor = oc.getFloat("persontrip.walk-opposite-factor");
136  }
137  if (oc.exists("xml-validation.routes") && oc.isDefault("xml-validation.routes") && !oc.isDefault("xml-validation")) {
138  oc.set("xml-validation.routes", oc.getString("xml-validation"));
139  }
140  std::cout << std::setprecision(gPrecision);
141  return true;
142 }
143 
144 
145 void
147  // flush aggregated warnings
149  // close all output devices
151  // close the xml-subsystem
153  // delete build program options
155  // delete messages
157 }
158 
159 
160 /****************************************************************************/
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:25
double gWeightsRandomFactor
Definition: StdDefs.cpp:29
double gWeightsWalkOppositeFactor
Definition: StdDefs.cpp:30
bool gHumanReadableTime
Definition: StdDefs.cpp:27
int gPrecisionGeo
Definition: StdDefs.cpp:26
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
Definition: MsgHandler.cpp:162
static void cleanupOnEnd()
Removes pending handler.
Definition: MsgHandler.cpp:265
An integer-option.
Definition: Option.h:329
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
Definition: OptionsCont.cpp:96
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void clear()
Removes all information from the container.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void addXMLDefault(const std::string &name, const std::string &xmlRoot="")
Adds an XML root element to handle by default. The special root "" denotes the default handler.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
static void closeAll(bool keepErrorRetrievers=false)
static void close()
Closes all of an applications subsystems.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:38
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:63
static bool checkOptions()
checks shared options and sets StdDefs
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:120