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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A set of actions common to all applications
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "SystemFrame.h"
26 #include <string>
27 #include <utils/xml/XMLSubSys.h>
28 #include <utils/common/StdDefs.h>
32 #include "RandHelper.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 void
40  oc.addOptionSubTopic("Configuration");
41 
42  oc.doRegister("configuration-file", 'c', new Option_FileName());
43  oc.addSynonyme("configuration-file", "configuration");
44  oc.addDescription("configuration-file", "Configuration", "Loads the named config on startup");
45  oc.addXMLDefault("configuration-file");
46 
47  oc.doRegister("save-configuration", 'C', new Option_FileName());
48  oc.addSynonyme("save-config", "save-configuration");
49  oc.addDescription("save-configuration", "Configuration", "Saves current configuration into FILE");
50 
51  oc.doRegister("save-template", new Option_FileName());
52  oc.addDescription("save-template", "Configuration", "Saves a configuration template (empty) into FILE");
53 
54  oc.doRegister("save-schema", new Option_FileName());
55  oc.addDescription("save-schema", "Configuration", "Saves the configuration schema into FILE");
56 
57  oc.doRegister("save-commented", new Option_Bool(false));
58  oc.addSynonyme("save-commented", "save-template.commented");
59  oc.addDescription("save-commented", "Configuration", "Adds comments to saved template, configuration, or schema");
60 }
61 
62 
63 void
65  oc.addOptionSubTopic("Report");
66 
67  oc.doRegister("verbose", 'v', new Option_Bool(false));
68  oc.addDescription("verbose", "Report", "Switches to verbose output");
69 
70  oc.doRegister("print-options", new Option_Bool(false));
71  oc.addDescription("print-options", "Report", "Prints option values before processing");
72 
73  oc.doRegister("help", '?', new Option_BoolExtended(false));
74  oc.addDescription("help", "Report", "Prints this screen or selected topics");
75 
76  oc.doRegister("version", 'V', new Option_Bool(false));
77  oc.addDescription("version", "Report", "Prints the current version");
78 
79  oc.doRegister("xml-validation", 'X', new Option_String("auto"));
80  oc.addDescription("xml-validation", "Report", "Set schema validation scheme of XML inputs (\"never\", \"auto\" or \"always\")");
81 
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  oc.doRegister("no-warnings", 'W', new Option_Bool(false));
86  oc.addSynonyme("no-warnings", "suppress-warnings", true);
87  oc.addDescription("no-warnings", "Report", "Disables output of warnings");
88 
89  oc.doRegister("aggregate-warnings", new Option_Integer(-1));
90  oc.addDescription("aggregate-warnings", "Report", "Aggregate warnings of the same type whenever more than INT occur");
91 
92  oc.doRegister("log", 'l', new Option_FileName());
93  oc.addSynonyme("log", "log-file");
94  oc.addDescription("log", "Report", "Writes all messages to FILE (implies verbose)");
95 
96  oc.doRegister("message-log", new Option_FileName());
97  oc.addDescription("message-log", "Report", "Writes all non-error messages to FILE (implies verbose)");
98 
99  oc.doRegister("error-log", new Option_FileName());
100  oc.addDescription("error-log", "Report", "Writes all warnings and errors to FILE");
101 
102  oc.doRegister("write-license", new Option_Bool(false));
103  oc.addDescription("write-license", "Output", "Include license info into every output file");
104 
105  oc.doRegister("output-prefix", new Option_String());
106  oc.addDescription("output-prefix", "Output", "Prefix which is applied to all output files. The special string 'TIME' is replaced by the current time.");
107 
108  oc.doRegister("precision", new Option_Integer(2));
109  oc.addDescription("precision", "Output", "Defines the number of digits after the comma for floating point output");
110 
111  oc.doRegister("precision.geo", new Option_Integer(6));
112  oc.addDescription("precision.geo", "Output", "Defines the number of digits after the comma for lon,lat output");
113 
114  oc.doRegister("human-readable-time", 'H', new Option_Bool(false));
115  oc.addDescription("human-readable-time", "Output", "Write time values as hour:minute:second or day:hour:minute:second rathern than seconds");
116 }
117 
118 
119 bool
122  gPrecision = oc.getInt("precision");
123  gPrecisionGeo = oc.getInt("precision.geo");
124  gHumanReadableTime = oc.getBool("human-readable-time");
125  if (oc.exists("weights.random-factor")) {
126  gWeightsRandomFactor = oc.getFloat("weights.random-factor");
127  }
128  return true;
129 }
130 
131 
132 void
134  // flush aggregated warnings
136  // close all output devices
138  // close the xml-subsystem
140  // delete build program options
142  // delete messages
144 }
145 
146 
147 /****************************************************************************/
148 
OptionsCont::getInt
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Definition: OptionsCont.cpp:215
SystemFrame::addConfigurationOptions
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:39
Option_BoolExtended
Definition: Option.h:602
SystemFrame::close
static void close()
Closes all of an applications subsystems.
Definition: SystemFrame.cpp:133
Option_Bool
Definition: Option.h:538
OutputDevice::closeAll
static void closeAll(bool keepErrorRetrievers=false)
Definition: OutputDevice.cpp:126
XMLSubSys::close
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:90
OptionsCont.h
MsgHandler.h
OptionsCont::exists
bool exists(const std::string &name) const
Returns the information whether the named option is known.
Definition: OptionsCont.cpp:129
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:222
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
MsgHandler::cleanupOnEnd
static void cleanupOnEnd()
Removes pending handler.
Definition: MsgHandler.cpp:250
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:27
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:30
SystemFrame::addReportOptions
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:64
MsgHandler::clear
virtual void clear()
Clears information whether an error occurred previously.
Definition: MsgHandler.cpp:160
OptionsCont::addDescription
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
Definition: OptionsCont.cpp:469
SystemFrame.h
OptionsCont::addSynonyme
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:95
MsgHandler::getWarningInstance
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:68
OutputDevice.h
OptionsCont::doRegister
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:74
Option_String
Definition: Option.h:399
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
OptionsCont::addXMLDefault
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.
Definition: OptionsCont.cpp:123
OptionsCont::addOptionSubTopic
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
Definition: OptionsCont.cpp:519
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
gHumanReadableTime
bool gHumanReadableTime
Definition: StdDefs.cpp:28
config.h
Option_FileName
Definition: Option.h:783
RandHelper.h
SystemFrame::checkOptions
static bool checkOptions()
checks shared options and sets StdDefs
Definition: SystemFrame.cpp:120
gPrecision
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:26
StdDefs.h
OptionsCont::clear
void clear()
Removes all information from the container.
Definition: OptionsCont.cpp:456
Option_Integer
An integer-option.
Definition: Option.h:331
XMLSubSys.h