45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
62 const bool isPermanent,
const RGBColor*
const c,
63 const std::vector<SUMOVehicleParameter::Stop>& stops)
64 :
Named(id), myEdges(edges), myAmPermanent(isPermanent),
65 myReferenceCounter(isPermanent ? 1 : 0),
66 myColor(c), myStops(stops) {}
88 return (
unsigned)
myEdges.size();
128 myDistDict[id] = std::make_pair(routeDist, permanent);
137 RouteDict::iterator it =
myDict.find(
id);
139 RouteDistDict::iterator it2 =
myDistDict.find(
id);
140 if (it2 ==
myDistDict.end() || it2->second.first->getOverallProb() == 0) {
143 return it2->second.first->get();
151 RouteDistDict::iterator it2 =
myDistDict.find(
id);
155 return it2->second.first;
162 delete i->second.first;
165 for (RouteDict::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
174 RouteDistDict::iterator it =
myDistDict.find(
id);
175 if (it !=
myDistDict.end() && !it->second.second) {
176 const std::vector<const MSRoute*>& routes = it->second.first->getVals();
177 for (std::vector<const MSRoute*>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
180 delete it->second.first;
189 for (RouteDict::const_iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
190 into.push_back((*i).first);
193 into.push_back((*i).first);
201 MSEdgeVector::const_iterator i =
myEdges.begin();
205 for (; i !=
myEdges.end(); ++i) {
211 if (upTo || i !=
myEdges.end() - 1) {
221 std::vector<MSEdge*>::const_iterator i = edgelist.begin();
222 for (; i != edgelist.end(); ++i) {
239 for (RouteDict::iterator it =
myDict.begin(); it !=
myDict.end(); ++it) {
257 for (MSEdgeVector::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
258 ret += (*i)->getLength();
266 bool isFirstIteration =
true;
268 MSEdgeVector::const_iterator it = std::find(
myEdges.begin(),
myEdges.end(), fromEdge);
274 if (fromEdge == toEdge) {
276 if (fromPos <= toPos) {
277 return toPos - fromPos;
278 }
else if (std::find(it + 1,
myEdges.end(), toEdge) ==
myEdges.end()) {
283 for (; it !=
end(); ++it) {
284 if ((*it) == toEdge && !isFirstIteration) {
288 const std::vector<MSLane*>& lanes = (*it)->getLanes();
289 distance += lanes[0]->getLength();
290 #ifdef HAVE_INTERNAL_LANES
292 for (std::vector<MSLane*>::const_iterator laneIt = lanes.begin(); laneIt != lanes.end(); ++laneIt) {
293 const MSLinkCont& links = (*laneIt)->getLinkCont();
294 for (MSLinkCont::const_iterator linkIt = links.begin(); linkIt != links.end(); ++linkIt) {
295 if ((*linkIt) == 0 || (*linkIt)->getLane() == 0) {
298 std::string succLaneId = (*(it + 1))->getLanes()[0]->getID();
299 if ((*linkIt)->getLane()->getID().compare(succLaneId) == 0) {
300 distance += (*linkIt)->getLength();
306 isFirstIteration =
false;
321 const std::vector<SUMOVehicleParameter::Stop>&
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::map< std::string, const MSRoute * > RouteDict
Definition of the dictionary container.
int writeEdgeIDs(OutputDevice &os, const MSEdge *const from, const MSEdge *const upTo=0) const
Output the edge ids up to but not including the id of the given edge.
MSEdgeVector::const_iterator MSRouteIterator
const MSEdge * getLastEdge() const
returns the destination edge
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
static void insertIDs(std::vector< std::string > &into)
A road/street connecting two junctions.
static void clear()
Clears the dictionary (delete all known routes, too)
std::vector< const MSEdge * > MSEdgeVector
bool containsAnyOf(const std::vector< MSEdge * > &edgelist) const
static RouteDistDict myDistDict
The dictionary container.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
MSEdgeVector myEdges
The list of edges to pass.
bool contains(const MSEdge *const edge) const
std::map< std::string, std::pair< RandomDistributor< const MSRoute * > *, bool > > RouteDistDict
Definition of the dictionary container.
virtual ~MSRoute()
Destructor.
SUMOReal getLength() const
void addReference() const
increments the reference counter for the route
std::vector< SUMOVehicleParameter::Stop > myStops
List of the stops on the parsed route.
Base class for objects which have an id.
std::string myID
The name of the object.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
unsigned size() const
Returns the number of edges to pass.
const MSEdge * operator[](unsigned index) const
Static storage of an output device and its base (abstract) implementation.
const RGBColor & getColor() const
Returns the color.
bool closeTag()
Closes the most recently opened tag.
unsigned int myReferenceCounter
Information by how many vehicles the route is used.
void release() const
deletes the route if there are no further references to it
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
static RouteDict myDict
The dictionary container.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
const RGBColor *const myColor
The color.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
MSRoute(const std::string &id, const MSEdgeVector &edges, const bool isPermanent, const RGBColor *const c, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.