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 #ifdef CHECK_MEMORY_LEAKS
37 #include <foreign/nvwa/debug_new.h>
38 #endif
39 
40 // ===========================================================================
41 // member method definitions
42 // ===========================================================================
43 
44 GNERouteProbReroute::GNERouteProbReroute(GNERerouterInterval& rerouterIntervalParent, std::string newRouteId, SUMOReal probability) :
45  myRerouterIntervalParent(&rerouterIntervalParent),
46  myNewRouteId(newRouteId),
47  myProbability(probability),
49  // set probability manually to avoid non valid values
50  setProbability(probability);
51 }
52 
53 
55 }
56 
57 
58 std::string
60  return myNewRouteId;
61 }
62 
63 
64 void
65 GNERouteProbReroute::setNewRouteId(std::string newRouteId) {
66  myNewRouteId = newRouteId;
67 }
68 
69 
72  return myProbability;
73 }
74 
75 
76 bool
78  if (probability >= 0 && probability <= 1) {
79  myProbability = probability;
80  return true;
81  } else {
82  return false;
83  }
84 }
85 
86 
89  return myTag;
90 }
91 
92 
96 }
97 
98 
99 bool
101  if ((myRerouterIntervalParent == routeProbReroute.myRerouterIntervalParent) &&
102  (myNewRouteId == routeProbReroute.myNewRouteId) &&
103  (myProbability && routeProbReroute.myProbability)) {
104  return true;
105  } else {
106  return false;
107  }
108 }
109 
110 /****************************************************************************/
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string getNewRouteId() const
get new route id
GNERouteProbReroute(GNERerouterInterval &rerouterIntervalParent, std::string newRouteId, SUMOReal probability)
constructor
bool setProbability(SUMOReal probability)
set probability, if the new probability is valid
std::string myNewRouteId
id of new route
SumoXMLTag myTag
XML Tag of route probability reroute.
SUMOReal getProbability() const
get probability
SumoXMLTag getTag() const
get tag
~GNERouteProbReroute()
destructor
void setNewRouteId(std::string newRouteId)
set new route id
GNERerouterInterval * myRerouterIntervalParent
reference to rerouter interval parent
const GNERerouterInterval & getRerouterIntervalParent() const
get rerouter interval parent
probability of route of a reroute
SUMOReal myProbability
probability with which a vehicle will use the given edge as destination
#define SUMOReal
Definition: config.h:208
bool operator==(const GNERouteProbReroute &routeProbReroute)
overload == operator