Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // A container for routes
17 /****************************************************************************/
18 #ifndef RODFRouteCont_h
19 #define RODFRouteCont_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <map>
30 #include "RODFRouteDesc.h"
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class RODFNet;
37 class OutputDevice;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
57 public:
59  RODFRouteCont();
60 
63 
64 
76  void addRouteDesc(RODFRouteDesc& desc);
77 
78 
88  bool removeRouteDesc(RODFRouteDesc& desc);
89 
90 
99  bool save(std::vector<std::string>& saved,
100  const std::string& prependix, OutputDevice& out);
101 
102 
106  std::vector<RODFRouteDesc>& get() {
107  return myRoutes;
108  }
109 
110 
116  void sortByDistance();
117 
118 
126  void removeIllegal(const std::vector<ROEdgeVector >& illegals);
127 
128 
129 protected:
137  void setID(RODFRouteDesc& desc) const;
138 
139 
142  public:
144  explicit by_distance_sorter() { }
145 
147  int operator()(const RODFRouteDesc& p1, const RODFRouteDesc& p2) {
148  return p1.distance2Last < p2.distance2Last;
149  }
150  };
151 
152 
154  class route_finder {
155  public:
159  explicit route_finder(const RODFRouteDesc& desc) : myDesc(desc) { }
160 
162  bool operator()(const RODFRouteDesc& desc) {
163  return myDesc.edges2Pass == desc.edges2Pass;
164  }
165 
166  private:
169 
170  private:
173  };
174 
175 protected:
177  std::vector<RODFRouteDesc> myRoutes;
178 
180  mutable std::map<std::pair<ROEdge*, ROEdge*>, int> myConnectionOccurences;
181 
182 
183 };
184 
185 
186 #endif
187 
188 /****************************************************************************/
189 
RODFRouteCont::myConnectionOccurences
std::map< std::pair< ROEdge *, ROEdge * >, int > myConnectionOccurences
Counts how many routes connecting the key-edges were already stored.
Definition: RODFRouteCont.h:180
RODFRouteCont::myRoutes
std::vector< RODFRouteDesc > myRoutes
Stored route descriptions.
Definition: RODFRouteCont.h:177
RODFRouteCont::by_distance_sorter::operator()
int operator()(const RODFRouteDesc &p1, const RODFRouteDesc &p2)
Sorting function; compares RODFRouteDesc::distance2Last.
Definition: RODFRouteCont.h:147
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
RODFRouteCont::by_distance_sorter::by_distance_sorter
by_distance_sorter()
Constructor.
Definition: RODFRouteCont.h:144
RODFRouteCont::addRouteDesc
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
Definition: RODFRouteCont.cpp:47
RODFRouteCont::removeRouteDesc
bool removeRouteDesc(RODFRouteDesc &desc)
Removes the given route description from the container.
Definition: RODFRouteCont.cpp:61
RODFRouteCont::RODFRouteCont
RODFRouteCont()
Constructor.
Definition: RODFRouteCont.cpp:39
RODFRouteCont::route_finder
A class for finding a same route (one that passes the same edges)
Definition: RODFRouteCont.h:154
RODFRouteDesc
A route within the DFROUTER.
Definition: RODFRouteDesc.h:47
RODFRouteCont::by_distance_sorter
A class for sorting route descriptions by their length.
Definition: RODFRouteCont.h:141
RODFRouteCont::~RODFRouteCont
~RODFRouteCont()
Destructor.
Definition: RODFRouteCont.cpp:42
RODFRouteCont::save
bool save(std::vector< std::string > &saved, const std::string &prependix, OutputDevice &out)
Saves routes.
Definition: RODFRouteCont.cpp:71
UtilExceptions.h
RODFRouteDesc::distance2Last
double distance2Last
Definition: RODFRouteDesc.h:57
RODFRouteCont::route_finder::operator()
bool operator()(const RODFRouteDesc &desc)
The comparing function; compares passed edges.
Definition: RODFRouteCont.h:162
RODFRouteCont::setID
void setID(RODFRouteDesc &desc) const
Computes and sets the id of a route.
Definition: RODFRouteCont.cpp:129
RODFRouteCont::route_finder::myDesc
const RODFRouteDesc & myDesc
The route description for which a same shall be found.
Definition: RODFRouteCont.h:168
RODFRouteDesc::edges2Pass
ROEdgeVector edges2Pass
The edges the route is made of.
Definition: RODFRouteDesc.h:49
RODFRouteCont::route_finder::operator=
route_finder & operator=(const route_finder &)
invalidated assignment operator
RODFRouteDesc.h
RODFNet
A DFROUTER-network.
Definition: RODFNet.h:45
config.h
RODFRouteCont
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:56
RODFRouteCont::get
std::vector< RODFRouteDesc > & get()
Returns the container of stored routes.
Definition: RODFRouteCont.h:106
RODFRouteCont::removeIllegal
void removeIllegal(const std::vector< ROEdgeVector > &illegals)
Removes "illegal" routes.
Definition: RODFRouteCont.cpp:104
RODFRouteCont::route_finder::route_finder
route_finder(const RODFRouteDesc &desc)
onstructor
Definition: RODFRouteCont.h:159
RODFRouteCont::sortByDistance
void sortByDistance()
Sorts routes by their distance (length)
Definition: RODFRouteCont.cpp:98