SUMO - Simulation of Urban MObility
GNERerouterInterval.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 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 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <utils/common/ToString.h>
32 
33 #include "GNERerouterInterval.h"
34 #include "GNEEdge.h"
35 #include "GNELane.h"
36 
37 
38 // ===========================================================================
39 // member method definitions
40 // ===========================================================================
41 
42 GNERerouterInterval::GNERerouterInterval(GNERerouter* rerouterParent, double begin, double end) :
43  myRerouterParent(rerouterParent),
44  myBegin(begin),
45  myEnd(end),
46  myTag(SUMO_TAG_INTERVAL) {
47  assert(begin <= end);
48 }
49 
50 
52 }
53 
54 
55 bool
57  if (std::find(myClosingLaneReroutes.begin(), myClosingLaneReroutes.end(), clr) != myClosingLaneReroutes.end()) {
58  WRITE_WARNING(toString(clr.getTag()) + " for lane '" + clr.getClosedLane()->getID() + "' was already inserted; duplicates aren't allowed");
59  return false;
60  } else {
61  myClosingLaneReroutes.push_back(clr);
62  return true;
63  }
64 }
65 
66 
67 bool
69  std::vector<GNEClosingLaneReroute>::iterator i = std::find(myClosingLaneReroutes.begin(), myClosingLaneReroutes.end(), clr);
70  if (i == myClosingLaneReroutes.end()) {
71  WRITE_WARNING(toString(clr.getTag()) + " for lane '" + clr.getClosedLane()->getID() + "' wasn't previously inserted");
72  return false;
73  } else {
74  myClosingLaneReroutes.erase(i);
75  return true;
76  }
77 }
78 
79 
80 bool
82  if (std::find(myClosingReroutes.begin(), myClosingReroutes.end(), cr) != myClosingReroutes.end()) {
83  WRITE_WARNING(toString(cr.getTag()) + " for edge '" + cr.getClosedEdge()->getID() + "' was already inserted; duplicates aren't allowed");
84  return false;
85  } else {
86  myClosingReroutes.push_back(cr);
87  return true;
88  }
89 }
90 
91 
92 bool
94  std::vector<GNEClosingReroute>::iterator i = std::find(myClosingReroutes.begin(), myClosingReroutes.end(), cr);
95  if (i == myClosingReroutes.end()) {
96  WRITE_WARNING(toString(cr.getTag()) + " for edge '" + cr.getClosedEdge()->getID() + "' wasn't previously inserted");
97  return false;
98  } else {
99  myClosingReroutes.erase(i);
100  return true;
101  }
102 }
103 
104 
105 bool
107  if (std::find(myDestProbReroutes.begin(), myDestProbReroutes.end(), dpr) != myDestProbReroutes.end()) {
108  WRITE_WARNING(toString(dpr.getTag()) + " to edge '" + dpr.getNewDestination()->getID() + "' was already inserted; duplicates aren't allowed");
109  return false;
110  } else {
111  myDestProbReroutes.push_back(dpr);
112  return true;
113  }
114 }
115 
116 
117 bool
119  std::vector<GNEDestProbReroute>::iterator i = std::find(myDestProbReroutes.begin(), myDestProbReroutes.end(), dpr);
120  if (i == myDestProbReroutes.end()) {
121  WRITE_WARNING(toString(dpr.getTag()) + " to edge '" + dpr.getNewDestination()->getID() + "' wasn't previously inserted");
122  return false;
123  } else {
124  myDestProbReroutes.erase(i);
125  return true;
126  }
127 }
128 
129 
130 bool
132  if (std::find(myRouteProbReroutes.begin(), myRouteProbReroutes.end(), rpr) != myRouteProbReroutes.end()) {
133  WRITE_WARNING(toString(rpr.getTag()) + " for route '" + rpr.getNewRouteId() + "' was already inserted; duplicates aren't allowed");
134  return false;
135  } else {
136  myRouteProbReroutes.push_back(rpr);
137  return true;
138  }
139 }
140 
141 
142 bool
144  std::vector<GNERouteProbReroute>::iterator i = std::find(myRouteProbReroutes.begin(), myRouteProbReroutes.end(), rpr);
145  if (i == myRouteProbReroutes.end()) {
146  WRITE_WARNING(toString(rpr.getTag()) + " for route '" + rpr.getNewRouteId() + "' wasn't previously inserted");
147  return false;
148  } else {
149  myRouteProbReroutes.erase(i);
150  return true;
151  }
152 }
153 
154 
157  return myRerouterParent;
158 }
159 
160 
163  return myTag;
164 }
165 
166 
167 double
169  return myBegin;
170 }
171 
172 
173 double
175  return myEnd;
176 }
177 
178 
179 void
181  myBegin = begin;
182 }
183 
184 
185 void
187  myEnd = end;
188 }
189 
190 
191 const std::vector<GNEClosingLaneReroute>&
193  return myClosingLaneReroutes;
194 }
195 
196 
197 const std::vector<GNEClosingReroute>&
199  return myClosingReroutes;
200 }
201 
202 
203 const std::vector<GNEDestProbReroute>&
205  return myDestProbReroutes;
206 }
207 
208 
209 const std::vector<GNERouteProbReroute>&
211  return myRouteProbReroutes;
212 }
213 
214 
215 void
216 GNERerouterInterval::setClosingLaneReroutes(const std::vector<GNEClosingLaneReroute>& closingLaneReroutes) {
217  myClosingLaneReroutes = closingLaneReroutes;
218 }
219 
220 
221 void
222 GNERerouterInterval::setClosingReroutes(const std::vector<GNEClosingReroute>& closingReroutes) {
223  myClosingReroutes = closingReroutes;
224 }
225 
226 
227 void
228 GNERerouterInterval::setDestProbReroutes(const std::vector<GNEDestProbReroute>& destProbReroutes) {
229  myDestProbReroutes = destProbReroutes;
230 }
231 
232 
233 void
234 GNERerouterInterval::setRouteProbReroutes(const std::vector<GNERouteProbReroute>& rerouteProbabilityReroutes) {
235  myRouteProbReroutes = rerouteProbabilityReroutes;
236 }
237 
238 
241  if (this != &rerouterInterval) {
242  myRerouterParent = rerouterInterval.myRerouterParent;
243  myBegin = rerouterInterval.myBegin;
244  myEnd = rerouterInterval.myEnd;
245  }
246  return *this;
247 }
248 
249 
250 bool
251 GNERerouterInterval::operator==(const GNERerouterInterval& rerouterInterval) const {
252  return (myBegin == rerouterInterval.myBegin) && (myEnd == rerouterInterval.myEnd);
253 }
254 
255 
256 bool
257 GNERerouterInterval::operator>(const GNERerouterInterval& rerouterInterval) const {
258  if (myBegin > rerouterInterval.myBegin) {
259  return true;
260  } else if (myBegin == rerouterInterval.myBegin) {
261  return (myEnd > rerouterInterval.myEnd);
262  } else {
263  return false;
264  }
265 }
266 
267 
268 bool
269 GNERerouterInterval::operator>=(const GNERerouterInterval& rerouterInterval) const {
270  if (myBegin > rerouterInterval.myBegin) {
271  return true;
272  } else if (myBegin == rerouterInterval.myBegin) {
273  return (myEnd >= rerouterInterval.myEnd);
274  } else {
275  return false;
276  }
277 }
278 
279 
280 bool
281 GNERerouterInterval::operator<(const GNERerouterInterval& rerouterInterval) const {
282  if (myBegin < rerouterInterval.myBegin) {
283  return true;
284  } else if (myBegin == rerouterInterval.myBegin) {
285  return (myEnd < rerouterInterval.myEnd);
286  } else {
287  return false;
288  }
289 }
290 
291 
292 bool
293 GNERerouterInterval::operator<=(const GNERerouterInterval& rerouterInterval) const {
294  if (myBegin < rerouterInterval.myBegin) {
295  return true;
296  } else if (myBegin == rerouterInterval.myBegin) {
297  return (myEnd <= rerouterInterval.myEnd);
298  } else {
299  return false;
300  }
301 }
302 
303 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool operator==(const GNERerouterInterval &rerouterInterval) const
overload operator =
std::string getNewRouteId() const
get new route id
SumoXMLTag getTag() const
get tag
SumoXMLTag getTag() const
get tag
bool operator<(const GNERerouterInterval &rerouterInterval) const
overload operator <
double getBegin() const
get begin time
const std::vector< GNEClosingReroute > & getClosingReroutes() const
get closing reroutes
bool operator>=(const GNERerouterInterval &rerouterInterval) const
overload operator >=
std::vector< GNEClosingReroute > myClosingReroutes
vector with the closingReroutes
GNERerouterInterval(GNERerouter *rerouterParent, double begin, double end)
constructor
void setBegin(double begin)
set begin time
std::vector< GNEClosingLaneReroute > myClosingLaneReroutes
vector with the closingLaneReroutes
void setClosingLaneReroutes(const std::vector< GNEClosingLaneReroute > &closingLaneReroutes)
set closing reroutes
GNEEdge * getClosedEdge() const
get closed edge
bool removeClosingLaneReroutes(const GNEClosingLaneReroute &clr)
remove a previously inserted closing reroute
GNERerouterInterval & operator=(const GNERerouterInterval &rerouterInterval)
overload operator =
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
const std::vector< GNEDestProbReroute > & getDestProbReroutes() const
get destiny probability reroutes
bool removeClosingReroutes(const GNEClosingReroute &cr)
remove a previously inserted closing reroute
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
bool insertDestProbReroutes(const GNEDestProbReroute &dpr)
insert destiny probability reroute
const std::vector< GNEClosingLaneReroute > & getClosingLaneReroutes() const
get closing reroutes
bool insertClosinLanegReroutes(const GNEClosingLaneReroute &clr)
insert a new closing lane reroute
bool insertClosingReroutes(const GNEClosingReroute &cr)
insert a new closing lane reroute
void setRouteProbReroutes(const std::vector< GNERouteProbReroute > &rerouteProbabilityReroutes)
set reoute probability reroutes
SumoXMLTag getTag() const
get tag
SumoXMLTag getTag() const
get tag
std::vector< GNEDestProbReroute > myDestProbReroutes
vector with the destProbReroutes
double myBegin
begin timeStep
GNERerouter * getRerouterParent() const
get rerouter parent
const std::string getID() const
function to support debugging
double myEnd
end timeStep
std::vector< GNERouteProbReroute > myRouteProbReroutes
vector with the routeProbReroutes
bool removeRouteProbReroute(const GNERouteProbReroute &rpr)
remove a previously inserted route probability reroute
SumoXMLTag getTag() const
get tag
GNERerouter * myRerouterParent
pointer to rerouter parent
bool operator>(const GNERerouterInterval &rerouterInterval) const
overload operator >
void setEnd(double end)
set end time
bool operator<=(const GNERerouterInterval &rerouterInterval) const
overload operator <=
bool removeDestProbReroutes(const GNEDestProbReroute &dpr)
remove a previously inserted destiny probability reroute
GNELane * getClosedLane() const
get closed lane Id
GNEEdge * getNewDestination() const
get edge destination
an aggreagated-output interval
const std::vector< GNERouteProbReroute > & getRouteProbReroutes() const
get reoute probability reroutes
SumoXMLTag myTag
XML Tag of a rerouter interval.
bool insertRouteProbReroute(const GNERouteProbReroute &rpr)
insert route probability reroute
double getEnd() const
get end time
~GNERerouterInterval()
destructor
void setClosingReroutes(const std::vector< GNEClosingReroute > &closingReroutes)
set closing reroutes
void setDestProbReroutes(const std::vector< GNEDestProbReroute > &destProbReroutes)
set destiny probability reroutes