OpenTTD Source 20260206-master-g4d4e37dbf1
LinkGraph::BaseNode Struct Reference

Node of the link graph. More...

#include <linkgraph.h>

Public Member Functions

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

Data Fields

uint supply = 0
 Supply at the station.
uint demand = 0
 Acceptance at the station.
StationID station = StationID::Invalid()
 Station ID.
TileIndex xy = INVALID_TILE
 Location of the station referred to by the node.
TimerGameEconomy::Date last_update {}
 When the supply was last updated.
std::vector< BaseEdgeedges
 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 = StationID::Invalid(),
uint demand = 0 )

Create a node or clear it.

Parameters
xyLocation of the associated station.
stID of the associated station.
demandDemand for cargo at the station.

Definition at line 26 of file linkgraph.cpp.

References BaseNode(), demand, TimerGameConst< struct Economy >::INVALID_DATE, last_update, LinkGraph::LinkGraph(), station, supply, and xy.

Referenced by BaseNode().

Member Function Documentation

◆ AddEdge()

void LinkGraph::BaseNode::AddEdge ( NodeID to,
uint capacity,
uint usage,
uint32_t travel_time,
EdgeUpdateModes modes )

Fill an edge with values from a link.

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

Parameters
toDestination node of the link.
capacityCapacity of the link.
usageUsage to be added.
travel_timeTravel time to be added, in ticks.
modesUpdate modes to be used.

Definition at line 168 of file linkgraph.cpp.

References LinkGraph::BaseEdge::capacity, TimerGameEconomy::date, HasEdgeTo(), LinkGraph::BaseEdge::last_restricted_update, LinkGraph::BaseEdge::last_unrestricted_update, Restricted, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), LinkGraph::BaseEdge::travel_time_sum, Unrestricted, and LinkGraph::BaseEdge::usage.

Referenced by UpdateEdge().

◆ GetEdge() [1/2]

std::vector< BaseEdge >::iterator LinkGraph::BaseNode::GetEdge ( NodeID dest)
inlineprivate

Definition at line 156 of file linkgraph.h.

◆ GetEdge() [2/2]

std::vector< BaseEdge >::const_iterator LinkGraph::BaseNode::GetEdge ( NodeID dest) const
inlineprivate

Definition at line 161 of file linkgraph.h.

◆ HasEdgeTo()

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

Check if an edge to a destination is present.

Parameters
destWanted edge destination.
Returns
True if an edge is present.

Definition at line 138 of file linkgraph.h.

Referenced by AddEdge(), and UpdateEdge().

◆ operator[]() [1/2]

BaseEdge & LinkGraph::BaseNode::operator[] ( NodeID to)
inline

Definition at line 143 of file linkgraph.h.

◆ operator[]() [2/2]

const BaseEdge & LinkGraph::BaseNode::operator[] ( NodeID to) const
inline

Definition at line 149 of file linkgraph.h.

◆ RemoveEdge()

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

Remove an outgoing edge from this node.

Parameters
toID of destination node.

Definition at line 203 of file linkgraph.cpp.

◆ SetDemand()

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

Set the node's demand.

Parameters
demandNew 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,
EdgeUpdateModes modes )

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

Parameters
toTarget node.
capacityCapacity of the link.
usageUsage to be added.
travel_timeTravel time to be added, in ticks.
modesUpdate modes to be used.

Definition at line 188 of file linkgraph.cpp.

References AddEdge(), and HasEdgeTo().

◆ UpdateLocation()

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

Update the node's location on the map.

Parameters
xyNew 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
supplySupply to be added.

Definition at line 105 of file linkgraph.h.

References TimerGameEconomy::date, and supply.

Field Documentation

◆ demand

uint LinkGraph::BaseNode::demand = 0

Acceptance at the station.

Definition at line 92 of file linkgraph.h.

Referenced by BaseNode(), AsymmetricScaler::HasDemandLeft(), SymmetricScaler::HasDemandLeft(), and SetDemand().

◆ edges

std::vector<BaseEdge> LinkGraph::BaseNode::edges

Sorted list of outgoing edges from this node.

Definition at line 97 of file linkgraph.h.

Referenced by SlLinkgraphEdge::Load(), LinkGraphOverlay::RebuildCache(), and SlLinkgraphEdge::Save().

◆ last_update

TimerGameEconomy::Date LinkGraph::BaseNode::last_update {}

When the supply was last updated.

Definition at line 95 of file linkgraph.h.

Referenced by BaseNode(), and LinkGraph::ShiftDates().

◆ station

StationID LinkGraph::BaseNode::station = StationID::Invalid()

Station ID.

Definition at line 93 of file linkgraph.h.

Referenced by BaseNode(), FlowMapper::Run(), and LinkGraphJob::~LinkGraphJob().

◆ supply

◆ xy

TileIndex LinkGraph::BaseNode::xy = INVALID_TILE

Location of the station referred to by the node.

Definition at line 94 of file linkgraph.h.

Referenced by BaseNode(), and UpdateLocation().


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