SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSEdgeWeightsStorage.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A storage for edge travel times and efforts
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "MSEdgeWeightsStorage.h"
33 
34 #ifdef CHECK_MEMORY_LEAKS
35 #include <foreign/nvwa/debug_new.h>
36 #endif // CHECK_MEMORY_LEAKS
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43 }
44 
45 
47 }
48 
49 
50 bool
52  SUMOReal t, SUMOReal& value) const {
53  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::const_iterator i = myTravelTimes.find((MSEdge*) e);
54  if (i == myTravelTimes.end()) {
55  return false;
56  }
57  const ValueTimeLine<SUMOReal>& tl = (*i).second;
58  if (!tl.describesTime(t)) {
59  return false;
60  }
61  value = tl.getValue(t);
62  return true;
63 }
64 
65 
66 bool
68  SUMOReal t, SUMOReal& value) const {
69  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::const_iterator i = myEfforts.find((MSEdge*) e);
70  if (i == myEfforts.end()) {
71  return false;
72  }
73  const ValueTimeLine<SUMOReal>& tl = (*i).second;
74  if (!tl.describesTime(t)) {
75  return false;
76  }
77  value = tl.getValue(t);
78  return true;
79 }
80 
81 
82 void
84  SUMOReal begin, SUMOReal end,
85  SUMOReal value) {
86  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::iterator i = myTravelTimes.find((MSEdge*) e);
87  if (i == myTravelTimes.end()) {
89  i = myTravelTimes.find((MSEdge*) e);
90  }
91  (*i).second.add(begin, end, value);
92 }
93 
94 
95 void
97  SUMOReal begin, SUMOReal end,
98  SUMOReal value) {
99  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::iterator i = myEfforts.find((MSEdge*) e);
100  if (i == myEfforts.end()) {
102  i = myEfforts.find((MSEdge*) e);
103  }
104  (*i).second.add(begin, end, value);
105 }
106 
107 
108 void
110  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::iterator i = myTravelTimes.find((MSEdge*) e);
111  if (i != myTravelTimes.end()) {
112  myTravelTimes.erase(i);
113  }
114 }
115 
116 
117 void
119  std::map<MSEdge*, ValueTimeLine<SUMOReal> >::iterator i = myEfforts.find((MSEdge*) e);
120  if (i != myEfforts.end()) {
121  myEfforts.erase(i);
122  }
123 }
124 
125 
126 bool
128  return myTravelTimes.find((MSEdge*) e) != myTravelTimes.end();
129 }
130 
131 
132 bool
134  return myEfforts.find((MSEdge*) e) != myEfforts.end();
135 }
136 
137 
138 
139 /****************************************************************************/
140