OpenTTD Source: LinkGraph::BaseNode Struct Reference

OpenTTD Source 14.0-beta3

Public Member Functions | Data Fields | Private Member Functions
LinkGraph::BaseNode Struct Reference

Node of the link graph. More...

`#include <linkgraph.h>`

## Public Member Functions
| BaseNode (TileIndex xy=INVALID_TILE, StationID st=INVALID_STATION, uint demand=0)
| Create a node or clear it. More...
void | UpdateSupply (uint supply)
| Update the node's supply and set last_update to the current date. More...
void | UpdateLocation (TileIndex xy)
| Update the node's location on the map. More...
void | SetDemand (uint demand)
| Set the node's demand. More...
void | AddEdge (NodeID to, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode)
| Fill an edge with values from a link. More...
void | UpdateEdge (NodeID to, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode)
| Creates an edge if none exists yet or updates an existing edge. More...
void | RemoveEdge (NodeID to)
| Remove an outgoing edge from this node. More...
bool | HasEdgeTo (NodeID dest) const
| Check if an edge to a destination is present. More...
BaseEdge & | operator[] (NodeID to)
const BaseEdge & | operator[] (NodeID to) const

## Data Fields
uint | supply
| Supply at the station.
uint | demand
| Acceptance at the station.
StationID | station
| Station ID.
TileIndex | xy
| Location of the station referred to by the node.
TimerGameEconomy::Date | last_update
| When the supply was last updated.
std::vector< BaseEdge > | edges
| Sorted list of outgoing edges from this node.

## Private Member Functions
std::vector< BaseEdge >::iterator | GetEdge (NodeID dest)
std::vector< BaseEdge >::const_iterator | GetEdge (NodeID dest) const

## Detailed Description

Node of the link graph.

contains all relevant information from the associated station. It's copied so that the link graph job can work on its own data set in a separate thread.

Definition at line 90 of file linkgraph.h.

## Constructor & Destructor Documentation

## ◆ BaseNode()

LinkGraph::BaseNode::BaseNode | ( | TileIndex | xy = `INVALID_TILE`,
|  | StationID | st = `INVALID_STATION`,
|  | uint | demand = `0`
| ) |  |

Create a node or clear it.

Parameters

  xy | Location of the associated station.
  st | ID of the associated station.
  demand | Demand for cargo at the station.

Definition at line 26 of file linkgraph.cpp.

References TimerGameConst< struct Economy >::INVALID_DATE.

## Member Function Documentation

## ◆ AddEdge()

void LinkGraph::BaseNode::AddEdge | ( | NodeID | to,
|  | uint | capacity,
|  | uint | usage,
|  | uint32_t | travel_time,
|  | EdgeUpdateMode | mode
| ) |  |

Fill an edge with values from a link.

Set the restricted or unrestricted update timestamp according to the given update mode.

Parameters

  to | Destination node of the link.
  capacity | Capacity of the link.
  usage | Usage to be added.
  mode | Update mode to be used.

Definition at line 167 of file linkgraph.cpp.

References LinkGraph::BaseEdge::capacity, TimerGameEconomy::date, EUM_RESTRICTED, EUM_UNRESTRICTED, LinkGraph::BaseEdge::last_restricted_update, LinkGraph::BaseEdge::last_unrestricted_update, LinkGraph::BaseEdge::travel_time_sum, and LinkGraph::BaseEdge::usage.

## ◆ HasEdgeTo()

bool LinkGraph::BaseNode::HasEdgeTo | ( | NodeID | dest | ) | const
| inline

Check if an edge to a destination is present.

Parameters

  dest | Wanted edge destination.

Returns
  True if an edge is present.

Definition at line 138 of file linkgraph.h.

## ◆ RemoveEdge()

void LinkGraph::BaseNode::RemoveEdge | ( | NodeID | to | ) |

Remove an outgoing edge from this node.

Parameters

  to | ID of destination node.

Definition at line 201 of file linkgraph.cpp.

## ◆ SetDemand()

void LinkGraph::BaseNode::SetDemand | ( | uint | demand | ) |
| inline

Set the node's demand.

Parameters

  demand | New demand for the node.

Definition at line 124 of file linkgraph.h.

References demand.

## ◆ UpdateEdge()

void LinkGraph::BaseNode::UpdateEdge | ( | NodeID | to,
|  | uint | capacity,
|  | uint | usage,
|  | uint32_t | travel_time,
|  | EdgeUpdateMode | mode
| ) |  |

Creates an edge if none exists yet or updates an existing edge.

Parameters

  to | Target node.
  capacity | Capacity of the link.
  usage | Usage to be added.
  mode | Update mode to be used.

Definition at line 186 of file linkgraph.cpp.

## ◆ UpdateLocation()

void LinkGraph::BaseNode::UpdateLocation | ( | TileIndex | xy | ) |
| inline

Update the node's location on the map.

Parameters

  xy | New location.

Definition at line 115 of file linkgraph.h.

References xy.

## ◆ UpdateSupply()

void LinkGraph::BaseNode::UpdateSupply | ( | uint | supply | ) |
| inline

Update the node's supply and set last_update to the current date.

Parameters

  supply | Supply to be added.

Definition at line 105 of file linkgraph.h.

References TimerGameEconomy::date, and supply.

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

- src/linkgraph/linkgraph.h
- src/linkgraph/linkgraph.cpp