|
OpenTTD Source 20260531-master-g0e951f3528
|
Simple collection class for a list of cargo packets. More...
#include <cargopacket.h>
Public Types | |
| enum class | MoveToAction : uint8_t { Transfer , Deliver , Keep , Load , End } |
| Kind of actions that could be done with packets on move. More... | |
| typedef Tcont::iterator | Iterator |
| The iterator for our container. | |
| typedef Tcont::reverse_iterator | ReverseIterator |
| The reverse iterator for our container. | |
| typedef Tcont::const_iterator | ConstIterator |
| The const iterator for our container. | |
| typedef Tcont::const_reverse_iterator | ConstReverseIterator |
| The const reverse iterator for our container. | |
Public Member Functions | |
| CargoList () | |
| Create the cargo list. | |
| ~CargoList () | |
| Destroy the cargolist ("frees" all cargo packets). | |
| void | OnCleanPool () |
| Empty the cargo list, but don't free the cargo packets; the cargo packets are cleaned by CargoPacket's CleanPool. | |
| const Tcont * | Packets () const |
| Returns a pointer to the cargo packet list (so you can iterate over it etc). | |
| uint | PeriodsInTransit () const |
| Returns average number of cargo aging periods in transit for a cargo entity. | |
| void | InvalidateCache () |
| Invalidates the cached data and rebuilds it. | |
Protected Member Functions | |
| void | AddToCache (const CargoPacket *cp) |
| Update the cache to reflect adding of this packet. | |
| void | RemoveFromCache (const CargoPacket *cp, uint count) |
| Update the cached values to reflect the removal of this packet or part of it. | |
Static Protected Member Functions | |
| static bool | TryMerge (CargoPacket *cp, CargoPacket *icp) |
| Tries to merge the second packet into the first and return if that was successful. | |
Protected Attributes | |
| uint | count = 0 |
| Cache for the number of cargo entities. | |
| uint64_t | cargo_periods_in_transit = 0 |
| Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours. | |
| Tcont | packets {} |
| The cargo packets in this list. | |
Simple collection class for a list of cargo packets.
| Tinst | Actual instantiation of this cargo list. |
Definition at line 268 of file cargopacket.h.
| typedef Tcont::const_iterator CargoList< Tinst, Tcont >::ConstIterator |
The const iterator for our container.
Definition at line 275 of file cargopacket.h.
| typedef Tcont::const_reverse_iterator CargoList< Tinst, Tcont >::ConstReverseIterator |
The const reverse iterator for our container.
Definition at line 277 of file cargopacket.h.
| typedef Tcont::iterator CargoList< Tinst, Tcont >::Iterator |
The iterator for our container.
Definition at line 271 of file cargopacket.h.
| typedef Tcont::reverse_iterator CargoList< Tinst, Tcont >::ReverseIterator |
The reverse iterator for our container.
Definition at line 273 of file cargopacket.h.
|
strong |
Kind of actions that could be done with packets on move.
| Enumerator | |
|---|---|
| Transfer | Transfer the cargo to the station. |
| Deliver | Deliver the cargo to some town or industry. |
| Keep | Keep the cargo in the vehicle. |
| Load | Load the cargo from the station. |
| End | End marker. |
Definition at line 280 of file cargopacket.h.
|
inline |
Create the cargo list.
Definition at line 302 of file cargopacket.h.
Destroy the cargolist ("frees" all cargo packets).
Definition at line 166 of file cargopacket.cpp.
References packets.
|
protected |
Update the cache to reflect adding of this packet.
Increases count and periods_in_transit.
| cp | New packet to be inserted. |
Definition at line 203 of file cargopacket.cpp.
References cargo_periods_in_transit, count, CargoPacket::count, and CargoPacket::periods_in_transit.
Referenced by InvalidateCache().
| void CargoList< Tinst, Tcont >::InvalidateCache | ( | ) |
Invalidates the cached data and rebuilds it.
Definition at line 211 of file cargopacket.cpp.
References AddToCache(), cargo_periods_in_transit, count, and packets.
Referenced by CargoPacket::AfterLoad(), and CheckCaches().
| void CargoList< Tinst, Tcont >::OnCleanPool | ( | ) |
Empty the cargo list, but don't free the cargo packets; the cargo packets are cleaned by CargoPacket's CleanPool.
Definition at line 178 of file cargopacket.cpp.
References packets.
|
inline |
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Definition at line 312 of file cargopacket.h.
Referenced by CargoPacket::AfterLoad(), StationViewWindow::BuildCargoList(), SlStationCargo::FixPointers(), SlStationCargo::Load(), and SlStationCargo::Save().
|
inline |
Returns average number of cargo aging periods in transit for a cargo entity.
Definition at line 321 of file cargopacket.h.
Referenced by CheckCaches().
|
protected |
Update the cached values to reflect the removal of this packet or part of it.
Decreases count and periods_in_transit.
| cp | Packet to be removed from cache. |
| count | Amount of cargo from the given packet to be removed. |
Definition at line 190 of file cargopacket.cpp.
References cargo_periods_in_transit, count, and CargoPacket::periods_in_transit.
|
staticprotected |
Tries to merge the second packet into the first and return if that was successful.
Definition at line 229 of file cargopacket.cpp.
References CargoPacket::count, CargoPacket::MAX_COUNT, and CargoPacket::Merge().
|
protected |
Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours.
Definition at line 290 of file cargopacket.h.
Referenced by AddToCache(), InvalidateCache(), and RemoveFromCache().
|
protected |
Cache for the number of cargo entities.
Definition at line 289 of file cargopacket.h.
Referenced by AddToCache(), InvalidateCache(), and RemoveFromCache().
|
protected |
The cargo packets in this list.
Definition at line 292 of file cargopacket.h.
Referenced by InvalidateCache(), OnCleanPool(), and ~CargoList().