SUMO - Simulation of Urban MObility
RODFRouteCont.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // A container for routes
19 /****************************************************************************/
20 #ifndef RODFRouteCont_h
21 #define RODFRouteCont_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <map>
36 #include "RODFRouteDesc.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class RODFNet;
43 class OutputDevice;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
63 public:
65  RODFRouteCont();
66 
69 
70 
82  void addRouteDesc(RODFRouteDesc& desc);
83 
84 
94  bool removeRouteDesc(RODFRouteDesc& desc);
95 
96 
105  bool save(std::vector<std::string>& saved,
106  const std::string& prependix, OutputDevice& out);
107 
108 
112  std::vector<RODFRouteDesc>& get() {
113  return myRoutes;
114  }
115 
116 
122  void sortByDistance();
123 
124 
132  void removeIllegal(const std::vector<ROEdgeVector >& illegals);
133 
134 
135 protected:
143  void setID(RODFRouteDesc& desc) const;
144 
145 
148  public:
150  explicit by_distance_sorter() { }
151 
153  int operator()(const RODFRouteDesc& p1, const RODFRouteDesc& p2) {
154  return p1.distance2Last < p2.distance2Last;
155  }
156  };
157 
158 
160  class route_finder {
161  public:
165  explicit route_finder(const RODFRouteDesc& desc) : myDesc(desc) { }
166 
168  bool operator()(const RODFRouteDesc& desc) {
169  return myDesc.edges2Pass == desc.edges2Pass;
170  }
171 
172  private:
175 
176  private:
178  route_finder& operator=(const route_finder&);
179  };
180 
181 protected:
183  std::vector<RODFRouteDesc> myRoutes;
184 
186  mutable std::map<std::pair<ROEdge*, ROEdge*>, int> myConnectionOccurences;
187 
188 
189 };
190 
191 
192 #endif
193 
194 /****************************************************************************/
195 
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:55
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:51
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:53
RODFRouteCont()
Constructor.
double distance2Last
Definition: RODFRouteDesc.h:63
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:62
route_finder(const RODFRouteDesc &desc)
onstructor
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
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.