2013-06-09 14:59:51 +02:00
|
|
|
/** @file demands.h Declaration of demand calculating link graph handler. */
|
|
|
|
|
|
|
|
#ifndef DEMANDS_H
|
|
|
|
#define DEMANDS_H
|
|
|
|
|
|
|
|
#include "linkgraphjob_base.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the demands. This class has a state, but is recreated for each
|
|
|
|
* call to of DemandHandler::Run.
|
|
|
|
*/
|
|
|
|
class DemandCalculator {
|
|
|
|
public:
|
|
|
|
DemandCalculator(LinkGraphJob &job);
|
|
|
|
|
|
|
|
private:
|
2024-04-20 14:53:42 +02:00
|
|
|
int32_t base_distance; ///< Base distance for scaling purposes.
|
|
|
|
int32_t mod_dist; ///< Distance modifier, determines how much demands decrease with distance.
|
|
|
|
int32_t accuracy; ///< Accuracy of the calculation.
|
2013-06-09 14:59:51 +02:00
|
|
|
|
|
|
|
template<class Tscaler>
|
|
|
|
void CalcDemand(LinkGraphJob &job, Tscaler scaler);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2019-09-29 22:27:32 +02:00
|
|
|
* Stateless, thread safe demand handler. Doesn't do anything but call DemandCalculator.
|
2013-06-09 14:59:51 +02:00
|
|
|
*/
|
|
|
|
class DemandHandler : public ComponentHandler {
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call the demand calculator on the given component.
|
2018-10-28 03:17:36 +01:00
|
|
|
* @param job Component to calculate the demands for.
|
2013-06-09 14:59:51 +02:00
|
|
|
*/
|
2023-04-13 08:23:18 +02:00
|
|
|
void Run(LinkGraphJob &job) const override { DemandCalculator c(job); }
|
2013-06-09 14:59:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual destructor has to be defined because of virtual Run().
|
|
|
|
*/
|
2023-05-14 23:31:03 +02:00
|
|
|
virtual ~DemandHandler() = default;
|
2013-06-09 14:59:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DEMANDS_H */
|