NIVissimSingleTypeParser_Streckendefinition Class Reference

#include <NIVissimSingleTypeParser_Streckendefinition.h>

Inheritance diagram for NIVissimSingleTypeParser_Streckendefinition:

NIImporter_Vissim::VissimSingleTypeParser

Detailed Description

Definition at line 43 of file NIVissimSingleTypeParser_Streckendefinition.h.


Public Member Functions

 NIVissimSingleTypeParser_Streckendefinition (NIImporter_Vissim &parent)
 Constructor.
bool parse (std::istream &from)
 Parses the data type from the given stream.
 ~NIVissimSingleTypeParser_Streckendefinition ()
 Destructor.

Protected Member Functions

Position2D getPosition2D (std::istream &from)
 returns the 2d-position saved as next within the stream
std::string myRead (std::istream &from)
 reads from the stream and returns the lower case version of the read value
std::string overrideOptionalLabel (std::istream &from, const std::string &tag="")
 overrides the optional label definition; returns the next tag as done by readEndSecure
IntVector parseAssignedVehicleTypes (std::istream &from, const std::string &next)
 parses a listof vehicle types assigned to the current data field One should remeber, that -1 means "all" vehicle types
std::string readEndSecure (std::istream &from, const std::vector< std::string > &excl)
std::string readEndSecure (std::istream &from, const std::string &excl="")
 as myRead, but returns "DATAEND" when the current field has ended
NIVissimExtendedEdgePoint readExtEdgePointDef (std::istream &from)
std::string readName (std::istream &from)
 Reads the structures name We cannot use the "<<" operator, as names may contain more than one word which are joined using '"'.
void readUntil (std::istream &from, const std::string &name)
 Reads from the stream until the keywor occurs.
bool skipOverreading (std::istream &from, const std::string &name="")
 Overreads the named parameter (if) given and skips the rest until "DATAEND".

Constructor & Destructor Documentation

NIVissimSingleTypeParser_Streckendefinition::NIVissimSingleTypeParser_Streckendefinition ( NIImporter_Vissim parent  ) 

Constructor.

Definition at line 48 of file NIVissimSingleTypeParser_Streckendefinition.cpp.

NIVissimSingleTypeParser_Streckendefinition::~NIVissimSingleTypeParser_Streckendefinition (  ) 

Destructor.

Definition at line 52 of file NIVissimSingleTypeParser_Streckendefinition.cpp.

00052 {}


Member Function Documentation

Position2D NIImporter_Vissim::VissimSingleTypeParser::getPosition2D ( std::istream &  from  )  [protected, inherited]

returns the 2d-position saved as next within the stream

Definition at line 222 of file NIImporter_Vissim.cpp.

References SUMOReal.

Referenced by parse(), and NIVissimSingleTypeParser_Knotendefinition::parse().

00222                                                                        {
00223     SUMOReal x, y;
00224     from >> x; // type-checking is missing!
00225     from >> y; // type-checking is missing!
00226     return Position2D(x, y);
00227 }

std::string NIImporter_Vissim::VissimSingleTypeParser::myRead ( std::istream &  from  )  [protected, inherited]

reads from the stream and returns the lower case version of the read value

Definition at line 144 of file NIImporter_Vissim.cpp.

References StringUtils::to_lower_case().

Referenced by NIImporter_Vissim::VissimSingleTypeParser::overrideOptionalLabel(), NIVissimSingleTypeParser_Zusammensetzungsdefinition::parse(), NIVissimSingleTypeParser_Zuflussdefinition::parse(), NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(), NIVissimSingleTypeParser_Verlustzeitmessungsdefinition::parse(), NIVissimSingleTypeParser_Verkehrszusammensetzungsdefinition::parse(), NIVissimSingleTypeParser_Verbindungsdefinition::parse(), parse(), NIVissimSingleTypeParser_Signalgruppendefinition::parse(), NIVissimSingleTypeParser_Signalgeberdefinition::parse(), NIVissimSingleTypeParser_Routenentscheidungsdefinition::parse(), NIVissimSingleTypeParser_Reisezeitmessungsdefinition::parse(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parse(), NIVissimSingleTypeParser_Querschnittsmessungsdefinition::parse(), NIVissimSingleTypeParser_Parkplatzdefinition::parse(), NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parse(), NIVissimSingleTypeParser_Langsamfahrbereichdefinition::parse(), NIVissimSingleTypeParser_Knotendefinition::parse(), NIVissimSingleTypeParser_Haltestellendefinition::parse(), NIVissimSingleTypeParser_Fensterdefinition::parse(), NIVissimSingleTypeParser_Fahrzeugtypdefinition::parse(), NIVissimSingleTypeParser_Fahrzeugklassendefinition::parse(), NIVissimSingleTypeParser_Detektordefinition::parse(), NIVissimSingleTypeParser_Auswertungsdefinition::parse(), NIVissimSingleTypeParser_Signalgruppendefinition::parseFixedTime(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed(), NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseRestActuated(), NIVissimSingleTypeParser_Signalgruppendefinition::parseVAS(), NIImporter_Vissim::VissimSingleTypeParser::readEndSecure(), NIImporter_Vissim::VissimSingleTypeParser::readUntil(), and NIImporter_Vissim::VissimSingleTypeParser::skipOverreading().

00144                                                                 {
00145     std::string tmp;
00146     from >> tmp;
00147     return StringUtils::to_lower_case(tmp);
00148 }

std::string NIImporter_Vissim::VissimSingleTypeParser::overrideOptionalLabel ( std::istream &  from,
const std::string &  tag = "" 
) [protected, inherited]

overrides the optional label definition; returns the next tag as done by readEndSecure

Definition at line 201 of file NIImporter_Vissim.cpp.

References NIImporter_Vissim::VissimSingleTypeParser::myRead().

Referenced by NIVissimSingleTypeParser_Zuflussdefinition::parse(), NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(), NIVissimSingleTypeParser_Verbindungsdefinition::parse(), parse(), NIVissimSingleTypeParser_Signalgeberdefinition::parse(), and NIVissimSingleTypeParser_Knotendefinition::parse().

00202                               {
00203     std::string tmp;
00204     if (tag=="") {
00205         tmp = myRead(from);
00206     } else {
00207         tmp = tag;
00208     }
00209     if (tmp=="beschriftung") {
00210         tmp = myRead(from);
00211         if (tmp=="keine") {
00212             from >> tmp;
00213         }
00214         tmp = myRead(from);
00215         tmp = myRead(from);
00216     }
00217     return tmp;
00218 }

bool NIVissimSingleTypeParser_Streckendefinition::parse ( std::istream &  from  )  [virtual]

Parses the data type from the given stream.

Implements NIImporter_Vissim::VissimSingleTypeParser.

Definition at line 56 of file NIVissimSingleTypeParser_Streckendefinition.cpp.

References TplConvert< E >::_2int(), TplConvert< E >::_2SUMOReal(), NIVissimEdge::dictionary(), NIImporter_Vissim::VissimSingleTypeParser::getPosition2D(), NIImporter_Vissim::VissimSingleTypeParser::myRead(), NIImporter_Vissim::VissimSingleTypeParser::overrideOptionalLabel(), Position2DVector::push_back_noDoublePos(), NIImporter_Vissim::VissimSingleTypeParser::readEndSecure(), NIImporter_Vissim::VissimSingleTypeParser::readName(), and SUMOReal.

00056                                                                    {
00057     // read in the id
00058     int id;
00059     from >> id;
00060     //
00061     std::string tag;
00062     // the following elements may occure: "Name", "Beschriftung", "Typ",
00063     //  followed by the mandatory "Laenge"
00064     std::string name, label, type;
00065     SUMOReal length = -1;
00066     while (length<0) {
00067         tag = overrideOptionalLabel(from);
00068         if (tag=="name") {
00069             name = readName(from);
00070         } else if (tag=="typ") {
00071             type = myRead(from);
00072         } else if (tag=="laenge") {
00073             from >> length; // type-checking is missing!
00074         }
00075     }
00076     // read in the number of lanes
00077     int noLanes;
00078     tag = myRead(from);
00079     from >> noLanes;
00080     // skip some parameter, except optional "Zuschlag" until "Von" (mandatory)
00081     //  occurs
00082     SUMOReal zuschlag1, zuschlag2;
00083     zuschlag1 = zuschlag2 = 0;
00084     while (tag!="von") {
00085         tag = myRead(from);
00086         if (tag=="zuschlag") {
00087             from >> zuschlag1; // type-checking is missing!
00088             tag = myRead(from);
00089             if (tag=="zuschlag") {
00090                 from >> zuschlag2; // type-checking is missing!
00091             }
00092         }
00093     }
00094     // Read the geometry information
00095     Position2DVector geom;
00096     while (tag!="nach") {
00097         geom.push_back_noDoublePos(getPosition2D(from));
00098         tag = myRead(from);
00099         try {
00100             TplConvert<char>::_2SUMOReal(tag.c_str());
00101             tag = myRead(from);
00102         } catch (NumberFormatException &) {}
00103     }
00104     geom.push_back_noDoublePos(getPosition2D(from));
00105     // Read definitions of closed lanes
00106     NIVissimClosedLanesVector clv;
00107     // check whether a next close lane definition can be found
00108     tag = readEndSecure(from);
00109     while (tag!="DATAEND") {
00110         if (tag=="spur") {
00111             // get the lane number
00112             int laneNo;
00113             from >> laneNo; // type-checking is missing!
00114             // get the list of assigned car classes
00115             IntVector assignedVehicles;
00116             tag = myRead(from);
00117             tag = myRead(from);
00118             while (tag!="DATAEND"&&tag!="spur") {
00119                 int classes = TplConvert<char>::_2int(tag.c_str());
00120                 assignedVehicles.push_back(classes);
00121                 tag = readEndSecure(from);
00122             }
00123             // build and add the definition
00124             NIVissimClosedLaneDef *cld = new NIVissimClosedLaneDef(laneNo, assignedVehicles);
00125             clv.push_back(cld);
00126         } else {
00127             tag = readEndSecure(from);
00128         }
00129     }
00130     NIVissimEdge *e = new NIVissimEdge(id, name, type, noLanes,
00131                                        zuschlag1, zuschlag2, length, geom, clv);
00132     if (!NIVissimEdge::dictionary(id, e)) {
00133         return false;
00134     }
00135     return true;
00136     //return NIVissimAbstractEdge::dictionary(id, e);
00137 }

IntVector NIImporter_Vissim::VissimSingleTypeParser::parseAssignedVehicleTypes ( std::istream &  from,
const std::string &  next 
) [protected, inherited]

parses a listof vehicle types assigned to the current data field One should remeber, that -1 means "all" vehicle types

Definition at line 231 of file NIImporter_Vissim.cpp.

References NIImporter_Vissim::VissimSingleTypeParser::readEndSecure().

Referenced by NIVissimSingleTypeParser_Signalgeberdefinition::parse().

00232                                              {
00233     std::string tmp = readEndSecure(from);
00234     IntVector ret;
00235     if (tmp=="alle") {
00236         ret.push_back(-1);
00237         return ret;
00238     }
00239     while (tmp!="DATAEND"&&tmp!=next) {
00240         ret.push_back(TplConvert<char>::_2int(tmp.c_str()));
00241         tmp = readEndSecure(from);
00242     }
00243     return ret;
00244 }

std::string NIImporter_Vissim::VissimSingleTypeParser::readEndSecure ( std::istream &  from,
const std::vector< std::string > &  excl 
) [protected, inherited]

Definition at line 171 of file NIImporter_Vissim.cpp.

References NIImporter_Vissim::admitContinue(), NIImporter_Vissim::VissimSingleTypeParser::myRead(), NIImporter_Vissim::VissimSingleTypeParser::myVissimParent, and StringUtils::to_lower_case().

00172                                           {
00173     std::vector<std::string> myExcl;
00174     std::vector<std::string>::const_iterator i;
00175     for (i=excl.begin(); i!=excl.end(); i++) {
00176         std::string mes = StringUtils::to_lower_case(*i);
00177         myExcl.push_back(mes);
00178     }
00179     std::string tmp = myRead(from);
00180     if (tmp=="") {
00181         return "DATAEND";
00182     }
00183 
00184     bool equals = false;
00185     for (i=myExcl.begin(); i!=myExcl.end()&&!equals; i++) {
00186         if ((*i)==tmp) {
00187             equals = true;
00188         }
00189     }
00190     if (!equals
00191             &&
00192             (tmp.substr(0, 2)=="--"||!myVissimParent.admitContinue(tmp))
00193        ) {
00194         return "DATAEND";
00195     }
00196     return StringUtils::to_lower_case(tmp);
00197 }

std::string NIImporter_Vissim::VissimSingleTypeParser::readEndSecure ( std::istream &  from,
const std::string &  excl = "" 
) [protected, inherited]

as myRead, but returns "DATAEND" when the current field has ended

Definition at line 153 of file NIImporter_Vissim.cpp.

References NIImporter_Vissim::admitContinue(), NIImporter_Vissim::VissimSingleTypeParser::myRead(), NIImporter_Vissim::VissimSingleTypeParser::myVissimParent, and StringUtils::to_lower_case().

Referenced by NIVissimSingleTypeParser_Zusammensetzungsdefinition::parse(), NIVissimSingleTypeParser_Zuflussdefinition::parse(), NIVissimSingleTypeParser_Zeitenverteilungsdefinition::parse(), NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(), NIVissimSingleTypeParser_Verlustzeitmessungsdefinition::parse(), NIVissimSingleTypeParser_Verkehrszusammensetzungsdefinition::parse(), NIVissimSingleTypeParser_Verbindungsdefinition::parse(), parse(), NIVissimSingleTypeParser_Stopschilddefinition::parse(), NIVissimSingleTypeParser_Routenentscheidungsdefinition::parse(), NIVissimSingleTypeParser_Reisezeitmessungsdefinition::parse(), NIVissimSingleTypeParser_Querschnittsmessungsdefinition::parse(), NIVissimSingleTypeParser_Laengenverteilungsdefinition::parse(), NIVissimSingleTypeParser_Knotendefinition::parse(), NIVissimSingleTypeParser_Kantensperrung::parse(), NIVissimSingleTypeParser_Haltestellendefinition::parse(), NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::parse(), NIVissimSingleTypeParser_Fahrzeugtypdefinition::parse(), NIVissimSingleTypeParser_Fahrzeugklassendefinition::parse(), NIVissimSingleTypeParser_DynUml::parse(), NIVissimSingleTypeParser_Detektordefinition::parse(), NIVissimSingleTypeParser_Auswertungsdefinition::parse(), NIImporter_Vissim::VissimSingleTypeParser::parseAssignedVehicleTypes(), NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseFixedTime(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed(), NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseRestActuated(), NIVissimSingleTypeParser_Lichtsignalanlagendefinition::parseVAS(), NIImporter_Vissim::VissimSingleTypeParser::readExtEdgePointDef(), and NIImporter_Vissim::VissimSingleTypeParser::skipOverreading().

00154                                {
00155     std::string myExcl = StringUtils::to_lower_case(excl);
00156     std::string tmp = myRead(from);
00157     if (tmp=="") {
00158         return "DATAEND";
00159     }
00160     if (tmp!=myExcl
00161             &&
00162             (tmp.substr(0, 2)=="--"||!myVissimParent.admitContinue(tmp))
00163        ) {
00164         return "DATAEND";
00165     }
00166     return StringUtils::to_lower_case(tmp);
00167 }

NIVissimExtendedEdgePoint NIImporter_Vissim::VissimSingleTypeParser::readExtEdgePointDef ( std::istream &  from  )  [protected, inherited]

Definition at line 248 of file NIImporter_Vissim.cpp.

References TplConvert< E >::_2int(), NIImporter_Vissim::VissimSingleTypeParser::readEndSecure(), and SUMOReal.

Referenced by NIVissimSingleTypeParser_Verbindungsdefinition::parse().

00249                       {
00250     std::string tag;
00251     from >> tag; // "Strecke"
00252     int edgeid;
00253     from >> edgeid; // type-checking is missing!
00254     from >> tag; // "Spuren"
00255     IntVector lanes;
00256     while (tag!="bei") {
00257         tag = readEndSecure(from);
00258         if (tag!="bei") {
00259             int lane = TplConvert<char>::_2int(tag.c_str());
00260             lanes.push_back(lane-1);
00261         }
00262     }
00263     SUMOReal position;
00264     from >> position;
00265     IntVector dummy;
00266     return NIVissimExtendedEdgePoint(edgeid, lanes, position, dummy);
00267 }

std::string NIImporter_Vissim::VissimSingleTypeParser::readName ( std::istream &  from  )  [protected, inherited]

void NIImporter_Vissim::VissimSingleTypeParser::readUntil ( std::istream &  from,
const std::string &  name 
) [protected, inherited]

bool NIImporter_Vissim::VissimSingleTypeParser::skipOverreading ( std::istream &  from,
const std::string &  name = "" 
) [protected, inherited]

Overreads the named parameter (if) given and skips the rest until "DATAEND".

Definition at line 296 of file NIImporter_Vissim.cpp.

References NIImporter_Vissim::VissimSingleTypeParser::myRead(), and NIImporter_Vissim::VissimSingleTypeParser::readEndSecure().

Referenced by NIVissimSingleTypeParser_Stauzaehlerdefinition::parse(), NIVissimSingleTypeParser_Richtungsentscheidungsdefinition::parse(), and NIVissimSingleTypeParser_Messungsdefinition::parse().

00297                                {
00298     std::string tag;
00299     while (tag!=name) {
00300         tag = myRead(from);
00301     }
00302     while (tag!="DATAEND") {
00303         tag = readEndSecure(from);
00304     }
00305     return true;
00306 }


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

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