Data Structures | Public Member Functions | Protected Attributes | Private Types | Friends

# LinkGraphJob Class Reference

Class for calculation jobs to be run on link graphs. More...

`#include <linkgraphjob.h>`

Inheritance diagram for LinkGraphJob:

## Data Structures
class | Edge
| A job edge. More...
struct | EdgeAnnotation
| Annotation for a link graph edge. More...
class | EdgeIterator
| Iterator for job edges. More...
class | Node
| Link graph job node. More...
struct | NodeAnnotation
| Annotation for a link graph node. More...
## Public Member Functions
| LinkGraphJob ()
| Bare constructor, only for save/load.
| LinkGraphJob (const LinkGraph &orig)
| Create a link graph job from a link graph.
| ~LinkGraphJob ()
| Join the link graph job and destroy it.
void | Init ()
| Initialize the link graph job: Resize nodes and edges and populate them.
bool | IsFinished () const
| Check if job is supposed to be finished.
Date | JoinDate () const
| Get the date when the job should be finished.
const LinkGraphSettings & | Settings () const
| Get the link graph settings for this component.
Node | operator[] (NodeID num)
| Get a node abstraction with the specified id.
uint | Size () const
| Get the size of the underlying link graph.
CargoID | Cargo () const
| Get the cargo of the underlying link graph.
Date | LastCompression () const
| Get the date when the underlying link graph was last compressed.
LinkGraphID | LinkGraphIndex () const
| Get the ID of the underlying link graph.
const LinkGraph & | Graph () const
| Get a reference to the underlying link graph.
## Protected Attributes
const LinkGraph | link_graph
| Link graph to by analyzed. Is copied when job is started and mustn't be modified later.
const LinkGraphSettings | settings
| Copy of _settings_game.linkgraph at spawn time.
ThreadObject * | thread
| Thread the job is running in or NULL if it's running in the main thread.
const Date | join_date
| Date when the job is to be joined.
NodeAnnotationVector | nodes
| Extra node data necessary for link graph calculation.
EdgeAnnotationMatrix | edges
| Extra edge data necessary for link graph calculation.
## Private Types
typedef SmallVector < NodeAnnotation, 16 > | NodeAnnotationVector
typedef SmallMatrix < EdgeAnnotation > | EdgeAnnotationMatrix
## Friends
class | LinkGraphSchedule
const SaveLoad * | GetLinkGraphJobDesc ()
| Get a SaveLoad array for a link graph job.

## Detailed Description

Class for calculation jobs to be run on link graphs.

Definition at line 31 of file linkgraphjob.h.

## Constructor & Destructor Documentation

LinkGraphJob::LinkGraphJob | ( |  | ) | `[inline]`

Bare constructor, only for save/load.

link_graph, join_date and actually settings have to be brutally const-casted in order to populate them.

Definition at line 264 of file linkgraphjob.h.

LinkGraphJob::LinkGraphJob | ( | const LinkGraph & | orig | ) |

Create a link graph job from a link graph.

The link graph will be copied so that the calculations don't interfer with the normal operations on the original. The job is immediately started.

Parameters:

  | orig | Original LinkGraph to be copied.

Definition at line 27 of file linkgraphjob.cpp.

## Member Function Documentation

CargoID LinkGraphJob::Cargo | ( |  | ) | const`[inline]`

Get the cargo of the underlying link graph.

Returns:
  Cargo.

Definition at line 307 of file linkgraphjob.h.

References LinkGraph::Cargo(), and link_graph.

Referenced by DemandCalculator::DemandCalculator(), and ~LinkGraphJob().

const LinkGraph& LinkGraphJob::Graph | ( |  | ) | const`[inline]`

Get a reference to the underlying link graph.

Only use this for save/load.

Returns:
  Link graph.

Definition at line 325 of file linkgraphjob.h.

References link_graph.

Referenced by DoSave_LGRJ(), and Load_LGRJ().

void LinkGraphJob::Init | ( |  | ) |

Initialize the link graph job: Resize nodes and edges and populate them.

This is done after the constructor so that we can do it in the calculation thread without delaying the main game.

Definition at line 80 of file linkgraphjob.cpp.

References edges, LinkGraphJob::EdgeAnnotation::Init(), link_graph, nodes, SmallMatrix< T >::Resize(), SmallVector< T, S >::Resize(), and Size().

Referenced by InitHandler::Run().

bool LinkGraphJob::IsFinished | ( |  | ) | const`[inline]`

Check if job is supposed to be finished.

Returns:
  True if job should be finished by now, false if not.

Definition at line 276 of file linkgraphjob.h.

References _date, and join_date.

Referenced by LinkGraphSchedule::JoinNext().

Date LinkGraphJob::JoinDate | ( |  | ) | const`[inline]`

Get the date when the job should be finished.

Returns:
  Join date.

Definition at line 282 of file linkgraphjob.h.

References join_date.

Referenced by FlowMapper::Run().

Date LinkGraphJob::LastCompression | ( |  | ) | const`[inline]`

Get the date when the underlying link graph was last compressed.

Returns:
  Compression date.

Definition at line 313 of file linkgraphjob.h.

References LinkGraph::LastCompression(), and link_graph.

Referenced by FlowMapper::Run().

LinkGraphID LinkGraphJob::LinkGraphIndex | ( |  | ) | const`[inline]`

Get the ID of the underlying link graph.

Returns:
  Link graph ID.

Definition at line 319 of file linkgraphjob.h.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, and link_graph.

Referenced by LinkGraphSchedule::JoinNext().

Node LinkGraphJob::operator[] | ( | NodeID | num | ) | `[inline]`

Get a node abstraction with the specified id.

Parameters:

  | num | ID of the node.

Returns:
  the Requested node.

Definition at line 295 of file linkgraphjob.h.

const LinkGraphSettings& LinkGraphJob::Settings | ( |  | ) | const`[inline]`

Get the link graph settings for this component.

Returns:
  Settings.

Definition at line 288 of file linkgraphjob.h.

References settings.

Referenced by DemandCalculator::DemandCalculator(), MCF1stPass::MCF1stPass(), MCF2ndPass::MCF2ndPass(), and FlowMapper::Run().

uint LinkGraphJob::Size | ( |  | ) | const`[inline]`

Get the size of the underlying link graph.

Returns:
  Size.

Definition at line 301 of file linkgraphjob.h.

References link_graph, and LinkGraph::Size().

Referenced by DemandCalculator::CalcDemand(), MultiCommodityFlow::Dijkstra(), DoSave_LGRJ(), MCF1stPass::EliminateCycles(), FlowEdgeIterator::FlowEdgeIterator(), Init(), MCF1stPass::MCF1stPass(), MCF2ndPass::MCF2ndPass(), FlowMapper::Run(), and ~LinkGraphJob().

## Friends And Related Function Documentation

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

Get a SaveLoad array for a link graph job.

The settings struct is derived from the global settings saveload array. The exact entries are calculated when the function is called the first time. It's necessary to keep a copy of the settings for each link graph job so that you can change the settings while in-game and still not mess with current link graph runs. Of course the settings have to be saved and loaded, too, to avoid desyncs.

Returns:
  Array of SaveLoad structs.

Definition at line 50 of file linkgraph_sl.cpp.

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

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