SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIImporter_Vissim.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // Importer for networks stored in Vissim format
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef NIImporter_Vissim_h
22 #define NIImporter_Vissim_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 #include <utils/common/RGBColor.h>
38 #include <utils/geom/Position.h>
40 #include "NIVissimElements.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class OptionsCont;
47 class NBNetBuilder;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
58 public:
70  static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
71 
72 
73 protected:
75  NIImporter_Vissim(NBNetBuilder& nb, const std::string& file);
76 
79 
81  void load(const OptionsCont& options);
82 
83  bool admitContinue(const std::string& tag);
84 
85 public:
87  public:
90 
92  virtual ~VissimSingleTypeParser();
93 
96  virtual bool parse(std::istream& from) = 0;
97 
98  protected:
100  std::string myRead(std::istream& from);
101 
103  std::string readEndSecure(std::istream& from,
104  const std::string& excl = "");
105 
106  std::string readEndSecure(std::istream& from,
107  const std::vector<std::string>& excl);
108 
110  std::string overrideOptionalLabel(std::istream& from,
111  const std::string& tag = "");
112 
114  Position getPosition(std::istream& from);
115 
118  std::vector<int> parseAssignedVehicleTypes(std::istream& from,
119  const std::string& next);
120 
122 
126  std::string readName(std::istream& from);
127 
130  bool skipOverreading(std::istream& from, const std::string& name = "");
131 
133  void readUntil(std::istream& from, const std::string& name);
134 
135  private:
137 
138  private:
141 
142  };
143 
144 
146  typedef std::map<std::string, RGBColor> ColorMap;
147 
148 private:
149  bool readContents(std::istream& strm);
150  void postLoadBuild(SUMOReal offset);
151 
152 
154  void insertKnownElements();
155 
157  void buildParsers();
158 
159 private:
161  typedef std::map<std::string, NIVissimElement> ToElemIDMap;
162 
165 
167  typedef std::map<NIVissimElement, VissimSingleTypeParser*> ToParserMap;
168 
171 
174 
175  std::string myLastSecure;
176 
178 
179 private:
182 
185 
186 };
187 
188 
189 #endif
190 
191 /****************************************************************************/
192 
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns &quot;DATAEND&quot; when the current field has ended
~NIImporter_Vissim()
destructor
Importer for networks stored in Vissim format.
VissimSingleTypeParser(NIImporter_Vissim &parent)
Constructor.
std::map< std::string, NIVissimElement > ToElemIDMap
Definition of a map from element names to their numerical representation.
virtual bool parse(std::istream &from)=0
Parses a single data type. Returns whether no error occured.
bool readContents(std::istream &strm)
ToParserMap myParsers
Parsers by element id.
void insertKnownElements()
adds name-to-id - relationships of known elements into myKnownElements
ToElemIDMap myKnownElements
Map from element names to their numerical representation.
NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream &from)
void load(const OptionsCont &options)
loads the vissim file
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
ColorMap myColorMap
a map from color names to color definitions
NIImporter_Vissim & operator=(const NIImporter_Vissim &)
Invalidated assignment operator.
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
std::string readName(std::istream &from)
Reads the structures name We cannot use the &quot;&lt;&lt;&quot; operator, as names may contain more than one wor...
void postLoadBuild(SUMOReal offset)
void buildParsers()
adds id-to-parser - relationships of elements to parse into myParsers
std::map< std::string, RGBColor > ColorMap
definition of a map from color names to color definitions
NIImporter_Vissim(NBNetBuilder &nb, const std::string &file)
constructor
VissimSingleTypeParser & operator=(const VissimSingleTypeParser &)
Invalidated assignment operator.
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool skipOverreading(std::istream &from, const std::string &name="")
Overreads the named parameter (if) given and skips the rest until &quot;DATAEND&quot;.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
#define SUMOReal
Definition: config.h:215
std::map< NIVissimElement, VissimSingleTypeParser * > ToParserMap
Definition of a map from an element&#39;s numerical id to his parser.
NBNetBuilder & myNetBuilder
std::string myLastSecure
bool admitContinue(const std::string &tag)
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...
std::vector< int > 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 &quot;all&quot; vehicle types