SUMO - Simulation of Urban MObility
ROHelper.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-2018 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 // Some helping methods for router
17 /****************************************************************************/
18 #ifndef ROHelper_h
19 #define ROHelper_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <functional>
28 #include <vector>
29 #include "ROEdge.h"
30 #include "ROVehicle.h"
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
43 class ROVehicleByDepartureComperator : public std::less<ROVehicle*> {
44 public:
47 
50 
62  bool operator()(ROVehicle* veh1, ROVehicle* veh2) const {
63  if (veh1->getDepart() == veh2->getDepart()) {
64  return veh1->getID() > veh2->getID();
65  }
66  return veh1->getDepart() > veh2->getDepart();
67  }
68 };
69 
70 
75 namespace ROHelper {
80 void recheckForLoops(ConstROEdgeVector& edges, const ConstROEdgeVector& mandatory);
81 
82 bool noMandatory(const ConstROEdgeVector& mandatory,
83  ConstROEdgeVector::const_iterator start,
84  ConstROEdgeVector::const_iterator end);
85 }
86 
87 #endif
88 
89 /****************************************************************************/
90 
void recheckForLoops(ConstROEdgeVector &edges, const ConstROEdgeVector &mandatory)
Checks whether the given edge list contains loops and removes them.
Definition: ROHelper.cpp:38
ROVehicleByDepartureComperator()
Constructor.
Definition: ROHelper.h:46
bool noMandatory(const ConstROEdgeVector &mandatory, ConstROEdgeVector::const_iterator start, ConstROEdgeVector::const_iterator end)
Definition: ROHelper.cpp:104
bool operator()(ROVehicle *veh1, ROVehicle *veh2) const
Comparing operator.
Definition: ROHelper.h:62
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:56
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:103
Some helping methods for router.
Definition: ROHelper.cpp:36
A vehicle as used by router.
Definition: ROVehicle.h:53
const std::string & getID() const
Returns the id of the routable.
Definition: RORoutable.h:94
A function for sorting vehicles by their departure time.
Definition: ROHelper.h:43
~ROVehicleByDepartureComperator()
Destructor.
Definition: ROHelper.h:49