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.sourceforge.net/
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 
101  ROEdge* getEdge(const std::string& name) const {
102  return myEdges.get(name);
103  }
104 
105 
106  /* @brief Adds a read node to the network
107  *
108  * If the node is already known (another one with the same id exists),
109  * an error is generated and given to msg-error-handler. The node
110  * is deleted in this case
111  *
112  * @param[in] node The node to add
113  */
114  void addNode(RONode* node);
115 
116 
123  RONode* getNode(const std::string& id) const {
124  return myNodes.get(id);
125  }
127 
128 
129 
131 
132 
139  bool checkVType(const std::string& id);
140 
141 
151  virtual bool addVehicleType(SUMOVTypeParameter* type);
152 
153 
167  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
168 
169 
182  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
183 
184 
185  /* @brief Adds a route definition to the network
186  *
187  * If the route definition is already known (another one with
188  * the same id exists), false is returned, but the route definition
189  * is not deleted.
190  *
191  * @param[in] def The route definition to add
192  * @return Whether the route definition could be added
193  * @todo Rename myRoutes to myRouteDefinitions
194  */
195  bool addRouteDef(RORouteDef* def);
196 
197 
205  RORouteDef* getRouteDef(const std::string& name) const {
206  return myRoutes.get(name);
207  }
208 
209 
210  /* @brief Adds a vehicle to the network
211  *
212  * If the vehicle is already known (another one with the same id
213  * exists), false is returned, but the vehicle is not deleted.
214  *
215  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
216  *
217  * @param[in] id The id of the vehicle to add
218  * @param[in] veh The vehicle to add
219  * @return Whether the vehicle could be added
220  */
221  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
222 
223 
224  /* @brief Adds a flow of vehicles to the network
225  *
226  * If the flow is already known (another one with the same id
227  * exists), false is returned, but the vehicle parameter are not deleted.
228  *
229  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
230  *
231  * @param[in] flow The parameter of the flow to add
232  * @return Whether the flow could be added
233  */
234  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
235 
236 
237  /* @brief Adds a person to the network
238  *
239  * @param[in] depart The departure time of the person
240  * @param[in] desc The xml description of the person
241  */
242  void addPerson(const SUMOTime depart, const std::string desc);
243  // @}
244 
245 
247 
248 
262 
263 
265  virtual bool furtherStored();
267 
268 
269 
270 
271 
282  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
283 
284 
286  void closeOutput();
287 
288 
290  unsigned int getEdgeNo() const;
291 
292  const std::map<std::string, ROEdge*>& getEdgeMap() const;
293 
294  bool hasRestrictions() const;
295 
296  void setRestrictionFound();
297 
298  OutputDevice* getRouteOutput(const bool alternative = false) {
299  if (alternative) {
301  }
302  return myRoutesOutput;
303  }
304 
305 protected:
306  bool computeRoute(OptionsCont& options,
307  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
308 
311  return myVehicles;
312  }
313 
314 
315  void checkFlows(SUMOTime time);
316 
317 
318 protected:
320  std::set<std::string> myVehIDs;
321 
324 
327 
330 
332  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
335 
338 
341 
344 
347 
349  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
351 
353  std::map<std::string, std::vector<SUMOTime> > myDepartures;
354 
357 
360 
363 
365  unsigned int myReadRouteNo;
366 
368  unsigned int myDiscardedRouteNo;
369 
371  unsigned int myWrittenRouteNo;
372 
375 
376 
377 private:
379  RONet(const RONet& src);
380 
382  RONet& operator=(const RONet& src);
383 
384 };
385 
386 
387 #endif
388 
389 /****************************************************************************/
390