netconvert_main.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Main for NETCONVERT
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #ifdef HAVE_VERSION_H
00031 #include <version.h>
00032 #endif
00033 
00034 #include <iostream>
00035 #include <string>
00036 #include <netbuild/NBNetBuilder.h>
00037 #include <netimport/NIOptionsIO.h>
00038 #include <netimport/NILoader.h>
00039 #include <netbuild/NBTypeCont.h>
00040 #include <netbuild/NBEdgeCont.h>
00041 #include <netbuild/NBNodeCont.h>
00042 #include <netbuild/NBTypeCont.h>
00043 #include <netbuild/NBDistrictCont.h>
00044 #include <netbuild/NBTrafficLightLogicCont.h>
00045 #include <netbuild/NBDistribution.h>
00046 #include <utils/options/OptionsIO.h>
00047 #include <utils/options/OptionsCont.h>
00048 #include <utils/common/UtilExceptions.h>
00049 #include <utils/common/RandHelper.h>
00050 #include <utils/common/SystemFrame.h>
00051 #include <utils/common/MsgHandler.h>
00052 #include <utils/xml/XMLSubSys.h>
00053 #include <utils/iodevices/OutputDevice.h>
00054 
00055 #ifdef CHECK_MEMORY_LEAKS
00056 #include <foreign/nvwa/debug_new.h>
00057 #endif // CHECK_MEMORY_LEAKS
00058 
00059 
00060 /* -------------------------------------------------------------------------
00061  * main
00062  * ----------------------------------------------------------------------- */
00063 int
00064 main(int argc, char **argv) {
00065     OptionsCont &oc = OptionsCont::getOptions();
00066     // give some application descriptions
00067     oc.setApplicationDescription("Road network importer / builder for the road traffic simulation SUMO.");
00068     oc.setApplicationName("netconvert", "SUMO netconvert Version " + (std::string)VERSION_STRING);
00069     int ret = 0;
00070     try {
00071         XMLSubSys::init(false);
00072         NIOptionsIO::fillOptions();
00073         OptionsIO::getOptions(true, argc, argv);
00074         if (oc.processMetaOptions(argc < 2)) {
00075             SystemFrame::close();
00076             return 0;
00077         }
00078         MsgHandler::initOutputOptions();
00079         if (!NIOptionsIO::checkOptions()) throw ProcessError();
00080         RandHelper::initRandGlobal();
00081         NBNetBuilder nb;
00082         nb.applyOptions(oc);
00083         // load data
00084         NILoader nl(nb);
00085         nl.load(oc);
00086         if (oc.getBool("dismiss-loading-errors")) {
00087             MsgHandler::getErrorInstance()->clear();
00088         }
00089         // check whether any errors occured
00090         if (MsgHandler::getErrorInstance()->wasInformed()) {
00091             throw ProcessError();
00092         }
00093         nb.buildLoaded();
00094     } catch (ProcessError &e) {
00095         if (std::string(e.what())!=std::string("Process Error") && std::string(e.what())!=std::string("")) {
00096             MsgHandler::getErrorInstance()->inform(e.what());
00097         }
00098         MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
00099         ret = 1;
00100 #ifndef _DEBUG
00101     } catch (...) {
00102         MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
00103         ret = 1;
00104 #endif
00105     }
00106     NBDistribution::clear();
00107     OutputDevice::closeAll();
00108     SystemFrame::close();
00109     // report about ending
00110     if (ret==0) {
00111         std::cout << "Success." << std::endl;
00112     }
00113     return ret;
00114 }
00115 
00116 
00117 
00118 /****************************************************************************/
00119 

Generated on Wed May 5 00:06:33 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6