SUMO - Simulation of Urban MObility
GNERerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNERerouter_h
21 #define GNERerouter_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNEAdditionalSet.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 
39 class GNEEdge;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class GNERerouter : public GNEAdditionalSet {
49 public:
50 
51  // ===========================================================================
52  // class closingReroute
53  // ===========================================================================
54 
56  public:
58  closingReroute(std::string closedEdgeId, std::vector<std::string> allowVehicles, std::vector<std::string> disallowVehicles);
59 
62 
65  void insertAllowVehicle(std::string vehicleid);
66 
69  void removeAllowVehicle(std::string vehicleid);
70 
73  void insertDisallowVehicle(std::string vehicleid);
74 
77  void removeDisallowVehicle(std::string vehicleid);
78 
80  std::vector<std::string> getAllowVehicles() const;
81 
83  std::vector<std::string> getDisallowVehicles() const;
84 
86  std::string getClosedEdgeId() const;
87 
88  private:
90  std::string myClosedEdgeId;
91 
93  std::vector<std::string> myAllowVehicles;
94 
96  std::vector<std::string> myDisallowVehicles;
97  };
98 
99  // ===========================================================================
100  // class destProbReroute
101  // ===========================================================================
102 
104  public:
106  destProbReroute(std::string newDestinationId, SUMOReal probability);
107 
109  ~destProbReroute();
110 
112  std::string getNewDestinationId() const;
113 
115  SUMOReal getProbability() const;
116 
119  void setProbability(SUMOReal probability);
120 
121  private:
123  std::string myNewDestinationId;
124 
127  };
128 
129  // ===========================================================================
130  // class routeProbReroute
131  // ===========================================================================
132 
134  public:
136  routeProbReroute(std::string newRouteId, SUMOReal probability);
137 
139  ~routeProbReroute();
140 
142  std::string getNewRouteId() const;
143 
145  SUMOReal getProbability() const;
146 
149  void setProbability(SUMOReal probability);
150 
151  private:
153  std::string myNewRouteId;
154 
157  };
158 
159  // ===========================================================================
160  // class rerouterInterval
161  // ===========================================================================
162 
163  class rerouterInterval : public std::pair<SUMOTime, SUMOTime> {
164  public:
166  rerouterInterval(SUMOTime begin, SUMOTime end);
167 
169  ~rerouterInterval();
170 
173  void insertClosingReroutes(closingReroute* cr);
174 
177  void removeClosingReroutes(closingReroute* cr);
178 
181  void insertDestProbReroutes(destProbReroute* dpr);
182 
185  void removeDestProbReroutes(destProbReroute* dpr);
186 
189  void insertRouteProbReroute(routeProbReroute* rpr);
190 
193  void removeRouteProbReroute(routeProbReroute* rpr);
194 
196  SUMOTime getBegin() const;
197 
199  SUMOTime getEnd() const;
200 
202  std::vector<closingReroute*> getClosingReroutes() const;
203 
205  std::vector<destProbReroute*> getDestProbReroutes() const;
206 
208  std::vector<routeProbReroute*> getRouteProbReroutes() const;
209 
210  private:
212  std::vector<closingReroute*> myClosingReroutes;
213 
215  std::vector<destProbReroute*> myDestProbReroutes;
216 
218  std::vector<routeProbReroute*> myRouteProbReroutes;
219  };
220 
232  GNERerouter(const std::string& id, GNEViewNet* viewNet, Position pos, std::vector<GNEEdge*> edges, const std::string& filename, SUMOReal probability, bool off, const std::set<rerouterInterval>& rerouterIntervals, bool blocked);
233 
235  ~GNERerouter();
236 
239  void updateGeometry();
240 
242  Position getPositionInView() const;
243 
245  void openAdditionalDialog();
246 
252  void moveAdditional(SUMOReal posx, SUMOReal posy, GNEUndoList* undoList);
253 
257  void writeAdditional(OutputDevice& device, const std::string&);
258 
261  bool addEdge(GNEEdge* edge);
262 
265  bool removeEdge(GNEEdge* edge);
266 
268  std::string getFilename() const;
269 
271  SUMOReal getProbability() const;
272 
274  bool getOff() const;
275 
277  void setFilename(std::string filename);
278 
280  void setProbability(SUMOReal probability);
281 
283  void setOff(bool off);
284 
289 
290  const std::string& getParentName() const;
295  void drawGL(const GUIVisualizationSettings& s) const;
297 
300  /* @brief method for getting the Attribute of an XML key
301  * @param[in] key The attribute key
302  * @return string with the value associated to key
303  */
304  std::string getAttribute(SumoXMLAttr key) const;
305 
306  /* @brief method for setting the attribute and letting the object perform additional changes
307  * @param[in] key The attribute key
308  * @param[in] value The new value
309  * @param[in] undoList The undoList on which to register changes
310  */
311  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
312 
313  /* @brief method for checking if the key and their correspond attribute are valids
314  * @param[in] key The attribute key
315  * @param[in] value The value asociated to key key
316  * @return true if the value is valid, false in other case
317  */
318  bool isValid(SumoXMLAttr key, const std::string& value);
320 
321 protected:
323  std::string myFilename;
324 
327 
329  bool myOff;
330 
332  std::set<rerouterInterval> myRerouterIntervals;
333 
334 private:
336  void setAttribute(SumoXMLAttr key, const std::string& value);
337 
339  GNERerouter(const GNERerouter&);
340 
343 };
344 
345 #endif
346 
347 /****************************************************************************/
std::vector< std::string > getDisallowVehicles() const
get disallow vehicles
long long int SUMOTime
Definition: SUMOTime.h:43
std::vector< std::string > myAllowVehicles
vector of allow vehicles
Definition: GNERerouter.h:93
GNERerouter & operator=(const GNERerouter &)
Invalidated assignment operator.
~GNERerouter()
Destructor.
bool addEdge(GNEEdge *edge)
add edge to rerouter
Stores the information about how to visualize structures.
std::vector< closingReroute * > myClosingReroutes
vector with the closingReroutes
Definition: GNERerouter.h:212
void setOff(bool off)
set attribute to enable or disable inactive initially
const std::string & getParentName() const
Returns the name of the parent object (if any)
SUMOReal myProbability
probability with which a vehicle will use the given edge as destination
Definition: GNERerouter.h:126
bool myOff
attribute to enable or disable inactive initially
Definition: GNERerouter.h:329
std::string getAttribute(SumoXMLAttr key) const
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void writeAdditional(OutputDevice &device, const std::string &)
writte additional element into a xml file
std::string getClosedEdgeId() const
get closed edge Id
bool getOff() const
get attribute to enable or disable inactive initially
An Element wich group additionalSet elements.
void removeDisallowVehicle(std::string vehicleid)
remove a previously inserted disallow vehicle
void removeAllowVehicle(std::string vehicleid)
remove a previously inserted allow vehicle
Definition: GNERerouter.cpp:98
void insertAllowVehicle(std::string vehicleid)
insert an allow vehicle
Definition: GNERerouter.cpp:85
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::set< rerouterInterval > myRerouterIntervals
set with the rerouterInterval
Definition: GNERerouter.h:332
void setProbability(SUMOReal probability)
set probability of rerouter
bool isValid(SumoXMLAttr key, const std::string &value)
std::vector< routeProbReroute * > myRouteProbReroutes
vector with the routeProbReroutes
Definition: GNERerouter.h:218
std::string myFilename
filename of rerouter
Definition: GNERerouter.h:323
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
std::string myNewDestinationId
id of new edge destination
Definition: GNERerouter.h:123
GNERerouter(const std::string &id, GNEViewNet *viewNet, Position pos, std::vector< GNEEdge * > edges, const std::string &filename, SUMOReal probability, bool off, const std::set< rerouterInterval > &rerouterIntervals, bool blocked)
Constructor.
bool removeEdge(GNEEdge *edge)
remove edge of rerouter
SUMOReal myProbability
probability with which a vehicle will use the given edge as destination
Definition: GNERerouter.h:156
std::string myNewRouteId
id of new route
Definition: GNERerouter.h:153
std::string getFilename() const
get filename of rerouter
std::vector< std::string > getAllowVehicles() const
get allow vehicles
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:54
std::vector< std::string > myDisallowVehicles
vector of disallow vehicles
Definition: GNERerouter.h:96
std::vector< destProbReroute * > myDestProbReroutes
vector with the destProbReroutes
Definition: GNERerouter.h:215
void moveAdditional(SUMOReal posx, SUMOReal posy, GNEUndoList *undoList)
change the position of the rerouter geometry
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
closingReroute(std::string closedEdgeId, std::vector< std::string > allowVehicles, std::vector< std::string > disallowVehicles)
constructor
Definition: GNERerouter.cpp:73
void updateGeometry()
update pre-computed geometry information
Position getPositionInView() const
Returns position of Rerouter in view.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
void insertDisallowVehicle(std::string vehicleid)
insert a disallow vehicle
SUMOReal myProbability
probability of rerouter
Definition: GNERerouter.h:326
void setFilename(std::string filename)
set filename of rerouter
void openAdditionalDialog()
open GNERerouterDialog
SUMOReal getProbability() const
get probability of rerouter
std::string myClosedEdgeId
edge ID
Definition: GNERerouter.h:90