OpenTTD Source: src/linkgraph/demands.h Source File

OpenTTD Source 15.3

demands.h
Go to the documentation of this file.
1
3#ifndef DEMANDS_H
4#define DEMANDS_H
5
6#include "linkgraphjob_base.h"
7
12 class DemandCalculator {
13public:
14 DemandCalculator(LinkGraphJob &job);
15
16private:
17 int32_t base_distance;
18 int32_t mod_dist;
19 int32_t accuracy;
20
21 template <class Tscaler>
22 void CalcDemand(LinkGraphJob &job, Tscaler scaler);
23};
24
28 class DemandHandler : public ComponentHandler {
29public:
30
35 void Run(LinkGraphJob &job) const override { DemandCalculator c(job); }
36
40 virtual ~DemandHandler() = default;
41};
42
43#endif /* DEMANDS_H */
ComponentHandler
A handler doing "something" on a link graph component.
Definition linkgraphschedule.h:21
DemandCalculator
Calculate the demands.
Definition demands.h:12
DemandCalculator::CalcDemand
void CalcDemand(LinkGraphJob &job, Tscaler scaler)
Do the actual demand calculation, called from constructor.
Definition demands.cpp:165
DemandCalculator::base_distance
int32_t base_distance
Base distance for scaling purposes.
Definition demands.h:17
DemandCalculator::mod_dist
int32_t mod_dist
Distance modifier, determines how much demands decrease with distance.
Definition demands.h:18
DemandCalculator::accuracy
int32_t accuracy
Accuracy of the calculation.
Definition demands.h:19
DemandHandler
Stateless, thread safe demand handler.
Definition demands.h:28
DemandHandler::~DemandHandler
virtual ~DemandHandler()=default
Virtual destructor has to be defined because of virtual Run().
DemandHandler::Run
void Run(LinkGraphJob &job) const override
Call the demand calculator on the given component.
Definition demands.h:35
LinkGraphJob
Class for calculation jobs to be run on link graphs.
Definition linkgraphjob.h:29
linkgraphjob_base.h
Some typedefs for component handlers.