SUMO - Simulation of Urban MObility
sumo_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // Main for SUMO
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #ifdef HAVE_VERSION_H
36 #include <version.h>
37 #endif
38 
39 #include <ctime>
40 #include <string>
41 #include <iostream>
42 #include <netload/NLBuilder.h>
48 #include <utils/common/ToString.h>
49 #include <utils/xml/XMLSubSys.h>
50 
51 #ifndef NO_TRACI
53 #endif
54 
55 
56 // ===========================================================================
57 // functions
58 // ===========================================================================
59 /* -------------------------------------------------------------------------
60  * main
61  * ----------------------------------------------------------------------- */
62 int
63 main(int argc, char** argv) {
65  // give some application descriptions
66  oc.setApplicationDescription("A microscopic road traffic simulation.");
67  oc.setApplicationName("sumo", "SUMO Version " VERSION_STRING);
68  int ret = 0;
69  try {
70  // initialise subsystems
72  OptionsIO::setArgs(argc, argv);
73  // load the net
74  ret = NLBuilder::loadAndRun();
75  } catch (const ProcessError& e) {
76  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
77  WRITE_ERROR(e.what());
78  }
79  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
80  ret = 1;
81 #ifndef _DEBUG
82  } catch (const std::exception& e) {
83  if (std::string(e.what()) != std::string("")) {
84  WRITE_ERROR(e.what());
85  }
86  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
87  ret = 1;
88  } catch (...) {
89  MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
90  ret = 1;
91 #endif
92  }
93 #ifndef NO_TRACI
95 #endif
97  return ret;
98 }
99 
100 
101 /****************************************************************************/
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:54
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:76
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
static void close()
Closes all of an applications subsystems.
int main(int argc, char **argv)
Definition: sumo_main.cpp:63
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:62
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
static void close()
request termination of connection
static int loadAndRun()
Definition: NLBuilder.cpp:223
#define VERSION_STRING
Definition: config.h:210
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:85
A storage for options typed value containers)
Definition: OptionsCont.h:99
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.