Grail (C++)  1.1.1
A multi-platform, modular, universal engine for embedding advanced AI in games.
ConstantFunction.hh
1 #ifndef GRAIL_CONSTANT_FUNCTION_H
2 #define GRAIL_CONSTANT_FUNCTION_H
3 
4 #include "Curve.hh"
5 
6 namespace grail
7 {
8  namespace curves
9  {
10  template <typename ContextType>
15  class ConstantFunction final : public Curve<ContextType>
16  {
17  public:
23  ConstantFunction(std::shared_ptr<utility::Evaluator<ContextType>> childEvaluator, float constant)
24  : Curve<ContextType>{childEvaluator}, constant{constant}
25  {
26  }
27 
28  virtual float Sample(float) const override final
29  {
30  return constant;
31  }
32 
37  float GetConstant() const { return constant; }
38  virtual EvaluatorType GetEvaluatorType() const override final { return EvaluatorType::CURVE_CONSTANT; }
39 
40  private:
41  float constant = 0.0f;
42  };
43  }
44 }
45 #endif // GRAIL_CONSTANT_FUNCTION_H
grail::curves::ConstantFunction::Sample
virtual float Sample(float) const override final
Sample - Transforms argument into output value depending on the type of Curve.
Definition: ConstantFunction.hh:28
grail::curves::Curve
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:19
grail::curves::ConstantFunction::ConstantFunction
ConstantFunction(std::shared_ptr< utility::Evaluator< ContextType >> childEvaluator, float constant)
ConstantFunction - Constructor.
Definition: ConstantFunction.hh:23
grail::curves::ConstantFunction::GetConstant
float GetConstant() const
GetConstant.
Definition: ConstantFunction.hh:37
grail::utility::Evaluator
The Evaluator class - base class being able to evaluate given context and output the result.
Definition: Evaluator.hh:20
grail::curves::ConstantFunction
The ConstantFunction class - Constant function.
Definition: ConstantFunction.hh:15