Eclipse SUMO - Simulation of Urban MObility
OptionsIO Class Reference

#include <OptionsIO.h>

Static Public Member Functions

static int getArgC ()
 Return the number of command line arguments. More...
 
static const std::chrono::time_point< std::chrono::system_clock > & getLoadTime ()
 Return the time stamp of the last init. More...
 
static void getOptions (const bool commandLineOnly=false)
 Parses the command line arguments and loads the configuration. More...
 
static std::string getRoot (const std::string &filename)
 Retrieves the XML root element of a supposed configuration or net. More...
 
static void loadConfiguration ()
 Loads and parses the configuration. More...
 
static void setArgs (const std::vector< std::string > &args)
 Stores faked command line arguments for later parsing. More...
 
static void setArgs (int argc, char **argv)
 Stores the command line arguments for later parsing. More...
 

Static Private Attributes

static std::vector< std::string > myArgs
 
static std::chrono::time_point< std::chrono::system_clock > myLoadTime
 

Detailed Description

Helping methods for parsing of command line arguments and reading a configuration file. Any errors are reported by throwing a ProcessError exception which contains a description about the failure.

Definition at line 46 of file OptionsIO.h.

Member Function Documentation

◆ getArgC()

static int OptionsIO::getArgC ( )
inlinestatic

Return the number of command line arguments.

Definition at line 63 of file OptionsIO.h.

References myArgs.

Referenced by NLBuilder::init().

Here is the caller graph for this function:

◆ getLoadTime()

static const std::chrono::time_point<std::chrono::system_clock>& OptionsIO::getLoadTime ( )
inlinestatic

Return the time stamp of the last init.

Definition at line 101 of file OptionsIO.h.

References myLoadTime.

Referenced by OutputDevice::getDevice(), and OptionsCont::set().

Here is the caller graph for this function:

◆ getOptions()

void OptionsIO::getOptions ( const bool  commandLineOnly = false)
static

Parses the command line arguments and loads the configuration.

Command line arguments are parsed, first, throwing a ProcessError if something fails. Then options are reset to being writeable and the configuration is loaded using "loadConfiguration". After this, the options are reset again and the command line arguments are reparsed.

This workflow allows to read the name of a configuration file from command line arguments, first, then to load values from this configuration file and reset them by other values from the command line.

Definition at line 74 of file OptionsIO.cpp.

References OptionsCont::getOptions(), getRoot(), loadConfiguration(), myArgs, myLoadTime, OptionsParser::parse(), and TL.

Referenced by NLBuilder::init(), GNELoadThread::loadConsoleOptions(), main(), and GUILoadThread::run().

Here is the caller graph for this function:

◆ getRoot()

std::string OptionsIO::getRoot ( const std::string &  filename)
static

Retrieves the XML root element of a supposed configuration or net.

Parameters
[in]filenamethe XML file to parse
Returns
the root element if any

Definition at line 142 of file OptionsIO.cpp.

References OptionsLoader::errorOccurred(), OptionsLoader::getItem(), OptionsCont::getOptions(), FileHelpers::isDirectory(), FileHelpers::isReadable(), TLF, StringUtils::transcode(), and StringUtils::transcodeToLocal().

Referenced by getOptions(), and GUILoadThread::run().

Here is the caller graph for this function:

◆ loadConfiguration()

void OptionsIO::loadConfiguration ( )
static

Loads and parses the configuration.

The name of the configuration file is extracted from the global OptionsCont ("configuration-file" is used as the name of the option to get the name of the configuration).

Definition at line 98 of file OptionsIO.cpp.

References OptionsLoader::errorOccurred(), OptionsCont::exists(), OptionsCont::getBool(), OptionsCont::getOptions(), OptionsCont::getString(), FileHelpers::isReadable(), OptionsCont::isSet(), myArgs, OptionsParser::parse(), PROGRESS_BEGIN_MESSAGE, PROGRESS_DONE_MESSAGE, OptionsCont::relocateFiles(), OptionsCont::resetWritable(), TL, TLF, StringUtils::transcode(), and StringUtils::transcodeToLocal().

Referenced by getOptions(), and GUILoadThread::run().

Here is the caller graph for this function:

◆ setArgs() [1/2]

void OptionsIO::setArgs ( const std::vector< std::string > &  args)
static

Stores faked command line arguments for later parsing.

Parameters
[in]argsarguments given as substitute for the command line

Definition at line 67 of file OptionsIO.cpp.

References myArgs.

◆ setArgs() [2/2]

void OptionsIO::setArgs ( int  argc,
char **  argv 
)
static

Stores the command line arguments for later parsing.

Parameters
[in]argcnumber of arguments given at the command line
[in]argvarguments given at the command line

Definition at line 58 of file OptionsIO.cpp.

References myArgs, and StringUtils::transcodeFromLocal().

Referenced by MSNet::adaptToState(), LIBSUMO_NAMESPACE::Simulation::load(), GUILoadThread::loadConfigOrNet(), and main().

Here is the caller graph for this function:

Field Documentation

◆ myArgs

std::vector< std::string > OptionsIO::myArgs
staticprivate

Definition at line 107 of file OptionsIO.h.

Referenced by getArgC(), getOptions(), loadConfiguration(), and setArgs().

◆ myLoadTime

std::chrono::time_point< std::chrono::system_clock > OptionsIO::myLoadTime
staticprivate

Definition at line 108 of file OptionsIO.h.

Referenced by getLoadTime(), and getOptions().


The documentation for this class was generated from the following files: