Update: Translations from eints
[openttd-github.git] / src / linkgraph / demands.h
blob52dd5cb097b44d72895b05a50d1f13895b55d78b
1 /** @file demands.h Declaration of demand calculating link graph handler. */
3 #ifndef DEMANDS_H
4 #define DEMANDS_H
6 #include "linkgraphjob_base.h"
8 /**
9 * Calculate the demands. This class has a state, but is recreated for each
10 * call to of DemandHandler::Run.
12 class DemandCalculator {
13 public:
14 DemandCalculator(LinkGraphJob &job);
16 private:
17 int32_t base_distance; ///< Base distance for scaling purposes.
18 int32_t mod_dist; ///< Distance modifier, determines how much demands decrease with distance.
19 int32_t accuracy; ///< Accuracy of the calculation.
21 template<class Tscaler>
22 void CalcDemand(LinkGraphJob &job, Tscaler scaler);
25 /**
26 * Stateless, thread safe demand handler. Doesn't do anything but call DemandCalculator.
28 class DemandHandler : public ComponentHandler {
29 public:
31 /**
32 * Call the demand calculator on the given component.
33 * @param job Component to calculate the demands for.
35 void Run(LinkGraphJob &job) const override { DemandCalculator c(job); }
37 /**
38 * Virtual destructor has to be defined because of virtual Run().
40 virtual ~DemandHandler() = default;
43 #endif /* DEMANDS_H */