wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wFunctionComponent.hpp
Go to the documentation of this file.
1/*
2+---------------------------------------------------------------------------------------------------------------------------------------------------+
3Created by Wilfried Koch.
4Copyright @ 2025 Wilfried Koch. All rights reserved.
5+---------------------------------------------------------------------------------------------------------------------------------------------------+
6*/
7
8#ifndef W_FUNCTION_COMPONENT_HPP
9#define W_FUNCTION_COMPONENT_HPP
10
11#include <functional>
12#include <stdexcept>
13
15
16namespace wEngine
17{
18
32 {
33 public:
39 FunctionComponent( std::function< double( double ) > function );
40
41 /*
42 * @brief Virtual destructor.
43 */
44 virtual ~FunctionComponent( ) = default;
45
52 [[nodiscard]] double calculate( double x ) const;
53
54 /*
55 * @brief Prints a message confirming that the function is set.
56 */
57 void debugPrint( ) const;
58 private:
59 std::function< double( double ) > mFunction;
60 };
61
62}//End of namespace wEngine
63
64#endif
Component()
Protected constructor to restrict instantiation to derived classes.
Definition wComponent.cpp:17
void debugPrint() const
Definition wFunctionComponent.cpp:48
FunctionComponent(std::function< double(double) > function)
Constructs a FunctionComponent with a given function.
Definition wFunctionComponent.cpp:17
virtual ~FunctionComponent()=default
double calculate(double x) const
Evaluates the stored function at a given x.
Definition wFunctionComponent.cpp:32
Definition wColorComponent.cpp:9