-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_generator.h
158 lines (129 loc) · 4.25 KB
/
train_generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* train_generator.h
*
* Created on: Dec 6, 2015
* Author: pavel
*/
#ifndef TRAIN_GENERATOR_H_
#define TRAIN_GENERATOR_H_
#include <simlib.h>
#include <iostream>
#include <vector>
class CStation;
class CTimeInterval;
class CTrainGenerator : public Event
{
public:
enum Frequency
{
FREQ_ONCE = 0,
FREQ_HOURLY = 60,
FREQ_DAILY = 24 * FREQ_HOURLY,
FREQ_WEEKLY = 7 * FREQ_DAILY
};
typedef std::vector<CTimeInterval*> ScheduleExceptions;
/**
* \brief Constructor.
*/
CTrainGenerator(const std::string& trainTitle,
CStation& startStation,
CStation& targetStation,
Frequency frequency,
unsigned scheduleStartTime,
unsigned scheduleTargetStationArrival,
unsigned averageDelay = 0,
bool bStopsInMainStation = false,
unsigned scheduleMainStationArrival = 0,
unsigned scheduleMainStationDeparture = 0);
virtual ~CTrainGenerator();
/**
* \brief Add interval when the train is not generated
*/
void AddException(unsigned minutesStart, unsigned minutesEnd);
/**
* \{
* \brief Getter.
*/
const std::string& GetTrainTitle() const;
unsigned GetAverageDelay() const;
Frequency GetFrequency() const;
bool StopsInMainStation() const;
unsigned GetMainStationArrival() const;
unsigned GetMainStationDeparture() const;
const ScheduleExceptions& GetScheduleExceptions() const;
CStation& GetStartStation();
CStation& GetTargetStation();
unsigned GetTargetStationArrival() const;
/** \} */
protected:
// train title
std::string m_TrainTitle;
CStation& m_StartStation;
CStation& m_TargetStation;
Frequency m_Frequency;
// start time
unsigned m_ScheduleStartTime;
// arrival at the target station
unsigned m_ScheduleTargetStationArrival;
// average delay
unsigned m_AverageDelay;
// stops in main station
bool m_StopsInMainStation;
// stop at main station
unsigned m_ScheduleMainStationArrival;
unsigned m_ScheduleMainStationDeparture;
// schedule exceptions
ScheduleExceptions m_ScheduleExceptions;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// Public interface //
////////////////////////////////////////////////////////////////////////////////////////////////////
inline const std::string& CTrainGenerator::GetTrainTitle() const
{
return m_TrainTitle;
}
inline unsigned CTrainGenerator::GetAverageDelay() const
{
return m_AverageDelay;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline CTrainGenerator::Frequency CTrainGenerator::GetFrequency() const
{
return m_Frequency;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool CTrainGenerator::StopsInMainStation() const
{
return m_StopsInMainStation;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline unsigned CTrainGenerator::GetMainStationArrival() const
{
return m_ScheduleMainStationArrival;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline unsigned CTrainGenerator::GetMainStationDeparture() const
{
return m_ScheduleMainStationDeparture;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline const CTrainGenerator::ScheduleExceptions& CTrainGenerator::GetScheduleExceptions() const
{
return m_ScheduleExceptions;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline CStation& CTrainGenerator::GetStartStation()
{
return m_StartStation;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline CStation& CTrainGenerator::GetTargetStation()
{
return m_TargetStation;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline unsigned CTrainGenerator::GetTargetStationArrival() const
{
return m_ScheduleTargetStationArrival;
}
#endif /* TRAIN_GENERATOR_H_ */