Skip to content

Commit

Permalink
Merge pull request #2255 from Irallia/INFRA/core/move_header_algorith…
Browse files Browse the repository at this point in the history
…m_to_configuration

[INFRA] Move core/algorithm into core/configuration
  • Loading branch information
rrahn authored Dec 5, 2020
2 parents 4a02592 + 1ae6a3f commit f66fe5b
Show file tree
Hide file tree
Showing 59 changed files with 1,175 additions and 1,097 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#pragma once

#include <seqan3/alignment/configuration/detail.hpp>
#include <seqan3/core/algorithm/configuration_element_debug_mode.hpp>
#include <seqan3/core/algorithm/pipeable_config_element.hpp>
#include <seqan3/core/configuration/detail/configuration_element_debug_mode.hpp>

namespace seqan3::align_cfg::detail
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <seqan3/alignment/configuration/align_config_gap_cost_affine.hpp>
#include <seqan3/alignment/configuration/align_config_scoring_scheme.hpp>
#include <seqan3/alignment/scoring/nucleotide_scoring_scheme.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>

namespace seqan3::align_cfg
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma once

#include <seqan3/alignment/configuration/detail.hpp>
#include <seqan3/core/algorithm/configuration_element_parallel_mode.hpp>
#include <seqan3/core/configuration/detail/configuration_element_parallel_mode.hpp>

namespace seqan3::align_cfg
{
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alignment/configuration/detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#pragma once

#include <seqan3/core/algorithm/configuration_utility.hpp>
#include <seqan3/core/configuration/detail/configuration_utility.hpp>

namespace seqan3::detail
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <seqan3/alignment/matrix/trace_directions.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/alphabet/gap/gapped.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
#include <seqan3/core/range/type_traits.hpp>
#include <seqan3/range/decorator/gap_decorator.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alignment/pairwise/alignment_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <optional>

#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/debug_stream_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <seqan3/alignment/exception.hpp>
#include <seqan3/alignment/matrix/detail/coordinate_matrix.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/template_inspection.hpp>

namespace seqan3::detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <seqan3/alignment/matrix/detail/aligned_sequence_builder.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include <seqan3/alignment/matrix/detail/coordinate_matrix.hpp>
#include <seqan3/alignment/matrix/detail/matrix_coordinate.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/concept/tuple.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/template_inspection.hpp>

namespace seqan3::detail
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alignment/pairwise/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <seqan3/alignment/matrix/detail/matrix_coordinate.hpp>
#include <seqan3/alignment/matrix/trace_directions.hpp>
#include <seqan3/alignment/pairwise/detail/concept.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/bit_manipulation.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
#include <seqan3/core/simd/simd_traits.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <seqan3/alignment/matrix/matrix_concept.hpp>
#include <seqan3/alignment/pairwise/alignment_result.hpp>
#include <seqan3/alignment/pairwise/edit_distance_fwd.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/configuration/configuration.hpp>

namespace seqan3::detail
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <seqan3/alignment/matrix/alignment_optimum.hpp>
#include <seqan3/alignment/matrix/trace_directions.hpp>
#include <seqan3/alignment/pairwise/detail/alignment_algorithm_state.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/concept/core_language.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/simd/concept.hpp>
#include <seqan3/core/simd/simd_algorithm.hpp>
#include <seqan3/core/simd/simd_traits.hpp>
Expand Down
64 changes: 4 additions & 60 deletions include/seqan3/core/algorithm/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,67 +15,11 @@
/*!\defgroup algorithm Algorithm
* \ingroup core
* \brief Provides core functionality used to configure algorithms.
*
* \details
*
* In SeqAn there are many algorithms, e.g. alignment or search algorithms, that can be configured through
* many different settings and policies that alter the execution of the respective algorithm.
* These configurations can be orthogonal or might be mutually exclusive and can make interfaces very difficult to use.
* This module provides a basic system to manage the configurations of algorithms using a unified interface.
*
* ### Usage
*
* The basis of any algorithm configuration are configuration elements. These are objects that handle a specific
* setting and must satisfy the seqan3::detail::config_element_specialisation. The following snippet demonstrates a
* basic setup for such configuration elements.
*
* \include test/snippet/core/algorithm/configuration_setup.cpp
*
* Here, two classes with the name `bar` and `foo` are created. They can be normal or template classes and must
* inherit from seqan3::pipeable_config_element and contain a member with the name `value` to satisfy the respective
* concept. The separate `value` member is used for a proper encapsulation from the actual setting parameter.
* For example the alignment algorithms require a scoring scheme, but the scoring scheme itself should not be pipeable
* with other settings.
*
* In addition an enum type was defined that will be used later to allow for compatibility checks when combining
* settings in a configuration object. This enum assigns every configuration element a unique id.
* To provide compatibility checks the `seqan3::detail::compatibility_table` must be overloaded for the specific
* algorithm configuration.
*
* \include test/snippet/core/algorithm/configuration_compatibility.cpp
*
* The type for the configuration element ids is used to overload the bool table. In the example above, both
* elements can be combined with each other but not with themselves, to avoid inconsistent settings.
*
* ### Combining Configurations
*
* To enable easy creation of algorithm settings the seqan3::configuration supports a pipeable interface for the
* different configuration elements which are added through the seqan3::pipeable_config_element base class.
* The following snippet demonstrates how `bar` and `foo` can be combined.
*
* \include test/snippet/core/algorithm/configuration_combine.cpp
* ### Access the data
*
* The configuration inherits from a std::tuple and exposes a tuple like interface using the standard
* position-based and type-based `get` interfaces. The `get` interface was extended to also support
* template template types as input template parameters to query the correct element:
*
* \include test/snippet/core/algorithm/configuration_get.cpp
*
* The get interface returns a reference to the stored configuration element. In some cases, e.g. the implementor
* of the actual algorithm, one wants to have an easy access to the actual value of the setting. Since, the
* configuration must not contain all possible configuration elements the seqan3::configuration provides a
* seqan3::configuration::get_or interface. Using this interface one can call get with a specific configuration element.
* If this configuration element or a specialisation of it is already stored inside of the configuration, the respective
* element is returned. Otherwise, the passed argument will be returned as the alternative.
*
* \include test/snippet/core/algorithm/configuration_get_or.cpp
*/
#include <seqan3/core/algorithm/algorithm_result_generator_range.hpp>
#include <seqan3/core/algorithm/bound.hpp>
#include <seqan3/core/algorithm/concept.hpp>
#include <seqan3/core/algorithm/configuration_utility.hpp>
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/core/detail/pack_algorithm.hpp>
#include <seqan3/core/algorithm/pipeable_config_element.hpp>
#include <seqan3/core/configuration/all.hpp>
#if SEQAN3_VERSION_MAJOR == 3 && SEQAN3_VERSION_MINOR == 1
#pragma warning "Remove #include <seqan3/core/configuration/all.hpp> from this header."
#endif
177 changes: 6 additions & 171 deletions include/seqan3/core/algorithm/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,180 +6,15 @@
// -----------------------------------------------------------------------------------------------------

/*!\file
* \brief Provides concepts for the configuration classes.
* \brief [DEPRECATED] Provides concepts for the configuration classes.
* \author Rene Rahn <rene.rahn AT fu-berlin.de>
* \deprecated This header will be removed in 3.1.0; Please \#include <seqan3/core/configuration/detail/concept.hpp>
* instead.
*/

#pragma once

#include <seqan3/std/concepts>
#include <functional>
#include <type_traits>
#include <seqan3/core/configuration/detail/concept.hpp>

#include <meta/meta.hpp>

#include <seqan3/core/detail/template_inspection.hpp>

namespace seqan3
{
//!\cond
// Forward declarations
template <typename derived_t, typename value_t = void>
struct pipeable_config_element;
//!\endcond
}

namespace seqan3::detail
{

// ----------------------------------------------------------------------------
// compatibility_table
// ----------------------------------------------------------------------------

/*!\brief Declaration of algorithm specific compatibility table.
* \ingroup algorithm
* \tparam algorithm_id_type The type of the algorithm specific id. Algorithm configurations must maintain
* this table to allow validation checks.
*/
template <typename algorithm_id_type>
inline constexpr std::array<std::array<void *, 0>, 0> compatibility_table{};

// ----------------------------------------------------------------------------
// Concept config_element_specialisation
// ----------------------------------------------------------------------------

#if SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
/*!\brief A helper class to check if a type has a static member called `id`.
* \ingroup algorithm
*
* \details
*
* This class is needed for gcc versions older than 11. It adds a SFINAE check to test if a type
* has a static member called `id`, which is needed for the concept defintions around the
* pipeable configuration element concepts.
*/
struct config_id_accessor
{
private:
//!\brief Helper variable template to convert the configuration enum identifier to an integer.
template <typename config_t>
static constexpr int32_t as_int = static_cast<int32_t>(std::remove_cvref_t<config_t>::id);

//!\brief Helper function to check if static id member exists.
template <typename config_t>
static constexpr auto has_id_member(int) -> decltype((static_cast<void>(config_t::id), true))
{
return true;
}

//!\overload
template <typename config_t>
static constexpr bool has_id_member(...)
{
return false;
}

public:
//!\brief Type alias for the internal enumeration type that represents the id.
template <typename config_t>
using id_type = std::remove_cvref_t<decltype(config_t::id)>;

/*!\brief Checks if two configuration types are compatible.
*
* \tparam config1_t The type of the first configuration to check against the second.
* \tparam config2_t The type of the second configuration.
*
* \details
*
* Uses the seqan3::detail::compatibility_table of the corresponding configuration element domain to check
* if both configurations can be combined.
*/
template <typename config1_t, typename config2_t>
static constexpr auto is_compatible()
{
if constexpr (has_id_member<config1_t>(0) && has_id_member<config2_t>(0)) // needed for gcc <= 9
{
if constexpr (std::same_as<id_type<config1_t>, id_type<config2_t>>)
{
return std::bool_constant<compatibility_table<id_type<config1_t>>[as_int<config1_t>]
[as_int<config2_t>]>{};
}
else
{
return std::false_type{};
}
}
else
{
return std::bool_constant<compatibility_table<id_type<config1_t>>[as_int<config1_t>][as_int<config2_t>]>{};
}
}

//!\brief Variable template that evaluates to `true` if the type has a static id member, otherwise `false`.
template <typename config_t>
static constexpr bool has_id = has_id_member<config_t>(0);
};
#endif // SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT

/*!\interface seqan3::detail::config_element_specialisation <>
* \brief Concept for an algorithm configuration element.
* \ingroup algorithm
*
* \extends std::semiregular
* \implements seqan3::pipeable_config_element
*/

/*!\name Requirements for seqan3::detail::config_element_specialisation
* \relates seqan3::detail::config_element_specialisation
* \brief You can expect this member on all types that satisfy seqan3::detail::config_element_specialisation.
* \{
*/
/*!\var id
* \brief Algorithm specific static id used for internal validation checks.
*/
//!\}
//!\cond
template <typename config_t>
SEQAN3_CONCEPT config_element_specialisation = requires
{
requires std::is_base_of_v<seqan3::pipeable_config_element<config_t>, config_t>;
requires std::semiregular<config_t>;
#if SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
requires config_id_accessor::has_id<config_t>;
#else // ^^^ workaround / no workaround vvv
{ config_t::id };
#endif // SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
};
//!\endcond

/*!\interface seqan3::detail::config_element_pipeable_with <>
* \brief Concept to check if one configuration element can be combined with another configuration element.
* \ingroup algorithm
*
* \tparam config1_t The type of the first configuration element.
* \tparam config2_t The type of the second configuration element.
*
* \details
*
* This concept is fulfilled if:
* * both configurations model seqan3::detail::config_element_specialisation,
* * are defined within the same algorithm configuration domain,
* * a seqan3::detail::compatibility_table is defined for the configuration elements and
* returns `true` for both configurations.
*/
//!\cond
template <typename config1_t, typename config2_t>
SEQAN3_CONCEPT config_element_pipeable_with =
config_element_specialisation<config1_t> &&
config_element_specialisation<config2_t> &&
#if SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
std::same_as<config_id_accessor::id_type<config1_t>, config_id_accessor::id_type<config2_t>> &&
decltype(config_id_accessor::is_compatible<config1_t, config2_t>())::value;
#else // ^^^ workaround / no workaround vvv
std::same_as<std::remove_cvref_t<decltype(config1_t::id)>, std::remove_cvref_t<decltype(config2_t::id)>> &&
compatibility_table<std::remove_cvref_t<decltype(config1_t::id)>>[static_cast<int32_t>(config1_t::id)]
[static_cast<int32_t>(config2_t::id)];
#endif // SEQAN3_WORKAROUND_GCC_PIPEABLE_CONFIG_CONCEPT
//!\endcond

} // namespace seqan3::detail
SEQAN3_DEPRECATED_HEADER(
"This header is deprecated and will be removed in SeqAn-3.1.0; Please #include <seqan3/core/configuration/detail/concept.hpp> instead.")
Loading

0 comments on commit f66fe5b

Please sign in to comment.