Remove costly recalculation of a date format we already have.
[openttd-joker.git] / src / script / api / script_stationlist.hpp
blob4efd9caa1be5d36a32c17c366cea3db72231fe46
1 /* $Id: script_stationlist.hpp 23615 2011-12-19 20:57:34Z truebrain $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file script_stationlist.hpp List all the stations (you own). */
12 #ifndef SCRIPT_STATIONLIST_HPP
13 #define SCRIPT_STATIONLIST_HPP
15 #include "script_list.hpp"
16 #include "script_station.hpp"
18 /**
19 * Creates a list of stations of which you are the owner.
20 * @api ai game
21 * @ingroup ScriptList
23 class ScriptStationList : public ScriptList {
24 public:
25 /**
26 * @param station_type The type of station to make a list of stations for.
28 ScriptStationList(ScriptStation::StationType station_type);
31 /**
32 * Creates a list of stations associated with cargo at a station. This is very generic. Use the
33 * subclasses for all practical purposes.
34 * @api ai game
35 * @ingroup ScriptList
37 class ScriptStationList_Cargo : public ScriptList {
38 public:
39 /**
40 * Criteria of selecting and grouping cargo at a station.
42 enum CargoSelector {
43 CS_BY_FROM, ///< Group by origin station.
44 CS_VIA_BY_FROM, ///< Select by next hop and group by origin station.
45 CS_BY_VIA, ///< Group by next hop.
46 CS_FROM_BY_VIA ///< Select by origin station and group by next hop.
49 /**
50 * Ways of associating cargo to stations.
52 enum CargoMode {
53 CM_WAITING, ///< Waiting cargo.
54 CM_PLANNED ///< Planned cargo.
57 /**
58 * Creates a list of stations associated with cargo in the specified way, selected and grouped
59 * by the chosen criteria.
60 * @param mode Mode of association, either waiting cargo or planned cargo.
61 * @param selector Mode of grouping and selecting to be applied.
62 * @param station_id Station to be queried.
63 * @param cargo Cargo type to query for.
64 * @param other_station Other station to restrict the query with.
66 ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
68 protected:
70 /**
71 * Creates an empty list.
73 ScriptStationList_Cargo() {}
76 /**
77 * Creates a list of stations associated with cargo waiting at a station. This is very generic. Use
78 * the subclasses for all practical purposes.
79 * @api ai game
80 * @ingroup ScriptList
82 class ScriptStationList_CargoWaiting : public ScriptStationList_Cargo {
83 protected:
84 friend class ScriptStationList_Cargo;
86 /**
87 * Creates an empty list.
89 ScriptStationList_CargoWaiting() {}
91 /**
92 * Add waiting cargo to the list.
93 * @param station_id Station to query for waiting cargo.
94 * @param cargo Cargo type to query for.
95 * @param other_station Other station to restrict the query with.
97 template<CargoSelector Tselector>
98 void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION);
100 public:
103 * Creates a list of stations associated with waiting cargo, selected and grouped by the chosen
104 * criteria.
105 * @param selector Mode of grouping and selecting to be applied.
106 * @param station_id Station to be queried.
107 * @param cargo Cargo type to query for.
108 * @param other_station Other station to restrict the query with.
110 ScriptStationList_CargoWaiting(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
114 * Creates a list of stations associated with cargo planned to pass a station. This is very
115 * generic. Use the subclasses for all practical purposes.
116 * @api ai game
117 * @ingroup ScriptList
119 class ScriptStationList_CargoPlanned : public ScriptStationList_Cargo {
120 protected:
121 friend class ScriptStationList_Cargo;
124 * Creates an empty list.
126 ScriptStationList_CargoPlanned() {}
129 * Add planned cargo to the list.
130 * @param station_id Station to query for waiting cargo.
131 * @param cargo Cargo type to query for.
132 * @param other_station Other station to restrict the query with.
134 template<CargoSelector Tselector>
135 void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION);
137 public:
140 * Creates a list of stations associated with cargo planned to pass the station, selected and
141 * grouped by the chosen criteria.
142 * @param selector Mode of grouping and selecting to be applied.
143 * @param station_id Station to be queried.
144 * @param cargo Cargo type to query for.
145 * @param other_station Other station to restrict the query with.
147 ScriptStationList_CargoPlanned(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station);
151 * Creates a list of origin stations of waiting cargo at a station, with the amounts of cargo
152 * waiting from each of those origin stations as values.
153 * @api ai game
154 * @ingroup ScriptList
156 class ScriptStationList_CargoWaitingByFrom : public ScriptStationList_CargoWaiting {
157 public:
159 * @param station_id Station to query for waiting cargo.
160 * @param cargo Cargo type to query for.
162 ScriptStationList_CargoWaitingByFrom(StationID station_id, CargoID cargo);
166 * Creates a list of origin stations of cargo waiting at a station for a transfer via another
167 * station, with the amounts of cargo waiting from each of those origin stations as values.
168 * @api ai game
169 * @ingroup ScriptList
171 class ScriptStationList_CargoWaitingViaByFrom : public ScriptStationList_CargoWaiting {
172 public:
174 * @param station_id Station to query for waiting cargo.
175 * @param cargo Cargo type to query for.
176 * @param via Next hop to restrict the query with.
178 ScriptStationList_CargoWaitingViaByFrom(StationID station_id, CargoID cargo, StationID via);
182 * Creates a list of next hops of waiting cargo at a station, with the amounts of cargo waiting for
183 * each of those next hops as values.
184 * @api ai game
185 * @ingroup ScriptList
187 class ScriptStationList_CargoWaitingByVia : public ScriptStationList_CargoWaiting {
188 public:
190 * @param station_id Station to query for waiting cargo.
191 * @param cargo Cargo type to query for.
193 ScriptStationList_CargoWaitingByVia(StationID station_id, CargoID cargo);
197 * Creates a list of next hops of waiting cargo from a specific station at another station, with
198 * the amounts of cargo waiting for each of those next hops as values.
199 * @api ai game
200 * @ingroup ScriptList
202 class ScriptStationList_CargoWaitingFromByVia : public ScriptStationList_CargoWaiting {
203 public:
205 * @param station_id Station to query for waiting cargo.
206 * @param cargo Cargo type to query for.
207 * @param from Origin station to restrict the query with.
209 ScriptStationList_CargoWaitingFromByVia(StationID station_id, CargoID cargo, StationID from);
213 * Creates a list of origin stations of cargo planned to pass a station, with the monthly amounts
214 * of cargo planned for each of those origin stations as values.
215 * @api ai game
216 * @ingroup ScriptList
218 class ScriptStationList_CargoPlannedByFrom : public ScriptStationList_CargoPlanned {
219 public:
221 * @param station_id Station to query for planned flows.
222 * @param cargo Cargo type to query for.
224 ScriptStationList_CargoPlannedByFrom(StationID station_id, CargoID cargo);
228 * Creates a list of origin stations of cargo planned to pass a station going via another station,
229 * with the monthly amounts of cargo planned for each of those origin stations as values.
230 * @api ai game
231 * @ingroup ScriptList
233 class ScriptStationList_CargoPlannedViaByFrom : public ScriptStationList_CargoPlanned {
234 public:
236 * @param station_id Station to query for planned flows.
237 * @param cargo Cargo type to query for.
238 * @param via Next hop to restrict the query with.
240 ScriptStationList_CargoPlannedViaByFrom(StationID station_id, CargoID cargo, StationID via);
244 * Creates a list of next hops of cargo planned to pass a station, with the monthly amounts of
245 * cargo planned for each of those next hops as values.
246 * Cargo planned to go "via" the station being queried will actually be delivered there.
247 * @api ai game
248 * @ingroup ScriptList
250 class ScriptStationList_CargoPlannedByVia : public ScriptStationList_CargoPlanned {
251 public:
253 * @param station_id Station to query for planned flows.
254 * @param cargo Cargo type to query for.
256 ScriptStationList_CargoPlannedByVia(StationID station_id, CargoID cargo);
260 * Creates a list of next hops of cargo planned to pass a station and originating from another
261 * station, with the monthly amounts of cargo planned for each of those next hops as values.
262 * Cargo planned to go "via" the station being queried will actually be delivered there.
263 * @api ai game
264 * @ingroup ScriptList
266 class ScriptStationList_CargoPlannedFromByVia : public ScriptStationList_CargoPlanned {
267 public:
269 * @param station_id Station to query for planned flows.
270 * @param cargo Cargo type to query for.
271 * @param from Origin station to restrict the query with.
273 ScriptStationList_CargoPlannedFromByVia(StationID station_id, CargoID cargo, StationID from);
277 * Creates a list of stations which the vehicle has in its orders.
278 * @api ai game
279 * @ingroup ScriptList
281 class ScriptStationList_Vehicle : public ScriptList {
282 public:
284 * @param vehicle_id The vehicle to get the list of stations he has in its orders from.
286 ScriptStationList_Vehicle(VehicleID vehicle_id);
289 #endif /* SCRIPT_STATIONLIST_HPP */