SUMO - Simulation of Urban MObility
GNERouteProbReroute.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>
31 
32 #include "GNERouteProbReroute.h"
33 #include "GNEEdge.h"
34 
35 
36 // ===========================================================================
37 // member method definitions
38 // ===========================================================================
39 
40 GNERouteProbReroute::GNERouteProbReroute(GNERerouterInterval& rerouterIntervalParent, std::string newRouteId, double probability) :
41  myRerouterIntervalParent(&rerouterIntervalParent),
42  myNewRouteId(newRouteId),
43  myProbability(probability),
45  // set probability manually to avoid non valid values
46  setProbability(probability);
47 }
48 
49 
51 }
52 
53 
54 std::string
56  return myNewRouteId;
57 }
58 
59 
60 void
61 GNERouteProbReroute::setNewRouteId(std::string newRouteId) {
62  myNewRouteId = newRouteId;
63 }
64 
65 
66 double
68  return myProbability;
69 }
70 
71 
72 bool
74  if (probability >= 0 && probability <= 1) {
75  myProbability = probability;
76  return true;
77  } else {
78  return false;
79  }
80 }
81 
82 
85  return myTag;
86 }
87 
88 
92 }
93 
94 
95 bool
96 GNERouteProbReroute::operator==(const GNERouteProbReroute& routeProbReroute) const {
97  if ((myRerouterIntervalParent == routeProbReroute.myRerouterIntervalParent) &&
98  (myNewRouteId == routeProbReroute.myNewRouteId) &&
99  (myProbability && routeProbReroute.myProbability)) {
100  return true;
101  } else {
102  return false;
103  }
104 }
105 
106 /****************************************************************************/
bool operator==(const GNERouteProbReroute &routeProbReroute) const
overload == operator
SumoXMLTag
Numbers representing SUMO-XML - element names.
const GNERerouterInterval & getRerouterIntervalParent() const
get rerouter interval parent
std::string getNewRouteId() const
get new route id
std::string myNewRouteId
id of new route
double myProbability
probability with which a vehicle will use the given edge as destination
SumoXMLTag myTag
XML Tag of route probability reroute.
GNERouteProbReroute(GNERerouterInterval &rerouterIntervalParent, std::string newRouteId, double probability)
constructor
double getProbability() const
get probability
bool setProbability(double probability)
set probability, if the new probability is valid
~GNERouteProbReroute()
destructor
void setNewRouteId(std::string newRouteId)
set new route id
GNERerouterInterval * myRerouterIntervalParent
reference to rerouter interval parent
probability of route of a reroute
SumoXMLTag getTag() const
get tag