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 
248  void moveAdditionalGeometry(SUMOReal offsetx, SUMOReal offsety);
249 
251  void commmitAdditionalGeometryMoved(SUMOReal oldPosx, SUMOReal oldPosy, GNEUndoList* undoList);
252 
256  void writeAdditional(OutputDevice& device, const std::string&);
257 
260  bool addEdge(GNEEdge* edge);
261 
264  bool removeEdge(GNEEdge* edge);
265 
267  std::string getFilename() const;
268 
270  SUMOReal getProbability() const;
271 
273  bool getOff() const;
274 
276  void setFilename(std::string filename);
277 
279  void setProbability(SUMOReal probability);
280 
282  void setOff(bool off);
283 
288 
289  const std::string& getParentName() const;
294  void drawGL(const GUIVisualizationSettings& s) const;
296 
299  /* @brief method for getting the Attribute of an XML key
300  * @param[in] key The attribute key
301  * @return string with the value associated to key
302  */
303  std::string getAttribute(SumoXMLAttr key) const;
304 
305  /* @brief method for setting the attribute and letting the object perform additional changes
306  * @param[in] key The attribute key
307  * @param[in] value The new value
308  * @param[in] undoList The undoList on which to register changes
309  */
310  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
311 
312  /* @brief method for checking if the key and their correspond attribute are valids
313  * @param[in] key The attribute key
314  * @param[in] value The value asociated to key key
315  * @return true if the value is valid, false in other case
316  */
317  bool isValid(SumoXMLAttr key, const std::string& value);
319 
320 protected:
322  std::string myFilename;
323 
326 
328  bool myOff;
329 
331  std::set<rerouterInterval> myRerouterIntervals;
332 
333 private:
335  void setAttribute(SumoXMLAttr key, const std::string& value);
336 
338  GNERerouter(const GNERerouter&);
339 
342 };
343 
344 #endif
345 
346 /****************************************************************************/
SUMOReal getProbability() const
get probability of rerouter
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.
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 getOff() const
get attribute to enable or disable inactive initially
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
std::string getAttribute(SumoXMLAttr key) const
Position getPositionInView() const
Returns position of Rerouter in view.
void setOff(bool off)
set attribute to enable or disable inactive initially
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:328
const std::string & getParentName() const
Returns the name of the parent object (if any)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void writeAdditional(OutputDevice &device, const std::string &)
writte additional element into a xml file
void moveAdditionalGeometry(SUMOReal offsetx, SUMOReal offsety)
change the position of the rerouter geometry
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)
method for setting the attribute and letting the object perform additional changes ...
std::set< rerouterInterval > myRerouterIntervals
set with the rerouterInterval
Definition: GNERerouter.h:331
void setProbability(SUMOReal probability)
set probability of rerouter
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
std::vector< routeProbReroute * > myRouteProbReroutes
vector with the routeProbReroutes
Definition: GNERerouter.h:218
std::string myFilename
filename of rerouter
Definition: GNERerouter.h:322
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
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::vector< std::string > getDisallowVehicles() const
get disallow vehicles
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:55
std::string getClosedEdgeId() const
get closed edge Id
void commmitAdditionalGeometryMoved(SUMOReal oldPosx, SUMOReal oldPosy, GNEUndoList *undoList)
updated geometry changes in the attributes of additional
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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
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
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
std::string getFilename() const
get filename of rerouter
void insertDisallowVehicle(std::string vehicleid)
insert a disallow vehicle
SUMOReal myProbability
probability of rerouter
Definition: GNERerouter.h:325
std::vector< std::string > getAllowVehicles() const
get allow vehicles
void setFilename(std::string filename)
set filename of rerouter
void openAdditionalDialog()
open GNERerouterDialog
std::string myClosedEdgeId
edge ID
Definition: GNERerouter.h:90