Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

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 258 of file cargopacket.h.


Member Typedef Documentation

The (direct) parent of this class.

Definition at line 261 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 New packet to be inserted.

Reimplemented from CargoList< VehicleCargoList >.

Definition at line 369 of file cargopacket.cpp.

References CargoList< VehicleCargoList >::AddToCache(), CargoPacket::feeder_share, and 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 First CargoPacket.
cp2 Second CargoPacket.
Returns:
True if they are mergeable.

Definition at line 294 of file cargopacket.h.

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

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

Returns total sum of the feeder share for all packets.

Returns:
The before mentioned number.

Definition at line 278 of file cargopacket.h.

References feeder_share.

Referenced by DrawRoadVehDetails(), and DrawShipDetails().

void VehicleCargoList::InvalidateCache (  ) 

Invalidates the cached data and rebuild it.

Reimplemented from CargoList< VehicleCargoList >.

Definition at line 391 of file cargopacket.cpp.

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

Referenced by CheckCaches().

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 358 of file cargopacket.cpp.

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


Friends And Related Function Documentation

friend class CargoList< VehicleCargoList > [friend]

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

Definition at line 270 of file cargopacket.h.

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 452 of file vehicle_sl.cpp.


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