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 /****************************************************************************/
15 // A container for routes
16 /****************************************************************************/
17 #ifndef RODFRouteCont_h
18 #define RODFRouteCont_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <map>
29 #include "RODFRouteDesc.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class RODFNet;
36 class OutputDevice;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
56 public:
58  RODFRouteCont();
59 
62 
63 
75  void addRouteDesc(RODFRouteDesc& desc);
76 
77 
87  bool removeRouteDesc(RODFRouteDesc& desc);
88 
89 
98  bool save(std::vector<std::string>& saved,
99  const std::string& prependix, OutputDevice& out);
100 
101 
105  std::vector<RODFRouteDesc>& get() {
106  return myRoutes;
107  }
108 
109 
115  void sortByDistance();
116 
117 
125  void removeIllegal(const std::vector<ROEdgeVector >& illegals);
126 
127 
128 protected:
136  void setID(RODFRouteDesc& desc) const;
137 
138 
141  public:
143  explicit by_distance_sorter() { }
144 
146  int operator()(const RODFRouteDesc& p1, const RODFRouteDesc& p2) {
147  return p1.distance2Last < p2.distance2Last;
148  }
149  };
150 
151 
153  class route_finder {
154  public:
158  explicit route_finder(const RODFRouteDesc& desc) : myDesc(desc) { }
159 
161  bool operator()(const RODFRouteDesc& desc) {
162  return myDesc.edges2Pass == desc.edges2Pass;
163  }
164 
165  private:
168 
169  private:
172  };
173 
174 protected:
176  std::vector<RODFRouteDesc> myRoutes;
177 
179  mutable std::map<std::pair<ROEdge*, ROEdge*>, int> myConnectionOccurences;
180 
181 
182 };
183 
184 
185 #endif
186 
187 /****************************************************************************/
188 
RODFRouteCont::myConnectionOccurences
std::map< std::pair< ROEdge *, ROEdge * >, int > myConnectionOccurences
Counts how many routes connecting the key-edges were already stored.
Definition: RODFRouteCont.h:179
RODFRouteCont::myRoutes
std::vector< RODFRouteDesc > myRoutes
Stored route descriptions.
Definition: RODFRouteCont.h:176
RODFRouteCont::by_distance_sorter::operator()
int operator()(const RODFRouteDesc &p1, const RODFRouteDesc &p2)
Sorting function; compares RODFRouteDesc::distance2Last.
Definition: RODFRouteCont.h:146
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
RODFRouteCont::by_distance_sorter::by_distance_sorter
by_distance_sorter()
Constructor.
Definition: RODFRouteCont.h:143
RODFRouteCont::addRouteDesc
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
Definition: RODFRouteCont.cpp:46
RODFRouteCont::removeRouteDesc
bool removeRouteDesc(RODFRouteDesc &desc)
Removes the given route description from the container.
Definition: RODFRouteCont.cpp:60
RODFRouteCont::RODFRouteCont
RODFRouteCont()
Constructor.
Definition: RODFRouteCont.cpp:38
RODFRouteCont::route_finder
A class for finding a same route (one that passes the same edges)
Definition: RODFRouteCont.h:153
RODFRouteDesc
A route within the DFROUTER.
Definition: RODFRouteDesc.h:46
RODFRouteCont::by_distance_sorter
A class for sorting route descriptions by their length.
Definition: RODFRouteCont.h:140
RODFRouteCont::~RODFRouteCont
~RODFRouteCont()
Destructor.
Definition: RODFRouteCont.cpp:41
RODFRouteCont::save
bool save(std::vector< std::string > &saved, const std::string &prependix, OutputDevice &out)
Saves routes.
Definition: RODFRouteCont.cpp:70
UtilExceptions.h
RODFRouteDesc::distance2Last
double distance2Last
Definition: RODFRouteDesc.h:56
RODFRouteCont::route_finder::operator()
bool operator()(const RODFRouteDesc &desc)
The comparing function; compares passed edges.
Definition: RODFRouteCont.h:161
RODFRouteCont::setID
void setID(RODFRouteDesc &desc) const
Computes and sets the id of a route.
Definition: RODFRouteCont.cpp:128
RODFRouteCont::route_finder::myDesc
const RODFRouteDesc & myDesc
The route description for which a same shall be found.
Definition: RODFRouteCont.h:167
RODFRouteDesc::edges2Pass
ROEdgeVector edges2Pass
The edges the route is made of.
Definition: RODFRouteDesc.h:48
RODFRouteCont::route_finder::operator=
route_finder & operator=(const route_finder &)
invalidated assignment operator
RODFRouteDesc.h
RODFNet
A DFROUTER-network.
Definition: RODFNet.h:44
config.h
RODFRouteCont
A container for DFROUTER-routes.
Definition: RODFRouteCont.h:55
RODFRouteCont::get
std::vector< RODFRouteDesc > & get()
Returns the container of stored routes.
Definition: RODFRouteCont.h:105
RODFRouteCont::removeIllegal
void removeIllegal(const std::vector< ROEdgeVector > &illegals)
Removes "illegal" routes.
Definition: RODFRouteCont.cpp:103
RODFRouteCont::route_finder::route_finder
route_finder(const RODFRouteDesc &desc)
onstructor
Definition: RODFRouteCont.h:158
RODFRouteCont::sortByDistance
void sortByDistance()
Sorts routes by their distance (length)
Definition: RODFRouteCont.cpp:97