OpenTTD Source 20261112-master-gbcbec5e63f
demands.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef DEMANDS_H
11#define DEMANDS_H
12
13#include "linkgraphjob.h"
14#include "linkgraphschedule.h"
15
21public:
23
24private:
25 int32_t base_distance;
26 int32_t mod_dist;
27 int32_t accuracy;
28
29 template <class Tscaler>
30 void CalcDemand(LinkGraphJob &job, Tscaler scaler);
31};
32
37public:
38
43 void Run(LinkGraphJob &job) const override { DemandCalculator c(job); }
44
48 ~DemandHandler() override = default;
49};
50
51#endif /* DEMANDS_H */
A handler doing "something" on a link graph component.
Calculate the demands.
Definition demands.h:20
void CalcDemand(LinkGraphJob &job, Tscaler scaler)
Do the actual demand calculation, called from constructor.
Definition demands.cpp:172
DemandCalculator(LinkGraphJob &job)
Create the DemandCalculator and immediately do the calculation.
Definition demands.cpp:269
int32_t base_distance
Base distance for scaling purposes.
Definition demands.h:25
int32_t mod_dist
Distance modifier, determines how much demands decrease with distance.
Definition demands.h:26
int32_t accuracy
Accuracy of the calculation.
Definition demands.h:27
Stateless, thread safe demand handler.
Definition demands.h:36
void Run(LinkGraphJob &job) const override
Call the demand calculator on the given component.
Definition demands.h:43
~DemandHandler() override=default
Virtual destructor has to be defined because of virtual Run().
Class for calculation jobs to be run on link graphs.
Declaration of link graph job classes used for cargo distribution.
Declaration of link graph schedule used for cargo distribution.