SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::configuration< configs_t > Class Template Reference

Collection of elements to configure an algorithm. More...

#include <seqan3/core/configuration/configuration.hpp>

+ Inheritance diagram for seqan3::configuration< configs_t >:

Public Member Functions

Constructor, destructor and assignment
constexpr configuration ()=default
 Defaulted.
 
constexpr configuration (configuration const &)=default
 Defaulted.
 
constexpr configuration (configuration &&)=default
 Defaulted.
 
constexpr configurationoperator= (configuration const &)=default
 Defaulted.
 
constexpr configurationoperator= (configuration &&)=default
 Defaulted.
 
 ~configuration ()=default
 Defaulted.
 
template<typename config_element_t >
requires (!std::same_as<std::remove_cvref_t<config_element_t>, configuration>) && detail::config_element<std::remove_cvref_t<config_element_t>>
constexpr configuration (config_element_t &&config_element)
 Constructs a configuration from a single configuration element.
 
Capacity
constexpr size_t size () const noexcept
 Returns the number of contained config elements.
 
- Public Member Functions inherited from std::tuple< configs_t... >
operator= (T... args)
 
swap (T... args)
 
tuple (T... args)
 

Private Types

using base_type = std::tuple< configs_t... >
 A type alias for the base class.
 

Private Member Functions

Internal constructor
template<typename... _configs_t>
constexpr configuration (std::tuple< _configs_t... > const &cfg)
 Constructs from std::tuple.
 
template<typename... _configs_t>
constexpr configuration (std::tuple< _configs_t... > &&cfg)
 Constructs from std::tuple.
 

Static Private Member Functions

template<typename this_t , typename query_t , typename alternative_t >
static constexpr decltype(auto) get_or_impl (this_t &&me, query_t const &query, alternative_t &&alternative) noexcept
 Internal implementation of the get_or interace.
 
template<typename this_t , template< typename... > typename query_template_t, typename... parameters_t, typename alternative_t >
static constexpr decltype(auto) get_or_impl (this_t &&me, query_template_t< parameters_t... > const &, alternative_t &&alternative) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Friends

template<detail::config_element... _configs_t>
class configuration
 Friend declaration for other instances of the configuration.
 

Related Symbols

(Note that these are not member symbols.)

template<typename lhs_config_t , typename rhs_config_t >
constexpr auto operator| (lhs_config_t &&lhs, rhs_config_t &&rhs)
 Combines two configurations and/or configuration elements forming a new seqan3::configuration.
 
Type deduction guides
template<detail::config_element config_t>
 configuration (config_t) -> configuration< config_t >
 Deduces the correct configuration element type from the passed seqan3::pipeable_config_element.
 
Tuple interface
template<template< typename... > class query_t, typename... configs_t>
constexpr auto & get (configuration< configs_t... > &config) noexcept
 Returns the stored element.
 

Observers

template<typename alternative_t >
constexpr decltype(auto) get_or (alternative_t &&alternative) &noexcept
 Returns the stored configuration element if present otherwise the given alternative.
 
template<typename alternative_t >
constexpr decltype(auto) get_or (alternative_t &&alternative) const &noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename alternative_t >
constexpr decltype(auto) get_or (alternative_t &&alternative) &&noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename alternative_t >
constexpr decltype(auto) get_or (alternative_t &&alternative) const &&noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename query_t >
static constexpr bool exists () noexcept
 Checks if the given type exists in the tuple.
 
template<template< typename... > typename query_t>
static constexpr bool exists () noexcept
 Checks if the given type exists in the tuple.
 

Modifiers

Note that modifications return new configurations and do not modify this.

template<typename other_configuration_t >
requires (is_config_element_combineable_v<configs_t, std::remove_cvref_t<other_configuration_t>> && ...)
constexpr auto append (other_configuration_t &&other_config) const
 Returns a new configuration by appending the given configuration to the current one.
 
template<typename query_t >
requires (exists<query_t>())
constexpr auto remove () const
 Remove a config element from the configuration.
 
template<template< typename... > typename query_t>
requires (exists<query_t>())
constexpr auto remove () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<int index>
constexpr auto remove_at () const
 Remove a config element from the configuration.
 

Detailed Description

template<detail::config_element... configs_t>
class seqan3::configuration< configs_t >

Collection of elements to configure an algorithm.

Template Parameters
configs_tTemplate parameter pack containing all configuration elements; Must model seqan3::detail::config_element

This class provides a unified interface to create and query such configurations for a specific algorithm. It extends the standard tuple interface with some useful functions to modify and query the user configurations.

Constructor & Destructor Documentation

◆ configuration()

template<detail::config_element... configs_t>
template<typename config_element_t >
requires (!std::same_as<std::remove_cvref_t<config_element_t>, configuration>) && detail::config_element<std::remove_cvref_t<config_element_t>>
constexpr seqan3::configuration< configs_t >::configuration ( config_element_t &&  config_element)
inlineconstexpr

Constructs a configuration from a single configuration element.

Template Parameters
config_element_tThe configuration element to add; must model seqan3::detail::config_element.
Parameters
[in]config_elementThe configuration element to construct the configuration from.

Member Function Documentation

◆ append()

template<detail::config_element... configs_t>
template<typename other_configuration_t >
requires (is_config_element_combineable_v<configs_t, std::remove_cvref_t<other_configuration_t>> && ...)
constexpr auto seqan3::configuration< configs_t >::append ( other_configuration_t &&  other_config) const
inlineconstexpr

Returns a new configuration by appending the given configuration to the current one.

Template Parameters
other_configuration_tAnother configuration type or configuration element type; each configuration element must model seqan3::detail::config_element_pipeable_with each of the configurations elements of the current configuration.
Parameters
[in]other_configThe other configuration to append to the current one.
Returns
A new configuration containing the appended configuration elements.

This function generates a new configuration object containing the appended configuration elements. The current configuration will not be modified.

◆ get_or()

template<detail::config_element... configs_t>
template<typename alternative_t >
constexpr decltype(auto) seqan3::configuration< configs_t >::get_or ( alternative_t &&  alternative) &
inlineconstexprnoexcept

Returns the stored configuration element if present otherwise the given alternative.

Template Parameters
alternative_tThe type of the configuration element that is queried.
Parameters
[in]alternativeThe alternative whose type is used to check for an existing configuration element.

Uses the type alternative_t of the given alternative to check if such an configuration element was already stored inside of the configuration. If no suitable candidate can be found the passed value alternative will be returned. If alternative_t is a class template, then any specialisation of this alternative type will be searched and returned if present.

Returns
The stored configuration element identified by alternative_t or the alternative if not present.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
// Initial setup used in the actual example:
enum struct my_id : int
{
bar_id,
foo_id
};
struct bar : private seqan3::pipeable_config_element
{
public:
float value{};
bar() = default;
bar(bar const &) = default;
bar(bar &&) = default;
bar & operator=(bar const &) = default;
bar & operator=(bar &&) = default;
~bar() = default;
bar(float v) : value{v}
{}
static constexpr my_id id{my_id::bar_id};
};
template <typename t>
{
public:
t value{};
foo() = default;
foo(foo const &) = default;
foo(foo &&) = default;
foo & operator=(foo const &) = default;
foo & operator=(foo &&) = default;
~foo() = default;
foo(t v) : value{std::move(v)}
{}
static constexpr my_id id{my_id::foo_id};
};
template <typename t>
foo(t) -> foo<t>;
int main()
{
seqan3::configuration my_cfg{foo{1}}; // Only foo<int> is present.
seqan3::debug_stream << my_cfg.get_or(foo{std::string{"hello"}}).value << '\n'; // finds foo<int> -> prints: 1
seqan3::debug_stream << my_cfg.get_or(bar{2.4}).value << '\n'; // bar not present -> prints: 2.4
}
Collection of elements to configure an algorithm.
Definition configuration.hpp:42
Provides seqan3::configuration and utility functions.
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
T move(T... args)
SeqAn specific customisations in the standard namespace.
Provides seqan3::pipeable_config_element.
Adds pipe interface to configuration elements.
Definition pipeable_config_element.hpp:29

Exception

no-throw guarantee.

Complexity

Constant time.

◆ get_or_impl()

template<detail::config_element... configs_t>
template<typename this_t , typename query_t , typename alternative_t >
static constexpr decltype(auto) seqan3::configuration< configs_t >::get_or_impl ( this_t &&  me,
query_t const &  query,
alternative_t &&  alternative 
)
inlinestaticconstexprprivatenoexcept

Internal implementation of the get_or interace.

Template Parameters
this_tThe type of this.
query_tThe type of the configuration element to query.
alternative_tThe type of the alternative.
Parameters
[in]meThe perfectly forwarded instance of *this.
[in]queryThe queried configuration element [only the type is needed].
[in]alternativeThe alternative configuration element to return if the query_t is not present.

Use the type query_t to check if such a configuration element is stored in me. If this is true then the stored configuration element is returned using perfect forwarding. If this evaluates to false the given alternative is returned. If query_t is a class template then it is checked if any specialisation of this class template is stored.

◆ remove()

template<detail::config_element... configs_t>
template<typename query_t >
requires (exists<query_t>())
constexpr auto seqan3::configuration< configs_t >::remove ( ) const
inlineconstexpr

Remove a config element from the configuration.

Template Parameters
query_tThe config element type to remove from the configuration.
Returns
A new configuration object without the config element identified by query_t.

◆ remove_at()

template<detail::config_element... configs_t>
template<int index>
constexpr auto seqan3::configuration< configs_t >::remove_at ( ) const
inlineconstexprprivate

Remove a config element from the configuration.

Template Parameters
indexThe config element at index is removed from the config.
Returns
A new configuration object without the config element at index.

Friends And Related Symbol Documentation

◆ operator|()

template<typename lhs_config_t , typename rhs_config_t >
constexpr auto operator| ( lhs_config_t &&  lhs,
rhs_config_t &&  rhs 
)
related

Combines two configurations and/or configuration elements forming a new seqan3::configuration.

Template Parameters
lhs_config_tThe type of the left hand side operand; the seqan3::is_config_element_combineable_v variable template must evaluate to true for both operand types.
rhs_config_tThe type of the right hand side operand; the seqan3::is_config_element_combineable_v variable template must evaluate to true for both operand types.
Parameters
[in]lhsThe left hand operand.
[in]rhsThe right hand operand.
Returns
A new seqan3::configuration containing lhs and rhs.

The two operands can be either a seqan3::configuration object or a seqan3::detail::config_element. The right hand side operand is then appended to the left hand side operand by creating a new seqan3::configuration object. Neither lhs nor rhs will be modified.


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