OpenTTD Source: LinkGraph::Node Class Reference

OpenTTD Source 13.1

Public Member Functions
LinkGraph::Node Class Reference

Updatable node class. More...

`#include <linkgraph.h>`

Inheritance diagram for LinkGraph::Node:

## Public Member Functions
| Node (LinkGraph *lg, NodeID node)
| Constructor. More...
Edge | operator[] (NodeID to)
| Get an Edge. More...
EdgeIterator | Begin ()
| Get an iterator pointing to the start of the edges array. More...
EdgeIterator | End ()
| Get an iterator pointing beyond the end of the edges array. 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 time, EdgeUpdateMode mode)
| Fill an edge with values from a link. More...
void | UpdateEdge (NodeID to, uint capacity, uint usage, uint32 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...
Public Member Functions inherited from LinkGraph::NodeWrapper< BaseNode, BaseEdge >
| NodeWrapper (BaseNode &node, BaseEdge *edges, NodeID index)
| Wrap a node. More...
uint | Supply () const
| Get supply of wrapped node. More...
uint | Demand () const
| Get demand of wrapped node. More...
StationID | Station () const
| Get ID of station belonging to wrapped node. More...
Date | LastUpdate () const
| Get node's last update. More...
TileIndex | XY () const
| Get the location of the station associated with the node. More...

## Additional Inherited Members
Protected Attributes inherited from LinkGraph::NodeWrapper< BaseNode, BaseEdge >
BaseNode & | node
| Node being wrapped.
BaseEdge * | edges
| Outgoing edges for wrapped node.
NodeID | index
| ID of wrapped node.

## Detailed Description

Updatable node class.

The node itself as well as its edges can be modified.

Definition at line 380 of file linkgraph.h.

## Constructor & Destructor Documentation

## ◆ Node()

LinkGraph::Node::Node | ( | LinkGraph * | lg,
|  | NodeID | node
| ) |  |
| inline

Constructor.

Parameters

  lg | LinkGraph to get the node from.
  node | ID of the node.

Definition at line 387 of file linkgraph.h.

## Member Function Documentation

## ◆ AddEdge()

void LinkGraph::Node::AddEdge | ( | NodeID | to,
|  | uint | capacity,
|  | uint | usage,
|  | uint32 | 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 200 of file linkgraph.cpp.

References _date, LinkGraph::BaseEdge::capacity, LinkGraph::edges, EUM_RESTRICTED, EUM_UNRESTRICTED, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::index, LinkGraph::BaseEdge::last_restricted_update, LinkGraph::BaseEdge::last_unrestricted_update, LinkGraph::BaseEdge::next_edge, LinkGraph::BaseEdge::travel_time_sum, and LinkGraph::BaseEdge::usage.

## ◆ Begin()

EdgeIterator LinkGraph::Node::Begin | ( |  | ) |
| inline

Get an iterator pointing to the start of the edges array.

Returns
  Edge iterator.

Definition at line 403 of file linkgraph.h.

Referenced by DeleteStaleLinks().

## ◆ End()

EdgeIterator LinkGraph::Node::End | ( |  | ) |
| inline

Get an iterator pointing beyond the end of the edges array.

Returns
  Constant edge iterator.

Definition at line 409 of file linkgraph.h.

Referenced by DeleteStaleLinks().

## ◆ operator[]()

Edge LinkGraph::Node::operator[] | ( | NodeID | to | ) |
| inline

Get an Edge.

This is not a reference as the wrapper objects are not actually persistent.

Parameters

  to | ID of end node of edge.

Returns
  Edge wrapper.

Definition at line 397 of file linkgraph.h.

## ◆ RemoveEdge()

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

Remove an outgoing edge from this node.

Parameters

  to | ID of destination node.

Definition at line 236 of file linkgraph.cpp.

References LinkGraph::BaseEdge::capacity, LinkGraph::edges, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::index, INVALID_DATE, LinkGraph::BaseEdge::last_restricted_update, LinkGraph::BaseEdge::last_unrestricted_update, LinkGraph::BaseEdge::travel_time_sum, and LinkGraph::BaseEdge::usage.

## ◆ SetDemand()

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

Set the node's demand.

Parameters

  demand | New demand for the node.

Definition at line 434 of file linkgraph.h.

References LinkGraph::BaseNode::demand, and LinkGraph::NodeWrapper< BaseNode, BaseEdge >::node.

## ◆ UpdateEdge()

void LinkGraph::Node::UpdateEdge | ( | NodeID | to,
|  | uint | capacity,
|  | uint | usage,
|  | uint32 | 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 221 of file linkgraph.cpp.

References LinkGraph::edges.

## ◆ UpdateLocation()

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

Update the node's location on the map.

Parameters

  xy | New location.

Definition at line 425 of file linkgraph.h.

References LinkGraph::NodeWrapper< BaseNode, BaseEdge >::node, and LinkGraph::BaseNode::xy.

## ◆ UpdateSupply()

void LinkGraph::Node::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 415 of file linkgraph.h.

References _date, LinkGraph::BaseNode::last_update, LinkGraph::NodeWrapper< BaseNode, BaseEdge >::node, and LinkGraph::BaseNode::supply.

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

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