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 #include "RORouteDef.h"
41 #include "ROVehicle.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class OutputDevice;
48 class ROEdge;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class ROPerson : public RORoutable {
59 
60 public:
66  ROPerson(const SUMOVehicleParameter& pars, const SUMOVTypeParameter* type);
67 
69  virtual ~ROPerson();
70 
71  void addTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
72  const std::string& vTypes, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop);
73 
74  void addRide(const ROEdge* const from, const ROEdge* const to, const std::string& lines, const std::string& destStop);
75 
76  void addWalk(const ConstROEdgeVector& edges, const SUMOReal duration, const SUMOReal speed,
77  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop);
78 
79  void addStop(const SUMOVehicleParameter::Stop& stopPar, const ROEdge* const stopEdge);
80 
81  class TripItem;
86  class PlanItem {
87  public:
89  virtual ~PlanItem() {}
90 
91  virtual void addTripItem(TripItem* /* tripIt */) {
92  throw ProcessError();
93  }
94  virtual const ROEdge* getOrigin() const = 0;
95  virtual const ROEdge* getDestination() const = 0;
96  virtual void saveVehicles(OutputDevice& /* os */, OutputDevice* const /* typeos */, bool /* asAlternatives */, OptionsCont& /* options */) const {}
97  virtual void saveAsXML(OutputDevice& os) const = 0;
98  virtual bool isStop() const {
99  return false;
100  }
101  virtual bool needsRouting() const {
102  return false;
103  }
104  };
105 
110  class Stop : public PlanItem {
111  public:
112  Stop(const SUMOVehicleParameter::Stop& stop, const ROEdge* const stopEdge)
113  : stopDesc(stop), edge(stopEdge) {}
114  const ROEdge* getOrigin() const {
115  return edge;
116  }
117  const ROEdge* getDestination() const {
118  return edge;
119  }
120  void saveAsXML(OutputDevice& os) const {
121  stopDesc.write(os);
122  }
123  bool isStop() const {
124  return true;
125  }
126 
127  private:
129  const ROEdge* const edge;
130 
131  private:
133  Stop& operator=(const Stop& src);
134 
135  };
136 
141  class TripItem {
142  public:
144  virtual ~TripItem() {}
145 
146  virtual const ROEdge* getOrigin() const = 0;
147  virtual const ROEdge* getDestination() const = 0;
148  virtual void saveAsXML(OutputDevice& os) const = 0;
149  };
150 
155  class Ride : public TripItem {
156  public:
157  Ride(const ROEdge* const _from, const ROEdge* const _to,
158  const std::string& _lines, const std::string& _destStop = "")
159  : from(_from), to(_to), lines(_lines), destStop(_destStop) {}
160 
161  const ROEdge* getOrigin() const {
162  return from;
163  }
164  const ROEdge* getDestination() const {
165  return to;
166  }
167  void saveAsXML(OutputDevice& os) const;
168 
169  private:
170  const ROEdge* const from;
171  const ROEdge* const to;
172  const std::string lines;
173  const std::string destStop;
174 
175  private:
177  Ride& operator=(const Ride& src);
178 
179  };
180 
185  class Walk : public TripItem {
186  public:
187  Walk(const ConstROEdgeVector& _edges, const std::string& _destStop = "")
188  : edges(_edges), dur(-1), v(-1), dep(std::numeric_limits<SUMOReal>::infinity()), arr(std::numeric_limits<SUMOReal>::infinity()), destStop(_destStop) {}
189  Walk(const ConstROEdgeVector& edges, const SUMOReal duration, const SUMOReal speed,
190  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& _destStop)
191  : edges(edges), dur(duration), v(speed), dep(departPos), arr(arrivalPos), destStop(_destStop) {}
192  const ROEdge* getOrigin() const {
193  return edges.front();
194  }
195  const ROEdge* getDestination() const {
196  return edges.back();
197  }
198  void saveAsXML(OutputDevice& os) const;
199 
200  private:
202  const SUMOReal dur, v, dep, arr;
203  const std::string destStop;
204 
205  private:
207  Walk& operator=(const Walk& src);
208 
209  };
210 
215  class PersonTrip : public PlanItem {
216  public:
218  : from(0), to(0), modes(SVC_PEDESTRIAN), dep(0), arr(0), busStop("") {}
219  PersonTrip(const ROEdge* const from, const ROEdge* const to, const SVCPermissions modeSet,
220  const SUMOReal departPos, const SUMOReal arrivalPos, const std::string& busStop)
221  : from(from), to(to), modes(modeSet), dep(departPos), arr(arrivalPos), busStop(busStop) {}
223  virtual ~PersonTrip() {
224  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
225  delete *it;
226  }
227  for (std::vector<ROVehicle*>::const_iterator it = myVehicles.begin(); it != myVehicles.end(); ++it) {
228  delete(*it)->getRouteDefinition();
229  delete *it;
230  }
231  }
232 
233  virtual void addTripItem(TripItem* tripIt) {
234  myTripItems.push_back(tripIt);
235  }
236  void addVehicle(ROVehicle* veh) {
237  myVehicles.push_back(veh);
238  }
239  std::vector<ROVehicle*>& getVehicles() {
240  return myVehicles;
241  }
242  const ROEdge* getOrigin() const {
243  return from != 0 ? from : myTripItems.front()->getOrigin();
244  }
245  const ROEdge* getDestination() const {
246  return to != 0 ? to : myTripItems.back()->getDestination();
247  }
249  return dep;
250  }
252  return arr;
253  }
255  return modes;
256  }
257  virtual bool needsRouting() const {
258  return myTripItems.empty();
259  }
260  void saveVehicles(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
261  void saveAsXML(OutputDevice& os) const {
262  for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
263  (*it)->saveAsXML(os);
264  }
265  }
266 
267  private:
268  const ROEdge* from;
269  const ROEdge* to;
271  const SUMOReal dep, arr;
272  const std::string busStop;
274  std::vector<TripItem*> myTripItems;
276  std::vector<ROVehicle*> myVehicles;
277 
278  private:
280  PersonTrip& operator=(const PersonTrip& src);
281 
282  };
283 
284 
289  const ROEdge* getDepartEdge() const {
290  return myPlan.front()->getOrigin();
291  }
292 
293 
294  void computeRoute(const RORouterProvider& provider,
295  const bool removeLoops, MsgHandler* errorHandler);
296 
297 
308  void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options) const;
309 
310  std::vector<PlanItem*>& getPlan() {
311  return myPlan;
312  }
313 
314 private:
315  bool computeIntermodal(const RORouterProvider& provider, PersonTrip* const trip, const ROVehicle* const veh, MsgHandler* const errorHandler);
316 
317 private:
321  std::vector<PlanItem*> myPlan;
322 
323 
324 private:
326  ROPerson(const ROPerson& src);
327 
329  ROPerson& operator=(const ROPerson& src);
330 
331 };
332 
333 #endif
334 
335 /****************************************************************************/
336 
const ROEdge * getOrigin() const
Definition: ROPerson.h:192
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:120
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, const std::string &destStop)
Definition: ROPerson.cpp:98
is a pedestrian
const std::string lines
Definition: ROPerson.h:172
const ROEdge *const edge
Definition: ROPerson.h:129
virtual void saveAsXML(OutputDevice &os) const =0
bool isStop() const
Definition: ROPerson.h:123
void addVehicle(ROVehicle *veh)
Definition: ROPerson.h:236
SUMOReal getArrivalPos() const
Definition: ROPerson.h:251
Structure representing possible vehicle parameter.
virtual bool needsRouting() const
Definition: ROPerson.h:257
const SVCPermissions modes
Definition: ROPerson.h:270
int SVCPermissions
A planItem can be a Stop.
Definition: ROPerson.h:110
std::vector< ROVehicle * > myVehicles
the vehicles which may be used for routing
Definition: ROPerson.h:276
void addWalk(const ConstROEdgeVector &edges, const SUMOReal duration, const SUMOReal speed, const SUMOReal departPos, const SUMOReal arrivalPos, const std::string &busStop)
Definition: ROPerson.cpp:107
const ROEdge *const from
Definition: ROPerson.h:170
bool computeIntermodal(const RORouterProvider &provider, PersonTrip *const trip, const ROVehicle *const veh, MsgHandler *const errorHandler)
Definition: ROPerson.cpp:170
const ROEdge * getDestination() const
Definition: ROPerson.h:245
SUMOReal getDepartPos() const
Definition: ROPerson.h:248
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
virtual bool needsRouting() const
Definition: ROPerson.h:101
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:86
const ROEdge * getDestination() const
Definition: ROPerson.h:195
A planItem can be a Trip which contains multiple tripItems.
Definition: ROPerson.h:215
virtual ~PlanItem()
Destructor.
Definition: ROPerson.h:89
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
const SUMOReal v
Definition: ROPerson.h:202
A ride is part of a trip, e.g., go from here to here by car or bus.
Definition: ROPerson.h:155
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:189
const ROEdge * from
Definition: ROPerson.h:268
std::vector< PlanItem * > myPlan
The plan of the person.
Definition: ROPerson.h:321
SUMOVehicleParameter::Stop stopDesc
Definition: ROPerson.h:128
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:310
const ROEdge * getDestination() const
Definition: ROPerson.h:164
virtual void addTripItem(TripItem *)
Definition: ROPerson.h:91
virtual bool isStop() const
Definition: ROPerson.h:98
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:116
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:242
const ROEdge * getOrigin() const
Definition: ROPerson.h:114
A person as used by router.
Definition: ROPerson.h:58
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:219
void saveAsXML(OutputDevice &os) const
Definition: ROPerson.h:261
A TripItem is part of a trip, e.g., go from here to here by car.
Definition: ROPerson.h:141
A walk is part of a trip, e.g., go from here to here by foot.
Definition: ROPerson.h:185
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:274
const ROEdge * getDestination() const
Definition: ROPerson.h:117
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
Definition: ROPerson.cpp:58
virtual ~PersonTrip()
Destructor.
Definition: ROPerson.h:223
SVCPermissions getModes() const
Definition: ROPerson.h:254
const ROEdge * getOrigin() const
Definition: ROPerson.h:161
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
Definition: ROPerson.cpp:197
Structure representing possible vehicle parameter.
const std::string destStop
Definition: ROPerson.h:203
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:99
virtual void saveVehicles(OutputDevice &, OutputDevice *const , bool, OptionsCont &) const
Definition: ROPerson.h:96
const std::string destStop
Definition: ROPerson.h:173
const ROEdge * to
Definition: ROPerson.h:269
Walk(const ConstROEdgeVector &_edges, const std::string &_destStop="")
Definition: ROPerson.h:187
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const ConstROEdgeVector edges
Definition: ROPerson.h:201
std::vector< ROVehicle * > & getVehicles()
Definition: ROPerson.h:239
virtual void addTripItem(TripItem *tripIt)
Definition: ROPerson.h:233
#define SUMOReal
Definition: config.h:213
const ROEdge * getDepartEdge() const
Returns the first edge the person takes.
Definition: ROPerson.h:289
Stop(const SUMOVehicleParameter::Stop &stop, const ROEdge *const stopEdge)
Definition: ROPerson.h:112
virtual const ROEdge * getOrigin() const =0
const SUMOReal dep
Definition: ROPerson.h:271
const ROEdge *const to
Definition: ROPerson.h:171
Ride(const ROEdge *const _from, const ROEdge *const _to, const std::string &_lines, const std::string &_destStop="")
Definition: ROPerson.h:157
virtual ~TripItem()
Destructor.
Definition: ROPerson.h:144
const std::string busStop
Definition: ROPerson.h:272