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 /****************************************************************************/
8 // The router's network representation
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 RONet_h
22 #define RONet_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 <vector>
35 #include "ROEdge.h"
36 #include "RONode.h"
37 #include "ROVehicleCont.h"
38 #include "ROVehicle.h"
39 #include "RORouteDef.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class RONode;
49 class RORouteDef;
50 class OptionsCont;
51 class OutputDevice;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
65 class RONet {
66  friend class RouteAggregator;
67 
68 public:
70  RONet();
71 
72 
74  virtual ~RONet();
75 
76 
78 
79 
80  /* @brief Adds a read edge to the network
81  *
82  * If the edge is already known (another one with the same id exists),
83  * an error is generated and given to msg-error-handler. The edge
84  * is deleted in this case and false is returned.
85  *
86  * @param[in] edge The edge to add
87  * @return Whether the edge was added (if not, it was deleted, too)
88  */
89  virtual bool addEdge(ROEdge* edge);
90 
91 
100  ROEdge* getEdge(const std::string& name) const {
101  return myEdges.get(name);
102  }
103 
104 
105  /* @brief Adds a read node to the network
106  *
107  * If the node is already known (another one with the same id exists),
108  * an error is generated and given to msg-error-handler. The node
109  * is deleted in this case
110  *
111  * @param[in] node The node to add
112  */
113  void addNode(RONode* node);
114 
115 
122  RONode* getNode(const std::string& id) const {
123  return myNodes.get(id);
124  }
125 
126 
127  /* @brief Adds a read bus stop to the network
128  *
129  * If the bus stop is already known (another one with the same id exists),
130  * an error is generated and given to msg-error-handler. The stop
131  * is deleted in this case
132  *
133  * @param[in] node The stop to add
134  */
135  void addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop);
136 
137 
143  const SUMOVehicleParameter::Stop* getBusStop(const std::string& id) const {
144  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
145  if (it == myBusStops.end()) {
146  return 0;
147  }
148  return it->second;
149  }
151 
152 
153 
155 
156 
163  bool checkVType(const std::string& id);
164 
165 
175  virtual bool addVehicleType(SUMOVTypeParameter* type);
176 
177 
191  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
192 
193 
206  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
207 
208 
209  /* @brief Adds a route definition to the network
210  *
211  * If the route definition is already known (another one with
212  * the same id exists), false is returned, but the route definition
213  * is not deleted.
214  *
215  * @param[in] def The route definition to add
216  * @return Whether the route definition could be added
217  * @todo Rename myRoutes to myRouteDefinitions
218  */
219  bool addRouteDef(RORouteDef* def);
220 
221 
229  RORouteDef* getRouteDef(const std::string& name) const {
230  return myRoutes.get(name);
231  }
232 
233 
234  /* @brief Adds a vehicle to the network
235  *
236  * If the vehicle is already known (another one with the same id
237  * exists), false is returned, but the vehicle is not deleted.
238  *
239  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
240  *
241  * @param[in] id The id of the vehicle to add
242  * @param[in] veh The vehicle to add
243  * @return Whether the vehicle could be added
244  */
245  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
246 
247 
248  /* @brief Adds a flow of vehicles to the network
249  *
250  * If the flow is already known (another one with the same id
251  * exists), false is returned, but the vehicle parameter are not deleted.
252  *
253  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
254  *
255  * @param[in] flow The parameter of the flow to add
256  * @return Whether the flow could be added
257  */
258  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
259 
260 
261  /* @brief Adds a person to the network
262  *
263  * @param[in] depart The departure time of the person
264  * @param[in] desc The xml description of the person
265  */
266  void addPerson(const SUMOTime depart, const std::string desc);
267  // @}
268 
269 
271 
272 
286 
287 
289  virtual bool furtherStored();
291 
292 
293 
294 
295 
306  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
307 
308 
310  void closeOutput();
311 
312 
314  unsigned int getEdgeNo() const;
315 
317  unsigned int getEdgeNoWithoutInternal() const;
318 
319  const std::map<std::string, ROEdge*>& getEdgeMap() const;
320 
321  bool hasRestrictions() const;
322 
323  void setRestrictionFound();
324 
325  OutputDevice* getRouteOutput(const bool alternative = false) {
326  if (alternative) {
328  }
329  return myRoutesOutput;
330  }
331 
332 protected:
333  bool computeRoute(OptionsCont& options,
334  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
335 
338  return myVehicles;
339  }
340 
341 
342  void checkFlows(SUMOTime time);
343 
344 
345 protected:
347  std::set<std::string> myVehIDs;
348 
351 
354 
356  std::map<std::string, SUMOVehicleParameter::Stop*> myBusStops;
357 
360 
362  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
365 
368 
371 
374 
377 
379  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
381 
383  std::map<std::string, std::vector<SUMOTime> > myDepartures;
384 
387 
390 
393 
395  unsigned int myReadRouteNo;
396 
398  unsigned int myDiscardedRouteNo;
399 
401  unsigned int myWrittenRouteNo;
402 
405 
408 
409 private:
411  RONet(const RONet& src);
412 
414  RONet& operator=(const RONet& src);
415 
416 };
417 
418 
419 #endif
420 
421 /****************************************************************************/
422