Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[filter] conditional parameter packs support #575

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/fcarouge/internal/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct std::formatter<fcarouge::kalman<Filter>, Char> {
format_context.advance_to(std::format_to(
format_context.out(), R"("k": {}, "p": {}, )", filter.k(), filter.p()));

if constexpr (fcarouge::internal::has_prediction_types<Filter>) {
if constexpr (fcarouge::has_prediction_types<Filter>) {
constexpr auto end{
fcarouge::internal::repack_s<typename Filter::prediction_types>};
constexpr decltype(end) begin{0};
Expand Down Expand Up @@ -121,7 +121,7 @@ struct std::formatter<fcarouge::kalman<Filter>, Char> {
}

//! @todo Inconsistent usage of internal?
if constexpr (fcarouge::internal::has_update_types<Filter>) {
if constexpr (fcarouge::has_update_types<Filter>) {
constexpr auto end{
fcarouge::internal::repack_s<typename Filter::update_types>};
constexpr decltype(end) begin{0};
Expand Down
25 changes: 21 additions & 4 deletions include/fcarouge/internal/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ struct conditional_output_uncertainty<Filter> {
using output_uncertainty = Filter::output_uncertainty;
};

template <typename Filter> struct conditional_prediction_types {};

template <has_prediction_types Filter>
struct conditional_prediction_types<Filter> {
//! @brief Pack of the prediction parameters.
using prediction_types = Filter::prediction_types;
};

template <typename Filter> struct conditional_state_transition {};

template <has_state_transition Filter>
Expand All @@ -186,15 +194,24 @@ struct conditional_state_transition<Filter> {
using state_transition = Filter::state_transition;
};

template <typename Filter> struct conditional_update_types {};

template <has_update_types Filter> struct conditional_update_types<Filter> {
//! @brief Pack of the update parameters.
using update_types = Filter::update_types;
};

// The only way to have a conditional member type is to inherit from a template
// specialization on the member type.
template <typename Filter>
struct conditional_member_types : public conditional_input<Filter>,
conditional_input_control<Filter>,
struct conditional_member_types : public conditional_input_control<Filter>,
conditional_input<Filter>,
conditional_output_model<Filter>,
conditional_process_uncertainty<Filter>,
conditional_output_uncertainty<Filter>,
conditional_state_transition<Filter> {};
conditional_prediction_types<Filter>,
conditional_process_uncertainty<Filter>,
conditional_state_transition<Filter>,
conditional_update_types<Filter> {};

template <typename...> struct pack {};

Expand Down
15 changes: 15 additions & 0 deletions include/fcarouge/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ concept has_process_uncertainty = internal::has_process_uncertainty<Filter>;
template <typename Filter>
concept has_output_uncertainty = internal::has_output_uncertainty<Filter>;

//! @brief Filter prediction pack support concept.
//!
//! @details The filter supports the prediction parameters related
//! functionality: `prediction_types` type member and parameters for the
//! `predict()` method.
template <typename Filter>
concept has_prediction_types = internal::has_prediction_types<Filter>;

//! @brief Filter input control support concept.
//!
//! @details The filter supports the input control related functionality:
Expand All @@ -106,6 +114,13 @@ concept has_input_control = internal::has_input_control<Filter>;
template <typename Filter>
concept has_state_transition = internal::has_state_transition<Filter>;

//! @brief Filter update pack support concept.
//!
//! @details The filter supports the update parameters related functionality:
//! `update_types` type member and parameters for the `update()` method.
template <typename Filter>
concept has_update_types = internal::has_update_types<Filter>;

//! @brief Filter output model support concept.
//!
//! @details The filter supports the output model related functionality:
Expand Down