SUMO - Simulation of Urban MObility
RODFRouteCont.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A container for routes
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef RODFRouteCont_h
22 #define RODFRouteCont_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <map>
37 #include "RODFRouteDesc.h"
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class RODFNet;
44 class OutputDevice;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
64 public:
66  RODFRouteCont();
67 
70 
71 
83  void addRouteDesc(RODFRouteDesc& desc);
84 
85 
95  bool removeRouteDesc(RODFRouteDesc& desc);
96 
97 
106  bool save(std::vector<std::string>& saved,
107  const std::string& prependix, OutputDevice& out);
108 
109 
113  std::vector<RODFRouteDesc>& get() {
114  return myRoutes;
115  }
116 
117 
123  void sortByDistance();
124 
125 
133  void removeIllegal(const std::vector<ROEdgeVector >& illegals);
134 
135 
136 protected:
144  void setID(RODFRouteDesc& desc) const;
145 
146 
149  public:
151  explicit by_distance_sorter() { }
152 
154  int operator()(const RODFRouteDesc& p1, const RODFRouteDesc& p2) {
155  return p1.distance2Last < p2.distance2Last;
156  }
157  };
158 
159 
161  class route_finder {
162  public:
166  explicit route_finder(const RODFRouteDesc& desc) : myDesc(desc) { }
167 
169  bool operator()(const RODFRouteDesc& desc) {
170  return myDesc.edges2Pass == desc.edges2Pass;
171  }
172 
173  private:
176 
177  private:
179  route_finder& operator=(const route_finder&);
180  };
181 
182 protected:
184  std::vector<RODFRouteDesc> myRoutes;
185 
187  mutable std::map<std::pair<ROEdge*, ROEdge*>, int> myConnectionOccurences;
188 
189 
190 };
191 
192 
193 #endif
194 
195 /****************************************************************************/
196 
void removeIllegal(const std::vector< ROEdgeVector > &illegals)
Removes "illegal" routes.
std::vector< RODFRouteDesc > myRoutes
Stored route descriptions.
A class for sorting route descriptions by their length.
~RODFRouteCont()
Destructor.
ROEdgeVector edges2Pass
The edges the route is made of.
Definition: RODFRouteDesc.h:56
A class for finding a same route (one that passes the same edges)
bool removeRouteDesc(RODFRouteDesc &desc)
Removes the given route description from the container.
void sortByDistance()
Sorts routes by their distance (length)
A DFROUTER-network.
Definition: RODFNet.h:52
const RODFRouteDesc & myDesc
The route description for which a same shall be found.
std::map< std::pair< ROEdge *, ROEdge * >, int > myConnectionOccurences
Counts how many routes connecting the key-edges were already stored.
bool operator()(const RODFRouteDesc &desc)
The comparing function; compares passed edges.
A route within the DFROUTER.
Definition: RODFRouteDesc.h:54
RODFRouteCont()
Constructor.
double distance2Last
Definition: RODFRouteDesc.h:64
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:63
route_finder(const RODFRouteDesc &desc)
onstructor
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
void setID(RODFRouteDesc &desc) const
Computes and sets the id of a route.
bool save(std::vector< std::string > &saved, const std::string &prependix, OutputDevice &out)
Saves routes.
int operator()(const RODFRouteDesc &p1, const RODFRouteDesc &p2)
Sorting function; compares RODFRouteDesc::distance2Last.