OpenTTD
Public Member Functions | Private Attributes
CargoArray Struct Reference

Class for storing amounts of cargo. More...

#include <cargo_type.h>

Public Member Functions

 CargoArray ()
 Default constructor. More...
 
void Clear ()
 Reset all entries. More...
 
uint & operator[] (CargoID cargo)
 Read/write access to an amount of a specific cargo type. More...
 
const uint & operator[] (CargoID cargo) const
 Read-only access to an amount of a specific cargo type. More...
 
template<typename T >
const T GetSum () const
 Get the sum of all cargo amounts. More...
 
byte GetCount () const
 Get the amount of cargos that have an amount. More...
 

Private Attributes

uint amount [NUM_CARGO]
 Amount of each type of cargo.
 

Detailed Description

Class for storing amounts of cargo.

Definition at line 74 of file cargo_type.h.

Constructor & Destructor Documentation

◆ CargoArray()

CargoArray::CargoArray ( )
inline

Default constructor.

Definition at line 80 of file cargo_type.h.

References Clear().

Member Function Documentation

◆ Clear()

void CargoArray::Clear ( )
inline

Reset all entries.

Definition at line 86 of file cargo_type.h.

Referenced by CargoArray(), and GetArticulatedVehicleCargoesAndRefits().

◆ GetCount()

byte CargoArray::GetCount ( ) const
inline

Get the amount of cargos that have an amount.

Returns
The amount.

Definition at line 127 of file cargo_type.h.

References lengthof.

◆ GetSum()

template<typename T >
const T CargoArray::GetSum ( ) const
inline

Get the sum of all cargo amounts.

Returns
The sum.

Definition at line 114 of file cargo_type.h.

Referenced by GetTotalCapacityOfArticulatedParts().

◆ operator[]() [1/2]

uint& CargoArray::operator[] ( CargoID  cargo)
inline

Read/write access to an amount of a specific cargo type.

Parameters
cargoCargo type to access.

Definition at line 95 of file cargo_type.h.

◆ operator[]() [2/2]

const uint& CargoArray::operator[] ( CargoID  cargo) const
inline

Read-only access to an amount of a specific cargo type.

Parameters
cargoCargo type to access.

Definition at line 104 of file cargo_type.h.


The documentation for this struct was generated from the following file: