SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RORouteDef.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Base class for a vehicle's route definition
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RORouteDef_h
23 #define RORouteDef_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <iostream>
37 #include <utils/common/Named.h>
38 #include "ReferencedItem.h"
40 #include "RORoute.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class ROEdge;
47 class OptionsCont;
48 class ROVehicle;
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
64 class RORouteDef : public ReferencedItem, public Named {
65 public:
71  RORouteDef(const std::string& id, const unsigned int lastUsed,
72  const bool tryRepair);
73 
74 
76  virtual ~RORouteDef();
77 
78 
81  void addLoadedAlternative(RORoute* alternative);
82 
84  void addAlternativeDef(const RORouteDef* alternative);
85 
89  const ROVehicle& veh) const;
90 
94  const ROVehicle& veh) const;
95 
99  const ROVehicle& veh) const;
100 
105  const ROVehicle* const, RORoute* current, SUMOTime begin);
106 
107  const ROEdge* getDestination() const;
108 
109  const RORoute* getFirstRoute() const {
110  return myAlternatives.front();
111  }
112 
121  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
122  bool asAlternatives, bool withExitTimes) const;
123 
132  RORouteDef* copyOrigDest(const std::string& id) const;
133 
142  RORouteDef* copy(const std::string& id) const;
143 
145  SUMOReal getOverallProb() const;
146 
147 protected:
150 
152  mutable unsigned int myLastUsed;
153 
155  std::vector<RORoute*> myAlternatives;
156 
158  mutable bool myNewRoute;
159 
160  const bool myTryRepair;
161 
162 private:
165  bool operator()(const RORoute* const a, const RORoute* const b) {
166  return a->getProbability() > b->getProbability();
167  }
168  };
169 
170 private:
172  RORouteDef(const RORouteDef& src);
173 
175  RORouteDef& operator=(const RORouteDef& src);
176 
177 };
178 
179 
180 #endif
181 
182 /****************************************************************************/
183 
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:158
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:340
const bool myTryRepair
Definition: RORouteDef.h:160
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:230
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route...
Definition: RORouteDef.cpp:88
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:81
void preComputeCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Builds the complete route (or chooses her from the list of alternatives, when existing) ...
Definition: RORouteDef.cpp:98
void repairCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Builds the complete route (or chooses her from the list of alternatives, when existing) ...
Definition: RORouteDef.cpp:146
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:149
A vehicle as used by router.
Definition: ROVehicle.h:59
Helper base for things that are referenced and have to be saved only once.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:324
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:122
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:318
A basic edge for routing applications.
Definition: ROEdge.h:69
Base class for objects which have an id.
Definition: Named.h:45
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:67
unsigned int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:152
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:165
RORouteDef(const std::string &id, const unsigned int lastUsed, const bool tryRepair)
Constructor.
Definition: RORouteDef.cpp:60
RORouteDef * copy(const std::string &id) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:353
A storage for options typed value containers)
Definition: OptionsCont.h:108
Base class for a vehicle's route definition.
Definition: RORouteDef.h:64
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:75
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:215
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:109
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:155
SUMOReal getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:365
A complete router's route.
Definition: RORoute.h:61