Public Member Functions | Static Public Attributes | Private Attributes | Friends

# LinkStat Class Reference

Link statistics. More...

`#include <station_base.h>`

Inheritance diagram for LinkStat:

## Public Member Functions
FORCEINLINE | LinkStat (uint distance=1, uint capacity=0, uint frozen=0, uint usage=0)
FORCEINLINE void | Clear ()
| Reset everything to 0.
FORCEINLINE void | Decrease ()
| Apply the moving averages to usage and capacity.
FORCEINLINE uint | Capacity () const
| Get an estimate of the current capacity by calculating the moving average.
FORCEINLINE uint | Usage () const
| Get an estimate of the current usage by calculating the moving average.
FORCEINLINE uint | Frozen () const
| Get the amount of frozen capacity.
FORCEINLINE void | Increase (uint capacity, uint usage)
| Add some capacity and usage.
FORCEINLINE void | Freeze (uint capacity)
| Freeze some of the capacity and prevent it from being decreased by the moving average.
FORCEINLINE void | Unfreeze (uint capacity)
| Thaw some of the frozen capacity and make it available for Decrease().
FORCEINLINE void | Unfreeze ()
| Thaw all frozen capacity.
FORCEINLINE bool | IsNull () const
| Check if the capacity is 0.
## Static Public Attributes
static const uint | MIN_AVERAGE_LENGTH = 96
| Minimum length of moving averages for capacity and usage.
## Private Attributes
uint | capacity
| Capacity of the link.
uint | frozen
| Capacity of currently loading vehicles.
uint | usage
| Usage of the link.
## Friends
const SaveLoad * | GetLinkStatDesc ()
| Wrapper function to get the LinkStat's internal structure while some of the variables are private.

## Detailed Description

Link statistics.

They include figures for capacity and usage of a link. Both are moving averages which are increased for every vehicle arriving at the destination station and decreased in regular intervals. Additionally while a vehicle is loading at the source station part of the capacity is frozen and prevented from being decreased. This is done so that the link won't break down all the time when the typical "full load" order is used.

Definition at line 38 of file station_base.h.

## Member Function Documentation

FORCEINLINE uint LinkStat::Capacity | ( |  | ) | const`[inline]`

Get an estimate of the current capacity by calculating the moving average.

Returns:
  Capacity.

Definition at line 91 of file station_base.h.

References capacity, and MovingAverage< uint >::Monthly().

FORCEINLINE void LinkStat::Freeze | ( | uint | capacity | ) | `[inline]`

Freeze some of the capacity and prevent it from being decreased by the moving average.

Parameters:

  | capacity | Amount of capacity to be frozen.

Definition at line 130 of file station_base.h.

References frozen, and max().

Referenced by IncreaseStats().

FORCEINLINE uint LinkStat::Frozen | ( |  | ) | const`[inline]`

Get the amount of frozen capacity.

Returns:
  Frozen capacity.

Definition at line 109 of file station_base.h.

References frozen.

Referenced by DecreaseFrozen().

FORCEINLINE void LinkStat::Increase | ( | uint | capacity,
|  | uint | usage |
| ) |  |  | `[inline]`

Add some capacity and usage.

Parameters:

  | capacity | Additional capacity.
  | usage | Additional usage.

Definition at line 119 of file station_base.h.

Referenced by IncreaseStats().

FORCEINLINE bool LinkStat::IsNull | ( |  | ) | const`[inline]`

Check if the capacity is 0.

This is necessary as Capacity() might return 0 even if there is a miniscule amount of capacity left.

Returns:
  If capacity is 0.

Definition at line 158 of file station_base.h.

References capacity.

Referenced by DecreaseFrozen(), IncreaseStats(), and Station::RunAverages().

FORCEINLINE void LinkStat::Unfreeze | ( | uint | capacity | ) | `[inline]`

Thaw some of the frozen capacity and make it available for Decrease().

Parameters:

  | capacity | Capacity to be thawed.

Definition at line 140 of file station_base.h.

References frozen.

Referenced by DecreaseFrozen().

FORCEINLINE uint LinkStat::Usage | ( |  | ) | const`[inline]`

Get an estimate of the current usage by calculating the moving average.

Usage.

Definition at line 100 of file station_base.h.

References MovingAverage< uint >::Monthly(), and usage.

## Friends And Related Function Documentation

const SaveLoad* GetLinkStatDesc | ( |  | ) | `[friend]`

Wrapper function to get the LinkStat's internal structure while some of the variables are private.

Returns:
  Saveload description for LinkStat.

Definition at line 248 of file station_sl.cpp.

## Field Documentation

uint LinkStat::capacity`[private]`

Capacity of the link.

This is a moving average. Use MovingAverage::Monthly() to get a meaningful value.

Definition at line 44 of file station_base.h.

Referenced by Capacity(), Clear(), Decrease(), and IsNull().

uint LinkStat::usage`[private]`

Usage of the link.

This is a moving average. Use MovingAverage::Monthly() to get a meaningful value.

Definition at line 55 of file station_base.h.

Referenced by Clear(), Decrease(), and Usage().

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

- src/station_base.h