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 /****************************************************************************/
17 // A set of actions common to all applications
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "SystemFrame.h"
27 #include <string>
28 #include <utils/xml/XMLSubSys.h>
29 #include <utils/common/StdDefs.h>
33 #include "RandHelper.h"
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
39 void
41  oc.addOptionSubTopic("Configuration");
42 
43  oc.doRegister("configuration-file", 'c', new Option_FileName());
44  oc.addSynonyme("configuration-file", "configuration");
45  oc.addDescription("configuration-file", "Configuration", "Loads the named config on startup");
46  oc.addXMLDefault("configuration-file");
47 
48  oc.doRegister("save-configuration", 'C', new Option_FileName());
49  oc.addSynonyme("save-config", "save-configuration");
50  oc.addDescription("save-configuration", "Configuration", "Saves current configuration into FILE");
51 
52  oc.doRegister("save-template", new Option_FileName());
53  oc.addDescription("save-template", "Configuration", "Saves a configuration template (empty) into FILE");
54 
55  oc.doRegister("save-schema", new Option_FileName());
56  oc.addDescription("save-schema", "Configuration", "Saves the configuration schema into FILE");
57 
58  oc.doRegister("save-commented", new Option_Bool(false));
59  oc.addSynonyme("save-commented", "save-template.commented");
60  oc.addDescription("save-commented", "Configuration", "Adds comments to saved template, configuration, or schema");
61 }
62 
63 
64 void
66  oc.addOptionSubTopic("Report");
67 
68  oc.doRegister("verbose", 'v', new Option_Bool(false));
69  oc.addDescription("verbose", "Report", "Switches to verbose output");
70 
71  oc.doRegister("print-options", new Option_Bool(false));
72  oc.addDescription("print-options", "Report", "Prints option values before processing");
73 
74  oc.doRegister("help", '?', new Option_BoolExtended(false));
75  oc.addDescription("help", "Report", "Prints this screen or selected topics");
76 
77  oc.doRegister("version", 'V', new Option_Bool(false));
78  oc.addDescription("version", "Report", "Prints the current version");
79 
80  oc.doRegister("xml-validation", 'X', new Option_String("auto"));
81  oc.addDescription("xml-validation", "Report", "Set schema validation scheme of XML inputs (\"never\", \"auto\" or \"always\")");
82 
83  oc.doRegister("xml-validation.net", new Option_String("never"));
84  oc.addDescription("xml-validation.net", "Report", "Set schema validation scheme of SUMO network inputs (\"never\", \"auto\" or \"always\")");
85 
86  oc.doRegister("no-warnings", 'W', new Option_Bool(false));
87  oc.addSynonyme("no-warnings", "suppress-warnings", true);
88  oc.addDescription("no-warnings", "Report", "Disables output of warnings");
89 
90  oc.doRegister("log", 'l', new Option_FileName());
91  oc.addSynonyme("log", "log-file");
92  oc.addDescription("log", "Report", "Writes all messages to FILE (implies verbose)");
93 
94  oc.doRegister("message-log", new Option_FileName());
95  oc.addDescription("message-log", "Report", "Writes all non-error messages to FILE (implies verbose)");
96 
97  oc.doRegister("error-log", new Option_FileName());
98  oc.addDescription("error-log", "Report", "Writes all warnings and errors to FILE");
99 
100  oc.doRegister("write-license", new Option_Bool(false));
101  oc.addDescription("write-license", "Output", "Include license info into every output file");
102 
103  oc.doRegister("output-prefix", new Option_String());
104  oc.addDescription("output-prefix", "Output", "Prefix which is applied to all output files. The special string 'TIME' is replaced by the current time.");
105 
106  oc.doRegister("precision", new Option_Integer(2));
107  oc.addDescription("precision", "Output", "Defines the number of digits after the comma for floating point output");
108 
109  oc.doRegister("precision.geo", new Option_Integer(6));
110  oc.addDescription("precision.geo", "Output", "Defines the number of digits after the comma for lon,lat output");
111 
112  oc.doRegister("human-readable-time", 'H', new Option_Bool(false));
113  oc.addDescription("human-readable-time", "Output", "Write time values as hour:minute:second or day:hour:minute:second rathern than seconds");
114 }
115 
116 
117 bool
120  gPrecision = oc.getInt("precision");
121  gPrecisionGeo = oc.getInt("precision.geo");
122  gHumanReadableTime = oc.getBool("human-readable-time");
123  if (oc.exists("weights.random-factor")) {
124  gWeightsRandomFactor = oc.getFloat("weights.random-factor");
125  }
126  return true;
127 }
128 
129 
130 void
132  // close all output devices
134  // close the xml-subsystem
136  // delete build program options
138  // delete messages
140 }
141 
142 
143 /****************************************************************************/
144 
OptionsCont::getInt
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Definition: OptionsCont.cpp:216
SystemFrame::addConfigurationOptions
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:40
Option_BoolExtended
Definition: Option.h:604
SystemFrame::close
static void close()
Closes all of an applications subsystems.
Definition: SystemFrame.cpp:131
Option_Bool
Definition: Option.h:540
OutputDevice::closeAll
static void closeAll(bool keepErrorRetrievers=false)
Definition: OutputDevice.cpp:127
XMLSubSys::close
static void close()
Closes the xml-subsystem.
Definition: XMLSubSys.cpp:91
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:130
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:223
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
MsgHandler::cleanupOnEnd
static void cleanupOnEnd()
Removes pending handler.
Definition: MsgHandler.cpp:241
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:28
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:31
SystemFrame::addReportOptions
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:65
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:473
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:96
OutputDevice.h
OptionsCont::doRegister
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
Option_String
Definition: Option.h:401
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
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:124
OptionsCont::addOptionSubTopic
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
Definition: OptionsCont.cpp:523
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:209
gHumanReadableTime
bool gHumanReadableTime
Definition: StdDefs.cpp:29
config.h
Option_FileName
Definition: Option.h:651
RandHelper.h
SystemFrame::checkOptions
static bool checkOptions()
checks shared options and sets StdDefs
Definition: SystemFrame.cpp:118
gPrecision
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
StdDefs.h
OptionsCont::clear
void clear()
Removes all information from the container.
Definition: OptionsCont.cpp:460
Option_Integer
An integer-option.
Definition: Option.h:333
XMLSubSys.h