SUMO - Simulation of Urban MObility
ROPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // A person as used by router
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2002-2016 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef ROPerson_h
22 #define ROPerson_h
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 <string>
34 #include <iostream>
35 #include <utils/common/StdDefs.h>
36 #include <utils/common/SUMOTime.h>
39 #include "RORoutable.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class OutputDevice;
46 class ROEdge;
47 class ROVehicle;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
57 class ROPerson : public RORoutable {
58 
59 public:
65  ROPerson(const SUMOVehicleParameter& pars, const SUMOVTypeParameter* type);
66 
68  virtual ~ROPerson();
69 
70  void addTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
71  const std::string& vTypes, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop);
72 
73  void addRide(const ROEdge* const from, const ROEdge* const to, const std::string& lines, const std::string& destStop);
74 
75  void addWalk(const ConstROEdgeVector& edges, const SUMOReal duration, const SUMOReal speed,
76  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop);
77 
78  void addStop(const SUMOVehicleParameter::Stop& stopPar, const ROEdge* const stopEdge);
79 
80  class TripItem;
85  class PlanItem {
86  public:
88  virtual ~PlanItem() {}
89 
90  virtual void addTripItem(TripItem* /* tripIt */) {
91  throw ProcessError();
92  }
93  virtual const ROEdge* getOrigin() const = 0;
94  virtual const ROEdge* getDestination() const = 0;
95  virtual void saveVehicles(OutputDevice& /* os */, OutputDevice* const /* typeos */, bool /* asAlternatives */, OptionsCont& /* options */) const {}
96  virtual void saveAsXML(OutputDevice& os) const = 0;
97  virtual bool isStop() const {
98  return false;
99  }
100  virtual bool needsRouting() const {
101  return false;
102  }
103  };
104 
109  class Stop : public PlanItem {
110  public:
111  Stop(const SUMOVehicleParameter::Stop& stop, const ROEdge* const stopEdge)
112  : stopDesc(stop), edge(stopEdge) {}
113  const ROEdge* getOrigin() const {
114  return edge;
115  }
116  const ROEdge* getDestination() const {
117  return edge;
118  }
119  void saveAsXML(OutputDevice& os) const {
120  stopDesc.write(os);
121  }
122  bool isStop() const {
123  return true;
124  }
125 
126  private:
128  const ROEdge* const edge;
129 
130  private:
132  Stop& operator=(const Stop& src);
133 
134  };
135 
140  class TripItem {
141  public:
143  virtual ~TripItem() {}
144 
145  virtual const ROEdge* getOrigin() const = 0;
146  virtual const ROEdge* getDestination() const = 0;
147  virtual void saveAsXML(OutputDevice& os) const = 0;
148  };
149 
154  class Ride : public TripItem {
155  public:
156  Ride(const ROEdge* const _from, const ROEdge* const _to,
157  const std::string& _lines, const std::string& _destStop = "")
158  : from(_from), to(_to), lines(_lines), destStop(_destStop) {}
159 
160  const ROEdge* getOrigin() const {
161  return from;
162  }
163  const ROEdge* getDestination() const {
164  return to;
165  }
166  void saveAsXML(OutputDevice& os) const;
167 
168  private:
169  const ROEdge* const from;
170  const ROEdge* const to;
171  const std::string lines;
172  const std::string destStop;
173 
174  private:
176  Ride& operator=(const Ride& src);
177 
178  };
179 
184  class Walk : public TripItem {
185  public:
186  Walk(const ConstROEdgeVector& _edges, const std::string& _destStop = "")
187  : edges(_edges), dur(-1), v(-1), dep(std::numeric_limits<SUMOReal>::infinity()), arr(std::numeric_limits<SUMOReal>::infinity()), destStop(_destStop) {}
188  Walk(const ConstROEdgeVector& edges, const SUMOReal duration, const SUMOReal speed,
189  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& _destStop)
190  : edges(edges), dur(duration), v(speed), dep(departPos), arr(arrivalPos), destStop(_destStop) {}
191  const ROEdge* getOrigin() const {
192  return edges.front();
193  }
194  const ROEdge* getDestination() const {
195  return edges.back();
196  }
197  void saveAsXML(OutputDevice& os) const;
198 
199  private:
201  const SUMOReal dur, v, dep, arr;
202  const std::string destStop;
203 
204  private:
206  Walk& operator=(const Walk& src);
207 
208  };
209 
214  class PersonTrip : public PlanItem {
215  public:
217  : from(0), to(0), modes(SVC_PEDESTRIAN), dep(0), arr(0), busStop("") {}
218  PersonTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
219  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop)
220  : from(from), to(to), modes(modeSet), dep(departPos), arr(arrivalPos), busStop(busStop) {}
222  virtual ~PersonTrip() {
223  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
224  delete *it;
225  }
226  }
227 
228  virtual void addTripItem(TripItem* tripIt) {
229  myTripItems.push_back(tripIt);
230  }
231  void addVehicle(ROVehicle* veh) {
232  myVehicles.push_back(veh);
233  }
234  std::vector<ROVehicle*>& getVehicles() {
235  return myVehicles;
236  }
237  const ROEdge* getOrigin() const {
238  return from != 0 ? from : myTripItems.front()->getOrigin();
239  }
240  const ROEdge* getDestination() const {
241  return to != 0 ? to : myTripItems.back()->getDestination();
242  }
244  return dep;
245  }
247  return arr;
248  }
250  return modes;
251  }
252  virtual bool needsRouting() const {
253  return myTripItems.empty();
254  }
255  void saveVehicles(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
256  void saveAsXML(OutputDevice& os) const {
257  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
258  (*it)->saveAsXML(os);
259  }
260  }
261 
262  private:
263  const ROEdge* from;
264  const ROEdge* to;
266  const SUMOReal dep, arr;
267  const std::string busStop;
269  std::vector<TripItem*> myTripItems;
271  std::vector<ROVehicle*> myVehicles;
272 
273  private:
275  PersonTrip& operator=(const PersonTrip& src);
276 
277  };
278 
279 
284  const ROEdge* getDepartEdge() const {
285  return myPlan.front()->getOrigin();
286  }
287 
288 
289  void computeRoute(const RORouterProvider& provider,
290  const bool removeLoops, MsgHandler* errorHandler);
291 
292 
303  void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
304 
305  std::vector<PlanItem*>& getPlan() {
306  return myPlan;
307  }
308 
309 private:
310  bool computeIntermodal(const RORouterProvider& provider, PersonTrip* const trip, const ROVehicle* const veh, MsgHandler* const errorHandler);
311 
312 private:
316  std::vector<PlanItem*> myPlan;
317 
318 
319 private:
321  ROPerson(const ROPerson& src);
322 
324  ROPerson& operator=(const ROPerson& src);
325 
326 };
327 
328 #endif
329 
330 /****************************************************************************/
331 
const ROEdge * getOrigin() const
Definition: ROPerson.h:191
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:119
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, const std::string &destStop)
Definition: ROPerson.cpp:97
is a pedestrian
const std::string lines
Definition: ROPerson.h:171
const ROEdge *const edge
Definition: ROPerson.h:128
virtual void saveAsXML(OutputDevice &os) const =0
bool isStop() const
Definition: ROPerson.h:122
void addVehicle(ROVehicle *veh)
Definition: ROPerson.h:231
SUMOReal getArrivalPos() const
Definition: ROPerson.h:246
Structure representing possible vehicle parameter.
virtual bool needsRouting() const
Definition: ROPerson.h:252
const SVCPermissions modes
Definition: ROPerson.h:265
int SVCPermissions
A planItem can be a Stop.
Definition: ROPerson.h:109
std::vector< ROVehicle * > myVehicles
the vehicles which may be used for routing
Definition: ROPerson.h:271
void addWalk(const ConstROEdgeVector &edges, const SUMOReal duration, const SUMOReal speed, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string &busStop)
Definition: ROPerson.cpp:106
const ROEdge *const from
Definition: ROPerson.h:169
bool computeIntermodal(const RORouterProvider &provider, PersonTrip *const trip, const ROVehicle *const veh, MsgHandler *const errorHandler)
Definition: ROPerson.cpp:169
const ROEdge * getDestination() const
Definition: ROPerson.h:240
SUMOReal getDepartPos() const
Definition: ROPerson.h:243
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
virtual bool needsRouting() const
Definition: ROPerson.h:100
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:85
const ROEdge * getDestination() const
Definition: ROPerson.h:194
A planItem can be a Trip which contains multiple tripItems.
Definition: ROPerson.h:214
virtual ~PlanItem()
Destructor.
Definition: ROPerson.h:88
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
const SUMOReal v
Definition: ROPerson.h:201
A ride is part of a trip, e.g., go from here to here by car or bus.
Definition: ROPerson.h:154
A vehicle as used by router.
Definition: ROVehicle.h:60
ROPerson & operator=(const ROPerson &src)
Invalidated assignment operator.
Walk(const ConstROEdgeVector &edges, const SUMOReal duration, const SUMOReal speed, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string &_destStop)
Definition: ROPerson.h:188
const ROEdge * from
Definition: ROPerson.h:263
std::vector< PlanItem * > myPlan
The plan of the person.
Definition: ROPerson.h:316
SUMOVehicleParameter::Stop stopDesc
Definition: ROPerson.h:127
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:305
const ROEdge * getDestination() const
Definition: ROPerson.h:163
virtual void addTripItem(TripItem *)
Definition: ROPerson.h:90
virtual bool isStop() const
Definition: ROPerson.h:97
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:115
void addTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string &busStop)
Definition: ROPerson.cpp:71
const ROEdge * getOrigin() const
Definition: ROPerson.h:237
const ROEdge * getOrigin() const
Definition: ROPerson.h:113
A person as used by router.
Definition: ROPerson.h:57
PersonTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string &busStop)
Definition: ROPerson.h:218
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:256
A TripItem is part of a trip, e.g., go from here to here by car.
Definition: ROPerson.h:140
A walk is part of a trip, e.g., go from here to here by foot.
Definition: ROPerson.h:184
A basic edge for routing applications.
Definition: ROEdge.h:77
virtual const ROEdge * getDestination() const =0
virtual ~ROPerson()
Destructor.
Definition: ROPerson.cpp:63
std::vector< TripItem * > myTripItems
the fully specified trips
Definition: ROPerson.h:269
const ROEdge * getDestination() const
Definition: ROPerson.h:116
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition: ROPerson.cpp:58
virtual ~PersonTrip()
Destructor.
Definition: ROPerson.h:222
SVCPermissions getModes() const
Definition: ROPerson.h:249
const ROEdge * getOrigin() const
Definition: ROPerson.h:160
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition: ROPerson.cpp:196
Structure representing possible vehicle parameter.
const std::string destStop
Definition: ROPerson.h:202
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:108
virtual void saveVehicles(OutputDevice &, OutputDevice *const , bool, OptionsCont &) const
Definition: ROPerson.h:95
const std::string destStop
Definition: ROPerson.h:172
const ROEdge * to
Definition: ROPerson.h:264
Walk(const ConstROEdgeVector &_edges, const std::string &_destStop="")
Definition: ROPerson.h:186
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const ConstROEdgeVector edges
Definition: ROPerson.h:200
std::vector< ROVehicle * > & getVehicles()
Definition: ROPerson.h:234
virtual void addTripItem(TripItem *tripIt)
Definition: ROPerson.h:228
#define SUMOReal
Definition: config.h:213
const ROEdge * getDepartEdge() const
Returns the first edge the person takes.
Definition: ROPerson.h:284
Stop(const SUMOVehicleParameter::Stop &stop, const ROEdge *const stopEdge)
Definition: ROPerson.h:111
virtual const ROEdge * getOrigin() const =0
const SUMOReal dep
Definition: ROPerson.h:266
const ROEdge *const to
Definition: ROPerson.h:170
Ride(const ROEdge *const _from, const ROEdge *const _to, const std::string &_lines, const std::string &_destStop="")
Definition: ROPerson.h:156
virtual ~TripItem()
Destructor.
Definition: ROPerson.h:143
const std::string busStop
Definition: ROPerson.h:267