DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
diffeq::core::composable::IntegratorBuilder< S > Class Template Reference

Builder for composing multiple facilities. More...

#include <integrator_builder.hpp>

Public Member Functions

 IntegratorBuilder (std::unique_ptr< AbstractIntegrator< S > > integrator)
 Construct builder with base integrator.
 
IntegratorBuilderwith_timeout (TimeoutConfig config={})
 Add timeout protection facility.
 
IntegratorBuilderwith_parallel (ParallelConfig config={})
 Add parallel execution facility.
 
IntegratorBuilderwith_output (OutputConfig config={}, std::function< void(const S &, typename AbstractIntegrator< S >::time_type, size_t)> handler=nullptr)
 Add output handling facility.
 
IntegratorBuilderwith_signals (SignalConfig config={})
 Add signal processing facility.
 
IntegratorBuilderwith_interpolation (InterpolationConfig config={})
 Add interpolation facility.
 
IntegratorBuilderwith_interprocess (InterprocessConfig config={})
 Add interprocess facility.
 
std::unique_ptr< AbstractIntegrator< S > > build ()
 Build the final composed integrator.
 
template<typename DecoratorType >
DecoratorType * get_as ()
 Get specific decorator type from the composition chain.
 
bool is_valid () const
 Check if the builder has a valid integrator.
 
std::string get_composition_info () const
 Get information about the current composition.
 

Detailed Description

template<system_state S>
class diffeq::core::composable::IntegratorBuilder< S >

Builder for composing multiple facilities.

This allows flexible combination of any facilities without exponential class combinations. Uses the decorator pattern to stack facilities in any order.

Key Design Principles:

  • Fluent Interface: Chainable method calls
  • Order Independence: Facilities work in any composition order
  • Type Safety: Compile-time type checking
  • Extensibility: Easy to add new facilities without modification

Example Usage:

auto integrator = make_builder(base_integrator)
.with_timeout(TimeoutConfig{.timeout_duration = std::chrono::seconds{30}})
.with_parallel(ParallelConfig{.max_threads = 8})
.with_output(OutputConfig{.mode = OutputMode::HYBRID})
.build();
IntegratorBuilder & with_parallel(ParallelConfig config={})
Add parallel execution facility.
IntegratorBuilder & with_output(OutputConfig config={}, std::function< void(const S &, typename AbstractIntegrator< S >::time_type, size_t)> handler=nullptr)
Add output handling facility.
std::unique_ptr< AbstractIntegrator< S > > build()
Build the final composed integrator.
IntegratorBuilder & with_signals(SignalConfig config={})
Add signal processing facility.
Configuration for output handling.
Configuration for parallel execution.
Timeout configuration for integration protection.

Definition at line 39 of file integrator_builder.hpp.

Constructor & Destructor Documentation

◆ IntegratorBuilder()

template<system_state S>
diffeq::core::composable::IntegratorBuilder< S >::IntegratorBuilder ( std::unique_ptr< AbstractIntegrator< S > >  integrator)
inlineexplicit

Construct builder with base integrator.

Parameters
integratorThe integrator to build upon (takes ownership)

Definition at line 48 of file integrator_builder.hpp.

Member Function Documentation

◆ build()

template<system_state S>
std::unique_ptr< AbstractIntegrator< S > > diffeq::core::composable::IntegratorBuilder< S >::build ( )
inline

Build the final composed integrator.

Returns
Unique pointer to the composed integrator

Note: After calling build(), the builder is left in a valid but unspecified state. Do not use the builder after calling build().

Definition at line 146 of file integrator_builder.hpp.

◆ get_as()

template<system_state S>
template<typename DecoratorType >
DecoratorType * diffeq::core::composable::IntegratorBuilder< S >::get_as ( )
inline

Get specific decorator type from the composition chain.

Template Parameters
DecoratorTypeThe specific decorator type to retrieve
Returns
Pointer to the decorator, or nullptr if not found

Note: This performs a dynamic_cast and may be expensive. Use sparingly.

Example:

auto builder = make_builder(base).with_timeout().with_async();
auto* timeout_decorator = builder.get_as<TimeoutDecorator<S, T>>();
if (timeout_decorator) {
// Access timeout-specific functionality
timeout_decorator->config().timeout_duration = std::chrono::seconds{60};
}
Timeout decorator - adds timeout protection to any integrator.
TimeoutConfig & config()
Access and modify timeout configuration.

Definition at line 171 of file integrator_builder.hpp.

◆ get_composition_info()

template<system_state S>
std::string diffeq::core::composable::IntegratorBuilder< S >::get_composition_info ( ) const
inline

Get information about the current composition.

Returns
String describing the current decorator stack

Definition at line 187 of file integrator_builder.hpp.

◆ is_valid()

template<system_state S>
bool diffeq::core::composable::IntegratorBuilder< S >::is_valid ( ) const
inline

Check if the builder has a valid integrator.

Returns
true if the builder can still be used

Definition at line 179 of file integrator_builder.hpp.

◆ with_interpolation()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_interpolation ( InterpolationConfig  config = {})
inline

Add interpolation facility.

Parameters
configInterpolation configuration (uses defaults if not specified)
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 112 of file integrator_builder.hpp.

◆ with_interprocess()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_interprocess ( InterprocessConfig  config = {})
inline

Add interprocess facility.

Parameters
configInterprocess configuration (uses defaults if not specified)
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 124 of file integrator_builder.hpp.

◆ with_output()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_output ( OutputConfig  config = {},
std::function< void(const S &, typename AbstractIntegrator< S >::time_type, size_t)>  handler = nullptr 
)
inline

Add output handling facility.

Parameters
configOutput configuration (uses defaults if not specified)
handlerOptional output handler function
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 87 of file integrator_builder.hpp.

◆ with_parallel()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_parallel ( ParallelConfig  config = {})
inline

Add parallel execution facility.

Parameters
configParallel configuration (uses defaults if not specified)
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 74 of file integrator_builder.hpp.

◆ with_signals()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_signals ( SignalConfig  config = {})
inline

Add signal processing facility.

Parameters
configSignal configuration (uses defaults if not specified)
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 100 of file integrator_builder.hpp.

◆ with_timeout()

template<system_state S>
IntegratorBuilder & diffeq::core::composable::IntegratorBuilder< S >::with_timeout ( TimeoutConfig  config = {})
inline

Add timeout protection facility.

Parameters
configTimeout configuration (uses defaults if not specified)
Returns
Reference to this builder for chaining
Exceptions
std::invalid_argumentif config is invalid

Definition at line 62 of file integrator_builder.hpp.


The documentation for this class was generated from the following file: