SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RONet.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The router's network representation
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef RONet_h
24 #define RONet_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include "ROEdge.h"
38 #include "RONode.h"
39 #include "ROVehicleCont.h"
40 #include "ROVehicle.h"
41 #include "RORouteDef.h"
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class RONode;
51 class RORouteDef;
52 class OptionsCont;
53 class OutputDevice;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
67 class RONet {
68  friend class RouteAggregator;
69 
70 public:
72  RONet();
73 
74 
76  virtual ~RONet();
77 
78 
80 
81 
82  /* @brief Adds a read edge to the network
83  *
84  * If the edge is already known (another one with the same id exists),
85  * an error is generated and given to msg-error-handler. The edge
86  * is deleted in this case and false is returned.
87  *
88  * @param[in] edge The edge to add
89  * @return Whether the edge was added (if not, it was deleted, too)
90  */
91  virtual bool addEdge(ROEdge* edge);
92 
93 
102  ROEdge* getEdge(const std::string& name) const {
103  return myEdges.get(name);
104  }
105 
106 
107  /* @brief Adds a read node to the network
108  *
109  * If the node is already known (another one with the same id exists),
110  * an error is generated and given to msg-error-handler. The node
111  * is deleted in this case
112  *
113  * @param[in] node The node to add
114  */
115  void addNode(RONode* node);
116 
117 
124  RONode* getNode(const std::string& id) const {
125  return myNodes.get(id);
126  }
127 
128 
129  /* @brief Adds a read bus stop to the network
130  *
131  * If the bus stop is already known (another one with the same id exists),
132  * an error is generated and given to msg-error-handler. The stop
133  * is deleted in this case
134  *
135  * @param[in] node The stop to add
136  */
137  void addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop);
138 
139 
145  const SUMOVehicleParameter::Stop* getBusStop(const std::string& id) const {
146  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
147  if (it == myBusStops.end()) {
148  return 0;
149  }
150  return it->second;
151  }
153 
154 
155 
157 
158 
165  bool checkVType(const std::string& id);
166 
167 
177  virtual bool addVehicleType(SUMOVTypeParameter* type);
178 
179 
193  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
194 
195 
208  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
209 
210 
211  /* @brief Adds a route definition to the network
212  *
213  * If the route definition is already known (another one with
214  * the same id exists), false is returned, but the route definition
215  * is not deleted.
216  *
217  * @param[in] def The route definition to add
218  * @return Whether the route definition could be added
219  * @todo Rename myRoutes to myRouteDefinitions
220  */
221  bool addRouteDef(RORouteDef* def);
222 
223 
231  RORouteDef* getRouteDef(const std::string& name) const {
232  return myRoutes.get(name);
233  }
234 
235 
236  /* @brief Adds a vehicle to the network
237  *
238  * If the vehicle is already known (another one with the same id
239  * exists), false is returned, but the vehicle is not deleted.
240  *
241  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
242  *
243  * @param[in] id The id of the vehicle to add
244  * @param[in] veh The vehicle to add
245  * @return Whether the vehicle could be added
246  */
247  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
248 
249 
250  /* @brief Adds a flow of vehicles to the network
251  *
252  * If the flow is already known (another one with the same id
253  * exists), false is returned, but the vehicle parameter are not deleted.
254  *
255  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
256  *
257  * @param[in] flow The parameter of the flow to add
258  * @return Whether the flow could be added
259  */
260  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
261 
262 
263  /* @brief Adds a person to the network
264  *
265  * @param[in] depart The departure time of the person
266  * @param[in] desc The xml description of the person
267  */
268  void addPerson(const SUMOTime depart, const std::string desc);
269  // @}
270 
271 
273 
274 
288 
289 
291  virtual bool furtherStored();
293 
294 
295 
296 
297 
308  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
309 
310 
312  void closeOutput();
313 
314 
316  unsigned int getEdgeNo() const;
317 
319  unsigned int getEdgeNoWithoutInternal() const;
320 
321  const std::map<std::string, ROEdge*>& getEdgeMap() const;
322 
323  bool hasRestrictions() const;
324 
325  void setRestrictionFound();
326 
327  OutputDevice* getRouteOutput(const bool alternative = false) {
328  if (alternative) {
330  }
331  return myRoutesOutput;
332  }
333 
334 protected:
335  bool computeRoute(OptionsCont& options,
336  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
337 
340  return myVehicles;
341  }
342 
343 
344  void checkFlows(SUMOTime time);
345 
346 
347 protected:
349  std::set<std::string> myVehIDs;
350 
353 
356 
358  std::map<std::string, SUMOVehicleParameter::Stop*> myBusStops;
359 
362 
364  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
367 
370 
373 
376 
379 
381  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
383 
385  std::map<std::string, std::vector<SUMOTime> > myDepartures;
386 
389 
392 
395 
397  unsigned int myReadRouteNo;
398 
400  unsigned int myDiscardedRouteNo;
401 
403  unsigned int myWrittenRouteNo;
404 
407 
410 
411 private:
413  RONet(const RONet& src);
414 
416  RONet& operator=(const RONet& src);
417 
418 };
419 
420 
421 #endif
422 
423 /****************************************************************************/
424