OpenTTD Source 20260109-master-g241b5fcdfe
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
10#ifndef DEMANDS_H
11#define DEMANDS_H
12
13#include "linkgraphjob_base.h"
14
20public:
22
23private:
24 int32_t base_distance;
25 int32_t mod_dist;
26 int32_t accuracy;
27
28 template <class Tscaler>
29 void CalcDemand(LinkGraphJob &job, Tscaler scaler);
30};
31
36public:
37
42 void Run(LinkGraphJob &job) const override { DemandCalculator c(job); }
43
47 ~DemandHandler() override = default;
48};
49
50#endif /* DEMANDS_H */
A handler doing "something" on a link graph component.
Calculate the demands.
Definition demands.h:19
void CalcDemand(LinkGraphJob &job, Tscaler scaler)
Do the actual demand calculation, called from constructor.
Definition demands.cpp:172
int32_t base_distance
Base distance for scaling purposes.
Definition demands.h:24
int32_t mod_dist
Distance modifier, determines how much demands decrease with distance.
Definition demands.h:25
int32_t accuracy
Accuracy of the calculation.
Definition demands.h:26
Stateless, thread safe demand handler.
Definition demands.h:35
void Run(LinkGraphJob &job) const override
Call the demand calculator on the given component.
Definition demands.h:42
~DemandHandler() override=default
Virtual destructor has to be defined because of virtual Run().
Class for calculation jobs to be run on link graphs.
Some typedefs for component handlers.