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 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif
40 
41 // ===========================================================================
42 // member method definitions
43 // ===========================================================================
44 
46  myRerouterParent(rerouterParent),
47  myBegin(begin),
48  myEnd(end),
49  myTag(SUMO_TAG_INTERVAL) {
50  assert(begin <= end);
51 }
52 
53 
55 }
56 
57 
58 bool
60  // Check if was already inserted due uplicates aren't allowed
61  if (std::find(myClosingLaneReroutes.begin(), myClosingLaneReroutes.end(), clr) != myClosingLaneReroutes.end()) {
62  WRITE_WARNING(clr.getTag() + " with ID = " + clr.getClosedLane()->getID() + "' was already inserted; Duplicates aren't allowed");
63  return false;
64  } else {
65  // insert in vector
66  myClosingLaneReroutes.push_back(clr);
67  return true;
68  }
69 }
70 
71 
72 bool
74  std::vector<GNEClosingLaneReroute>::iterator i = std::find(myClosingLaneReroutes.begin(), myClosingLaneReroutes.end(), clr);
75  // check if exists
76  if (i == myClosingLaneReroutes.end()) {
77  WRITE_WARNING(clr.getTag() + " with ID = " + clr.getClosedLane()->getID() + "' wasn't previously inserted");
78  return false;
79  } else {
80  // remove it from vector
81  myClosingLaneReroutes.erase(i);
82  return true;
83  }
84 }
85 
86 
87 bool
89  // Check if was already inserted due uplicates aren't allowed
90  if (std::find(myClosingReroutes.begin(), myClosingReroutes.end(), cr) != myClosingReroutes.end()) {
91  WRITE_WARNING(cr.getTag() + " with ID = " + cr.getClosedEdge()->getID() + "' was already inserted; Duplicates aren't allowed");
92  return false;
93  } else {
94  // insert in vector
95  myClosingReroutes.push_back(cr);
96  return true;
97  }
98 }
99 
100 
101 bool
103  std::vector<GNEClosingReroute>::iterator i = std::find(myClosingReroutes.begin(), myClosingReroutes.end(), cr);
104  // check if exists
105  if (i == myClosingReroutes.end()) {
106  WRITE_WARNING(cr.getTag() + " with ID = " + cr.getClosedEdge()->getID() + "' wasn't previously inserted");
107  return false;
108  } else {
109  // remove it from vector
110  myClosingReroutes.erase(i);
111  return true;
112  }
113 }
114 
115 
116 bool
118  // Check if was already inserted due uplicates aren't allowed
119  if (std::find(myDestProbReroutes.begin(), myDestProbReroutes.end(), dpr) != myDestProbReroutes.end()) {
120  WRITE_WARNING(dpr.getTag() + " with ID = " + dpr.getNewDestination()->getID() + "' was already inserted; Duplicates aren't allowed");
121  return false;
122  } else {
123  // insert in vector
124  myDestProbReroutes.push_back(dpr);
125  return true;
126  }
127 }
128 
129 
130 bool
132  std::vector<GNEDestProbReroute>::iterator i = std::find(myDestProbReroutes.begin(), myDestProbReroutes.end(), dpr);
133  // check if exists
134  if (i == myDestProbReroutes.end()) {
135  WRITE_WARNING(dpr.getTag() + " with ID = " + dpr.getNewDestination()->getID() + "' wasn't previously inserted");
136  return false;
137  } else {
138  // remove it from vector
139  myDestProbReroutes.erase(i);
140  return true;
141  }
142 }
143 
144 
145 bool
147  // Check if was already inserted due uplicates aren't allowed
148  if (std::find(myRouteProbReroutes.begin(), myRouteProbReroutes.end(), rpr) != myRouteProbReroutes.end()) {
149  WRITE_WARNING(rpr.getTag() + " with ID = " + rpr.getNewRouteId() + "' was already inserted; Duplicates aren't allowed");
150  return false;
151  } else {
152  // insert in vector
153  myRouteProbReroutes.push_back(rpr);
154  return true;
155  }
156 }
157 
158 
159 bool
161  std::vector<GNERouteProbReroute>::iterator i = std::find(myRouteProbReroutes.begin(), myRouteProbReroutes.end(), rpr);
162  // check if exists
163  if (i == myRouteProbReroutes.end()) {
164  WRITE_WARNING(rpr.getTag() + " with ID = " + rpr.getNewRouteId() + "' wasn't previously inserted");
165  return false;
166  } else {
167  // remove it from vector
168  myRouteProbReroutes.erase(i);
169  return true;
170  }
171 }
172 
173 
176  return myRerouterParent;
177 }
178 
179 
182  return myTag;
183 }
184 
185 
186 SUMOReal
188  return myBegin;
189 }
190 
191 
192 SUMOReal
194  return myEnd;
195 }
196 
197 
198 void
200  myBegin = begin;
201 }
202 
203 
204 void
206  myEnd = end;
207 }
208 
209 
210 const std::vector<GNEClosingLaneReroute>&
212  return myClosingLaneReroutes;
213 }
214 
215 
216 const std::vector<GNEClosingReroute>&
218  return myClosingReroutes;
219 }
220 
221 
222 const std::vector<GNEDestProbReroute>&
224  return myDestProbReroutes;
225 }
226 
227 
228 const std::vector<GNERouteProbReroute>&
230  return myRouteProbReroutes;
231 }
232 
233 
234 void
235 GNERerouterInterval::setClosingLaneReroutes(const std::vector<GNEClosingLaneReroute>& closingLaneReroutes) {
236  myClosingLaneReroutes = closingLaneReroutes;
237 }
238 
239 
240 void
241 GNERerouterInterval::setClosingReroutes(const std::vector<GNEClosingReroute>& closingReroutes) {
242  myClosingReroutes = closingReroutes;
243 }
244 
245 
246 void
247 GNERerouterInterval::setDestProbReroutes(const std::vector<GNEDestProbReroute>& destProbReroutes) {
248  myDestProbReroutes = destProbReroutes;
249 }
250 
251 
252 void
253 GNERerouterInterval::setRouteProbReroutes(const std::vector<GNERouteProbReroute>& rerouteProbabilityReroutes) {
254  myRouteProbReroutes = rerouteProbabilityReroutes;
255 }
256 
257 
260  if (this != &rerouterInterval) {
261  myRerouterParent = rerouterInterval.myRerouterParent;
262  myBegin = rerouterInterval.myBegin;
263  myEnd = rerouterInterval.myEnd;
264  }
265  return *this;
266 }
267 
268 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
GNERerouter * getRerouterParent() const
get rerouter parent
std::string getNewRouteId() const
get new route id
const std::vector< GNEClosingLaneReroute > & getClosingLaneReroutes() const
get closing reroutes
void setEnd(SUMOReal end)
set end time
std::vector< GNEClosingReroute > myClosingReroutes
vector with the closingReroutes
GNELane * getClosedLane() const
get closed lane Id
std::vector< GNEClosingLaneReroute > myClosingLaneReroutes
vector with the closingLaneReroutes
void setBegin(SUMOReal begin)
set begin time
void setClosingLaneReroutes(const std::vector< GNEClosingLaneReroute > &closingLaneReroutes)
set closing reroutes
GNEEdge * getClosedEdge() const
get closed edge
const std::vector< GNEClosingReroute > & getClosingReroutes() const
get closing reroutes
SumoXMLTag getTag() const
get tag
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
SUMOReal getEnd() const
get end time
SumoXMLTag getTag() const
get tag
bool removeClosingReroutes(const GNEClosingReroute &cr)
remove a previously inserted closing reroute
SumoXMLTag getTag() const
get tag
bool insertDestProbReroutes(const GNEDestProbReroute &dpr)
insert destiny probability reroute
SUMOReal myEnd
end timeStep
bool insertClosinLanegReroutes(const GNEClosingLaneReroute &clr)
insert a new closing lane reroute
GNEEdge * getNewDestination() const
get edge destination
bool insertClosingReroutes(const GNEClosingReroute &cr)
insert a new closing lane reroute
void setRouteProbReroutes(const std::vector< GNERouteProbReroute > &rerouteProbabilityReroutes)
set reoute probability reroutes
GNERerouterInterval(GNERerouter *rerouterParent, SUMOReal begin, SUMOReal end)
constructor
std::vector< GNEDestProbReroute > myDestProbReroutes
vector with the destProbReroutes
SumoXMLTag getTag() const
get tag
const std::vector< GNERouteProbReroute > & getRouteProbReroutes() const
get reoute probability reroutes
const std::string getID() const
function to support debugging
std::vector< GNERouteProbReroute > myRouteProbReroutes
vector with the routeProbReroutes
bool removeRouteProbReroute(const GNERouteProbReroute &rpr)
remove a previously inserted route probability reroute
SUMOReal getBegin() const
get begin time
GNERerouter * myRerouterParent
pointer to rerouter parent
const std::vector< GNEDestProbReroute > & getDestProbReroutes() const
get destiny probability reroutes
bool removeDestProbReroutes(const GNEDestProbReroute &dpr)
remove a previously inserted destiny probability reroute
SumoXMLTag getTag() const
get tag
an aggreagated-output interval
#define SUMOReal
Definition: config.h:208
SumoXMLTag myTag
XML Tag of a rerouter interval.
SUMOReal myBegin
begin timeStep
bool insertRouteProbReroute(const GNERouteProbReroute &rpr)
insert route probability reroute
~GNERerouterInterval()
destructor
void setClosingReroutes(const std::vector< GNEClosingReroute > &closingReroutes)
set closing reroutes
void setDestProbReroutes(const std::vector< GNEDestProbReroute > &destProbReroutes)
set destiny probability reroutes