StationCargoList Class Reference

CargoList that is used for stations. More...

#include <cargopacket.h>

Inheritance diagram for StationCargoList:
CargoList< StationCargoList >

Public Types

typedef std::map< OrderID, int > OrderMap

Public Member Functions

void InvalidateCache ()
 Invalidates the cached data and rebuild it.
void UpdateCargoNextHop (Station *st, CargoID cid)
 Recompute the desired next hop of all cargo packets.
const OrderMap & CountForNextHop () const
 Gets the cargo counts per next hop.
int CountForNextHop (OrderID order) const
 Gets the cargo count for a next hop.

Static Public Member Functions

static bool AreMergable (const CargoPacket *cp1, const CargoPacket *cp2)
 Are two the two CargoPackets mergeable in the context of a list of CargoPackets for a Vehicle?
static void InvalidateAllTo (OrderID order, StationID st_unload)
 Invalidates the next hop info of all cargo packets with a given next order or unload station.
static void InvalidateAllTo (SourceType type, SourceID dest)
 Invalidates the next hop info of all cargo packets for a given destination.

Protected Types

typedef CargoList
< StationCargoList
Parent
 The (direct) parent of this class.

Protected Member Functions

void AddToCache (const CargoPacket *cp)
 Update the cache to reflect adding of this packet.
void RemoveFromCache (const CargoPacket *cp)
 Update the cached values to reflect the removal of this packet.
void RemoveFromCacheLocal (const CargoPacket *cp, uint amount)
 Update the local next-hop count cache.
bool UpdateCargoNextHop (CargoPacket *cp, Station *st, CargoID cid)
 Recompute the desired next hop of a cargo packet.

Protected Attributes

OrderMap order_cache
uint32 next_start
 Packet number to start the next hop update loop from.

Friends

class CargoList< StationCargoList >
 The super class ought to know what it's doing.
struct SaveLoadGetGoodsDesc ()
 The stations, via GoodsEntry, have a CargoList.

Detailed Description

CargoList that is used for stations.

Definition at line 390 of file cargopacket.h.


Member Typedef Documentation

The (direct) parent of this class.

Definition at line 396 of file cargopacket.h.


Member Function Documentation

void StationCargoList::AddToCache ( const CargoPacket cp  )  [protected]

Update the cache to reflect adding of this packet.

Increases count and days_in_transit.

Parameters:
cp New packet to be inserted.

Reimplemented from CargoList< StationCargoList >.

Definition at line 550 of file cargopacket.cpp.

References CargoList< StationCargoList >::AddToCache(), CargoPacket::count, and CargoPacket::next_order.

Referenced by InvalidateAllTo(), and UpdateCargoNextHop().

static bool StationCargoList::AreMergable ( const CargoPacket cp1,
const CargoPacket cp2 
) [inline, static]

Are two the two CargoPackets mergeable in the context of a list of CargoPackets for a Vehicle?

Parameters:
cp1 First CargoPacket.
cp2 Second CargoPacket.
Returns:
True if they are mergeable.

Definition at line 444 of file cargopacket.h.

References CargoPacket::days_in_transit, CargoPacket::dest_id, CargoPacket::dest_type, CargoPacket::dest_xy, CargoPacket::flags, CargoPacket::next_order, CargoPacket::next_station, CargoPacket::source_id, CargoPacket::source_type, and CargoPacket::source_xy.

int StationCargoList::CountForNextHop ( OrderID  order  )  const [inline]

Gets the cargo count for a next hop.

Parameters:
order The next hop.
Returns:
The cargo count for the specified next hop.

Definition at line 431 of file cargopacket.h.

const OrderMap& StationCargoList::CountForNextHop (  )  const [inline]

Gets the cargo counts per next hop.

Returns:
Cargo counts.

Definition at line 421 of file cargopacket.h.

Referenced by SmallMapWindow::DrawRouteLinks(), LoadUnloadStation(), LoadUnloadVehicle(), and CYapfCostRouteLinkT< Types >::RouteLinkCost().

void StationCargoList::InvalidateAllTo ( SourceType  type,
SourceID  dest 
) [static]

Invalidates the next hop info of all cargo packets for a given destination.

Parameters:
order Next order to invalidate.

Definition at line 647 of file cargopacket.cpp.

References AddToCache(), GoodsEntry::cargo, CargoPacket::dest_id, CargoPacket::dest_type, Station::goods, INVALID_ORDER, CargoPacket::next_order, CargoPacket::next_station, NUM_CARGO, CargoList< Tinst >::packets, and RemoveFromCache().

void StationCargoList::InvalidateAllTo ( OrderID  order,
StationID  st_unload 
) [static]

Invalidates the next hop info of all cargo packets with a given next order or unload station.

Parameters:
order Next order to invalidate.
st_unload Unload station to invalidate.

Definition at line 623 of file cargopacket.cpp.

References AddToCache(), GoodsEntry::cargo, Station::goods, INVALID_ORDER, CargoPacket::next_order, CargoPacket::next_station, NUM_CARGO, CargoList< Tinst >::packets, and RemoveFromCache().

Referenced by CargoPacket::InvalidateAllFrom(), and RouteLink::~RouteLink().

void StationCargoList::InvalidateCache (  ) 

Invalidates the cached data and rebuild it.

Reimplemented from CargoList< StationCargoList >.

Definition at line 557 of file cargopacket.cpp.

References CargoList< StationCargoList >::InvalidateCache().

Referenced by CargoPacket::AfterLoad(), and CheckCaches().

void StationCargoList::RemoveFromCache ( const CargoPacket cp  )  [protected]

Update the cached values to reflect the removal of this packet.

Decreases count and days_in_transit.

Parameters:
cp Packet to be removed from cache.

Reimplemented from CargoList< StationCargoList >.

Definition at line 539 of file cargopacket.cpp.

References CargoPacket::count, CargoList< StationCargoList >::RemoveFromCache(), and RemoveFromCacheLocal().

Referenced by InvalidateAllTo(), and UpdateCargoNextHop().

void StationCargoList::RemoveFromCacheLocal ( const CargoPacket cp,
uint  amount 
) [protected]

Update the local next-hop count cache.

Parameters:
cp Packet the be removed.
amount Cargo amount to be removed.

Reimplemented from CargoList< StationCargoList >.

Definition at line 528 of file cargopacket.cpp.

References CargoPacket::next_order.

Referenced by RemoveFromCache().

void StationCargoList::UpdateCargoNextHop ( Station st,
CargoID  cid 
)

Recompute the desired next hop of all cargo packets.

Parameters:
st Station of this list.
cid Cargo type of this list.

Definition at line 596 of file cargopacket.cpp.

References _settings_game, EconomySettings::cargodest, CargoList< StationCargoList >::count, GameSettings::economy, INVALID_SOURCE, next_start, CargoList< StationCargoList >::packets, CargodestSettings::route_recalc_chunk, and UpdateCargoNextHop().

bool StationCargoList::UpdateCargoNextHop ( CargoPacket cp,
Station st,
CargoID  cid 
) [protected, virtual]

Recompute the desired next hop of a cargo packet.

Parameters:
cp Cargo packet to update.
st Station of this list.
cid Cargo type of this list.
Returns:
False if the packet was deleted, true otherwise.

Reimplemented from CargoList< StationCargoList >.

Definition at line 570 of file cargopacket.cpp.

References AddToCache(), FindRouteLinkForCargo(), RouteLink::GetOriginOrderId(), CargoPacket::next_order, CargoPacket::next_station, and RemoveFromCache().

Referenced by Vehicle::BeginLoading(), and UpdateCargoNextHop().


Friends And Related Function Documentation

friend class CargoList< StationCargoList > [friend]

The super class ought to know what it's doing.

Definition at line 409 of file cargopacket.h.

struct SaveLoad* GetGoodsDesc (  )  [friend]

The stations, via GoodsEntry, have a CargoList.

Returns:
the saveload description for GoodsEntry.

Definition at line 244 of file station_sl.cpp.


The documentation for this class was generated from the following files:

Generated on Mon May 9 05:20:32 2011 for OpenTTD by  doxygen 1.6.1