Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef DEPARTURES_TYPE_H
00013 #define DEPARTURES_TYPE_H
00014
00015 #include "station_base.h"
00016 #include "order_base.h"
00017 #include "vehicle_base.h"
00018
00020 typedef enum {
00021 D_TRAVELLING = 0,
00022 D_ARRIVED = 1,
00023 D_CANCELLED = 2,
00024 } DepartureStatus;
00025
00027 typedef enum {
00028 D_DEPARTURE = 0,
00029 D_ARRIVAL = 1,
00030 } DepartureType;
00031
00032 typedef struct CallAt {
00033 StationID station;
00034 DateTicks scheduled_date;
00035
00036 CallAt(const StationID& s) : station(s), scheduled_date(0) { }
00037 CallAt(const StationID& s, const DateTicks& t) : station(s), scheduled_date(t) { }
00038 CallAt(const CallAt& c) : station(c.station), scheduled_date(c.scheduled_date) { }
00039
00040 inline bool operator==(const CallAt& c) const {
00041 return this->station == c.station;
00042 }
00043
00044 inline bool operator!=(const CallAt& c) const {
00045 return this->station != c.station;
00046 }
00047
00048 inline bool operator>=(const CallAt& c) const {
00049 return this->station == c.station &&
00050 this->scheduled_date != 0 &&
00051 c.scheduled_date != 0 &&
00052 this->scheduled_date >= c.scheduled_date;
00053 }
00054
00055 CallAt& operator=(const CallAt& c) {
00056 this->station = c.station;
00057 this->scheduled_date = c.scheduled_date;
00058 return *this;
00059 }
00060
00061 inline bool operator==(StationID s) const {
00062 return this->station == s;
00063 }
00064 } CallAt;
00065
00067 typedef struct Departure {
00068 DateTicks scheduled_date;
00069 DateTicks lateness;
00070 CallAt terminus;
00071 StationID via;
00072 SmallVector<CallAt, 32> calling_at;
00073 DepartureStatus status;
00074 DepartureType type;
00075 const Vehicle *vehicle;
00076 const Order *order;
00077 Departure() : terminus(INVALID_STATION), via(INVALID_STATION), calling_at(), vehicle(NULL) { }
00078 ~Departure()
00079 {
00080 calling_at.Reset();
00081 }
00082
00083 inline bool operator==(const Departure& d) const {
00084 if (this->calling_at.Length() != d.calling_at.Length()) return false;
00085
00086 for (uint i = 0; i < this->calling_at.Length(); ++i) {
00087 if (*(this->calling_at.Get(i)) != *(d.calling_at.Get(i))) return false;
00088 }
00089
00090 return
00091 (this->scheduled_date / DATE_UNIT_SIZE) == (d.scheduled_date / DATE_UNIT_SIZE) &&
00092 this->vehicle->type == d.vehicle->type &&
00093 this->via == d.via &&
00094 this->type == d.type
00095 ;
00096 }
00097 } Departure;
00098
00099 typedef SmallVector<Departure*, 32> DepartureList;
00100
00101 #endif