SUMO - Simulation of Urban MObility
NIVissimSingleTypeParser_Signalgeberdefinition.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00008 //
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <cassert>
00033 #include <iostream>
00034 #include <utils/common/TplConvert.h>
00035 #include <utils/common/ToString.h>
00036 #include <utils/common/MsgHandler.h>
00037 #include <utils/common/VectorHelper.h>
00038 #include "../NIImporter_Vissim.h"
00039 #include "../tempstructs/NIVissimTL.h"
00040 #include "NIVissimSingleTypeParser_Signalgeberdefinition.h"
00041 
00042 #ifdef CHECK_MEMORY_LEAKS
00043 #include <foreign/nvwa/debug_new.h>
00044 #endif // CHECK_MEMORY_LEAKS
00045 
00046 
00047 // ===========================================================================
00048 // method definitions
00049 // ===========================================================================
00050 NIVissimSingleTypeParser_Signalgeberdefinition::NIVissimSingleTypeParser_Signalgeberdefinition(NIImporter_Vissim& parent)
00051     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
00052 
00053 
00054 NIVissimSingleTypeParser_Signalgeberdefinition::~NIVissimSingleTypeParser_Signalgeberdefinition() {}
00055 
00056 
00057 bool
00058 NIVissimSingleTypeParser_Signalgeberdefinition::parse(std::istream& from) {
00059     //
00060     int id;
00061     from >> id;
00062     //
00063     std::string tag, name;
00064     tag = myRead(from);
00065     if (tag == "name") {
00066         name = readName(from);
00067         tag = myRead(from);
00068     }
00069     // skip optional "Beschriftung"
00070     tag = overrideOptionalLabel(from, tag);
00071     //
00072     int lsaid;
00073     std::vector<int> groupids;
00074     if (tag == "lsa") {
00075         int groupid;
00076         from >> lsaid; // type-checking is missing!
00077         from >> tag; // "Gruppe"
00078         do {
00079             from >> groupid;
00080             groupids.push_back(groupid);
00081             tag = myRead(from);
00082         } while (tag == "oder");
00083         //
00084     } else {
00085         from >> tag; // strecke
00086         WRITE_WARNING("Omitting unknown traffic light.");
00087         return true;
00088     }
00089     if (tag == "typ") {
00090         from >> tag; // typ-value
00091         from >> tag; // "ort"
00092     }
00093 
00094     //
00095     from >> tag;
00096     int edgeid;
00097     from >> edgeid;
00098 
00099     from >> tag;
00100     int laneno;
00101     from >> laneno;
00102 
00103     from >> tag;
00104     int position;
00105     from >> position;
00106     //
00107     while (tag != "fahrzeugklassen") {
00108         tag = myRead(from);
00109     }
00110     std::vector<int> assignedVehicleTypes = parseAssignedVehicleTypes(from, "N/A");
00111     //
00112     NIVissimTL::dictionary(lsaid); // !!! check whether someting is really done here
00113     NIVissimTL::NIVissimTLSignal* signal =
00114         new NIVissimTL::NIVissimTLSignal(lsaid, id, name, groupids, edgeid,
00115                                          laneno, (SUMOReal) position, assignedVehicleTypes);
00116     if (!NIVissimTL::NIVissimTLSignal::dictionary(lsaid, id, signal)) {
00117         throw 1; // !!!
00118     }
00119     return true;
00120 }
00121 
00122 
00123 
00124 /****************************************************************************/
00125 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines