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-2012 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 <string>
35 #include <set>
36 #include <fstream>
37 #include <deque>
38 #include <vector>
39 #include "ROEdge.h"
40 #include "RONode.h"
41 #include "ROVehicleCont.h"
42 #include "ROVehicle.h"
43 #include "RORouteDef.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class RONode;
52 class RORouteDef;
53 class OptionsCont;
54 class OutputDevice;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
68 class RONet {
69  friend class RouteAggregator;
70 
71 public:
73  RONet() ;
74 
75 
77  virtual ~RONet() ;
78 
79 
81 
82 
83  /* @brief Adds a read edge to the network
84  *
85  * If the edge is already known (another one with the same id exists),
86  * an error is generated and given to msg-error-handler. The edge
87  * is deleted in this case and false is returned.
88  *
89  * @param[in] edge The edge to add
90  * @return Whether the edge was added (if not, it was deleted, too)
91  */
92  virtual bool addEdge(ROEdge* edge) ;
93 
94 
104  ROEdge* getEdge(const std::string& name) const {
105  return myEdges.get(name);
106  }
107 
108 
109  /* @brief Adds a read node to the network
110  *
111  * If the node is already known (another one with the same id exists),
112  * an error is generated and given to msg-error-handler. The node
113  * is deleted in this case
114  *
115  * @param[in] node The node to add
116  */
117  void addNode(RONode* node) ;
118 
119 
126  RONode* getNode(const std::string& id) const {
127  return myNodes.get(id);
128  }
130 
131 
132 
134 
135 
136  /* @brief Adds a read vehicle type definition to the network
137  *
138  * If the vehicle type definition is already known (another one with
139  * the same id exists), false is returned, and the vehicle type
140  * is deleted.
141  *
142  * @param[in] def The vehicle type to add
143  * @return Whether the vehicle type could be added
144  */
145  virtual bool addVehicleType(SUMOVTypeParameter* type) ;
146 
147 
160  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id) ;
161 
162 
163  /* @brief Adds a route definition to the network
164  *
165  * If the route definition is already known (another one with
166  * the same id exists), false is returned, but the route definition
167  * is not deleted.
168  *
169  * @param[in] def The route definition to add
170  * @return Whether the route definition could be added
171  * @todo Rename myRoutes to myRouteDefinitions
172  */
173  bool addRouteDef(RORouteDef* def) ;
174 
175 
183  RORouteDef* getRouteDef(const std::string& name) const {
184  return myRoutes.get(name);
185  }
186 
187 
188  /* @brief Adds a vehicle to the network
189  *
190  * If the vehicle is already known (another one with the same id
191  * exists), false is returned, but the vehicle is not deleted.
192  *
193  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
194  *
195  * @param[in] id The id of the vehicle to add
196  * @param[in] veh The vehicle to add
197  * @return Whether the vehicle could be added
198  */
199  virtual bool addVehicle(const std::string& id, ROVehicle* veh) ;
200  // @}
201 
202 
203 
205 
206 
220 
221 
223  virtual bool furtherStored();
225 
226 
227 
228 
229 
241  void openOutput(const std::string& filename, bool useAlternatives, const std::string& typefilename);
242 
243 
245  void closeOutput() ;
246 
247 
248 
249 
257 
258 
265  const ROEdge* getRandomSource() const ;
266 
267 
275 
276 
283  const ROEdge* getRandomDestination() const ;
284 
285 
287  unsigned int getEdgeNo() const;
288 
289  const std::map<std::string, ROEdge*> &getEdgeMap() const;
290 
291  bool hasRestrictions() const;
292 
293  void setRestrictionFound();
294 
295 protected:
296  bool computeRoute(OptionsCont& options,
297  SUMOAbstractRouter<ROEdge, ROVehicle> &router, const ROVehicle* const veh);
298 
300  void checkSourceAndDestinations() const;
301 
302 
305  return myVehicles;
306  }
307 
308 
309 protected:
311  std::set<std::string> myVehIDs;
312 
315 
318 
321 
324 
327 
330 
332  mutable std::vector<ROEdge*> mySourceEdges;
333 
335  mutable std::vector<ROEdge*> myDestinationEdges;
336 
339 
342 
345 
347  unsigned int myReadRouteNo;
348 
350  unsigned int myDiscardedRouteNo;
351 
353  unsigned int myWrittenRouteNo;
354 
357 
358 
359 private:
361  RONet(const RONet& src);
362 
364  RONet& operator=(const RONet& src);
365 
366 };
367 
368 
369 #endif
370 
371 /****************************************************************************/
372