(svn r28004) -Update from Eints:
[openttd.git] / src / linkgraph / demands.h
blobc3d9dc7cda79707713866e91c793a1ff0fdccb96
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 max_distance; ///< Maximum distance possible on the map.
18 int32 mod_dist; ///< Distance modifier, determines how much demands decrease with distance.
19 int32 accuracy; ///< Accuracy of the calculation.
21 template<class Tscaler>
22 void CalcDemand(LinkGraphJob &job, Tscaler scaler);
25 /**
26 * Stateless, thread safe demand hander. 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 graph Component to calculate the demands for.
35 virtual void Run(LinkGraphJob &job) const { DemandCalculator c(job); }
37 /**
38 * Virtual destructor has to be defined because of virtual Run().
40 virtual ~DemandHandler() {}
43 #endif /* DEMANDS_H */