SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
Provides core functionality used to configure configurations. More...
Classes | |
class | seqan3::configuration< configs_t > |
Collection of elements to configure an algorithm. More... | |
struct | seqan3::pipeable_config_element |
Adds pipe interface to configuration elements. More... | |
Variables | |
template<typename config1_t , typename config2_t > | |
constexpr bool | seqan3::is_config_element_combineable_v = detail::config_element_pipeable_with<config1_t, config2_t> |
Helper variable template to test if a configuration element is combineable with another configuration element or configuration. | |
Tuple interface | |
template<template< typename... > class query_t, typename... configs_t> | |
constexpr auto & | get (configuration< configs_t... > &config) noexcept |
Returns the stored element. | |
Provides core functionality used to configure configurations.
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.
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. The following snippet demonstrates a basic setup for such configuration elements.
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.
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.
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.
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:
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.
|
related |
Returns the stored element.
query_t | A template template. |
[in] | config | The configuration to get the element for. |
Extends the position-based and type based get
interface for the configuration type, with a version that also accepts template-template types (types that are itself templates), such that the exact template definition must not be known.
The following snippet demonstrates the various versions of get that can be used.
no-throw guarantee.
Constant time.
|
inlineconstexpr |
Helper variable template to test if a configuration element is combineable with another configuration element or configuration.
config1_t | Either the type of a configuration element or a configuration. |
config2_t | Either the type of a configuration element or a configuration. |
This helper variable template checks if config1_t
fulfills the concept requirements seqan3::detail::config_element_pipeable_with config2_t
. If config2_t
is a seqan3::configuration, the check will be expanded to every configuration element contained in the configuration type. Only if config1_t
is combineable with every element stored inside of the given configuration, this helper variable template evaluates to true
, otherwise false
. If config1_t
is a seqan3::configuration the same applies in combination with the configuration element config2_t
. If both config1_t
and config2_t
are seqan3::configuration types, then the cartesian product between the configuration elements of the first configuration and the second configuration are tested.