VehicleCargoList Class Reference

CargoList that is used for vehicles. More...

#include <cargopacket.h>

Inheritance diagram for VehicleCargoList:

CargoList< VehicleCargoList >

Public Member Functions

FORCEINLINE Money FeederShare () const
 Returns total sum of the feeder share for all packets.
void AgeCargo ()
 Ages the all cargo in this list.
void InvalidateCache ()
 Invalidates the cached data and rebuild it.

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?

Protected Types

typedef CargoList
< VehicleCargoList
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.

Protected Attributes

Money feeder_share
 Cache for the feeder share.

Friends

class CargoList< VehicleCargoList >
 The super class ought to know what it's doing.
struct SaveLoadGetVehicleDescription (VehicleType vt)
 The vehicles have a cargo list (and we want that saved).

Detailed Description

CargoList that is used for vehicles.

Definition at line 328 of file cargopacket.h.


Member Function Documentation

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

Update the cache to reflect adding of this packet.

Increases count, feeder share and days_in_transit

Parameters:
cp a new packet to be inserted

Reimplemented from CargoList< VehicleCargoList >.

Definition at line 261 of file cargopacket.cpp.

References CargoList< VehicleCargoList >::AddToCache(), CargoPacket::feeder_share, and feeder_share.

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

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

Decreases count, feeder share and days_in_transit

Parameters:
cp Packet to be removed from cache

Reimplemented from CargoList< VehicleCargoList >.

Definition at line 255 of file cargopacket.cpp.

References CargoPacket::feeder_share, feeder_share, and CargoList< VehicleCargoList >::RemoveFromCache().

FORCEINLINE Money VehicleCargoList::FeederShare (  )  const [inline]

Returns total sum of the feeder share for all packets.

Returns:
the before mentioned number

Definition at line 359 of file cargopacket.h.

References feeder_share.

static bool VehicleCargoList::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 the first CargoPacket
cp2 the second CargoPacket
Returns:
true if they are mergeable

Definition at line 379 of file cargopacket.h.

References CargoPacket::days_in_transit, CargoPacket::loaded_at_xy, CargoPacket::source_id, CargoPacket::source_type, and CargoPacket::source_xy.


Friends And Related Function Documentation

struct SaveLoad* GetVehicleDescription ( VehicleType  vt  )  [friend]

The vehicles have a cargo list (and we want that saved).

Parameters:
vt the vehicle type. Can be VEH_END for the common vehicle description data
Returns:
the saveload description

Save and load of vehicles

Definition at line 401 of file vehicle_sl.cpp.


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

Generated on Wed Dec 23 23:28:25 2009 for OpenTTD by  doxygen 1.5.6