DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
integrator_decorator.hpp
1#pragma once
2
3#include "../concepts.hpp"
4#include "../abstract_integrator.hpp"
5#include <memory>
6
7namespace diffeq::core::composable {
8
21template<system_state S>
23public:
25 using state_type = typename base_type::state_type;
26 using time_type = typename base_type::time_type;
27 using system_function = typename base_type::system_function;
28
29protected:
30 std::unique_ptr<base_type> wrapped_integrator_;
31
32public:
37 explicit IntegratorDecorator(std::unique_ptr<base_type> integrator)
38 : base_type(integrator->sys_), wrapped_integrator_(std::move(integrator)) {}
39
43 virtual ~IntegratorDecorator() = default;
44
45 // Delegate core functionality by default - decorators override as needed
46 void step(state_type& state, time_type dt) override {
47 wrapped_integrator_->step(state, dt);
48 }
49
50 void integrate(state_type& state, time_type dt, time_type end_time) override {
51 wrapped_integrator_->integrate(state, dt, end_time);
52 }
53
54 time_type current_time() const override {
55 return wrapped_integrator_->current_time();
56 }
57
58 void set_time(time_type t) override {
59 wrapped_integrator_->set_time(t);
60 this->current_time_ = t;
61 }
62
63 void set_system(system_function sys) override {
64 wrapped_integrator_->set_system(std::move(sys));
65 this->sys_ = wrapped_integrator_->sys_;
66 }
67
72 base_type& wrapped() { return *wrapped_integrator_; }
73 const base_type& wrapped() const { return *wrapped_integrator_; }
74
79 bool has_wrapped_integrator() const { return wrapped_integrator_ != nullptr; }
80};
81
82} // namespace diffeq::core::composable
Base decorator interface for integrator enhancements.
IntegratorDecorator(std::unique_ptr< base_type > integrator)
Construct decorator wrapping another integrator.
virtual ~IntegratorDecorator()=default
Virtual destructor for proper cleanup.
base_type & wrapped()
Access to wrapped integrator for advanced use.
bool has_wrapped_integrator() const
Check if wrapped integrator exists.