Commit f77391f3 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

core: add for-all dynamics data-array functions

parent 272df080
Pipeline #15337 passed with stage
in 1 minute and 17 seconds
......@@ -2712,6 +2712,12 @@ enum class dynamics_type : i8
flow
};
constexpr i8
dynamics_type_size() noexcept
{
return static_cast<i8>(dynamics_type::flow) + 1;
}
struct model
{
double tl{ 0 };
......@@ -5102,7 +5108,21 @@ struct simulation
time end = time_domain<time>::infinity;
template<typename Function>
status dispatch(const dynamics_type type, Function f) noexcept
constexpr status for_all(Function f) noexcept
{
int i = 0;
constexpr int e = dynamics_type_size();
for (; i != e; ++i)
if (auto ret = dispatch(static_cast<dynamics_type>(i), f);
is_bad(ret))
return ret;
return status::success;
}
template<typename Function>
constexpr status dispatch(const dynamics_type type, Function f) noexcept
{
switch (type) {
case dynamics_type::none:
......@@ -5178,11 +5198,12 @@ struct simulation
return f(flow_models);
}
irt_bad_return(status::unknown_dynamics);
return status::unknown_dynamics;
}
template<typename Function>
status dispatch(const dynamics_type type, Function f) const noexcept
constexpr status dispatch(const dynamics_type type,
Function f) const noexcept
{
switch (type) {
case dynamics_type::none:
......@@ -5258,7 +5279,7 @@ struct simulation
return f(flow_models);
}
irt_bad_return(status::unknown_dynamics);
return status::unknown_dynamics;
}
status get_output_port_index(const model& mdl,
......@@ -5516,43 +5537,10 @@ public:
input_ports.clear();
output_ports.clear();
none_models.clear();
qss1_integrator_models.clear();
qss1_multiplier_models.clear();
qss1_cross_models.clear();
qss1_sum_2_models.clear();
qss1_sum_3_models.clear();
qss1_sum_4_models.clear();
qss1_wsum_2_models.clear();
qss1_wsum_3_models.clear();
qss1_wsum_4_models.clear();
qss2_integrator_models.clear();
qss2_multiplier_models.clear();
qss2_cross_models.clear();
qss2_sum_2_models.clear();
qss2_sum_3_models.clear();
qss2_sum_4_models.clear();
qss2_wsum_2_models.clear();
qss2_wsum_3_models.clear();
qss2_wsum_4_models.clear();
integrator_models.clear();
quantifier_models.clear();
adder_2_models.clear();
adder_3_models.clear();
adder_4_models.clear();
mult_2_models.clear();
mult_3_models.clear();
mult_4_models.clear();
counter_models.clear();
generator_models.clear();
constant_models.clear();
cross_models.clear();
time_func_models.clear();
accumulator_2_models.clear();
flow_models.clear();
for_all([]<typename DynamicsM>(DynamicsM& dyn_models) -> status {
dyn_models.clear();
return status::success;
});
observers.clear();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment