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"
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
52 class RONode;
53 class RORouteDef;
54 class OptionsCont;
55 class OutputDevice;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
69 class RONet {
70  friend class RouteAggregator;
71 
72 public:
74  RONet();
75 
76 
78  virtual ~RONet();
79 
80 
82 
83 
84  /* @brief Adds a read edge to the network
85  *
86  * If the edge is already known (another one with the same id exists),
87  * an error is generated and given to msg-error-handler. The edge
88  * is deleted in this case and false is returned.
89  *
90  * @param[in] edge The edge to add
91  * @return Whether the edge was added (if not, it was deleted, too)
92  */
93  virtual bool addEdge(ROEdge* edge);
94 
95 
105  ROEdge* getEdge(const std::string& name) const {
106  return myEdges.get(name);
107  }
108 
109 
110  /* @brief Adds a read node to the network
111  *
112  * If the node is already known (another one with the same id exists),
113  * an error is generated and given to msg-error-handler. The node
114  * is deleted in this case
115  *
116  * @param[in] node The node to add
117  */
118  void addNode(RONode* node);
119 
120 
127  RONode* getNode(const std::string& id) const {
128  return myNodes.get(id);
129  }
131 
132 
133 
135 
136 
143  bool checkVType(const std::string& id);
144 
145 
155  virtual bool addVehicleType(SUMOVTypeParameter* type);
156 
157 
171  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
172 
173 
186  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
187 
188 
189  /* @brief Adds a route definition to the network
190  *
191  * If the route definition is already known (another one with
192  * the same id exists), false is returned, but the route definition
193  * is not deleted.
194  *
195  * @param[in] def The route definition to add
196  * @return Whether the route definition could be added
197  * @todo Rename myRoutes to myRouteDefinitions
198  */
199  bool addRouteDef(RORouteDef* def);
200 
201 
209  RORouteDef* getRouteDef(const std::string& name) const {
210  return myRoutes.get(name);
211  }
212 
213 
214  /* @brief Adds a vehicle to the network
215  *
216  * If the vehicle is already known (another one with the same id
217  * exists), false is returned, but the vehicle is not deleted.
218  *
219  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
220  *
221  * @param[in] id The id of the vehicle to add
222  * @param[in] veh The vehicle to add
223  * @return Whether the vehicle could be added
224  */
225  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
226  // @}
227 
228 
229 
231 
232 
246 
247 
249  virtual bool furtherStored();
251 
252 
253 
254 
255 
267  void openOutput(const std::string& filename, bool useAlternatives, const std::string& typefilename);
268 
269 
271  void closeOutput();
272 
273 
274 
275 
283 
284 
291  const ROEdge* getRandomSource() const;
292 
293 
301 
302 
309  const ROEdge* getRandomDestination() const;
310 
311 
313  unsigned int getEdgeNo() const;
314 
315  const std::map<std::string, ROEdge*>& getEdgeMap() const;
316 
317  bool hasRestrictions() const;
318 
319  void setRestrictionFound();
320 
321 protected:
322  bool computeRoute(OptionsCont& options,
323  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
324 
326  void checkSourceAndDestinations() const;
327 
328 
331  return myVehicles;
332  }
333 
334 
335 protected:
337  std::set<std::string> myVehIDs;
338 
341 
344 
347 
349  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
352 
355 
358 
361 
363  mutable std::vector<ROEdge*> mySourceEdges;
364 
366  mutable std::vector<ROEdge*> myDestinationEdges;
367 
370 
373 
376 
378  unsigned int myReadRouteNo;
379 
381  unsigned int myDiscardedRouteNo;
382 
384  unsigned int myWrittenRouteNo;
385 
388 
389 
390 private:
392  RONet(const RONet& src);
393 
395  RONet& operator=(const RONet& src);
396 
397 };
398 
399 
400 #endif
401 
402 /****************************************************************************/
403