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

A CRTP-base that eases the definition of proxy types returned in place of regular alphabets. More...

#include <seqan3/alphabet/detail/alphabet_proxy.hpp>

+ Inheritance diagram for seqan3::alphabet_proxy< derived_type, alphabet_type >:

Public Member Functions

Write functions

All of these call the emulated type's write functions and then delegate to the assignment operator which invokes derived behaviour.

constexpr derived_typeassign_rank (alphabet_rank_t< alphabet_type > const r) noexcept
 Assigns a rank.
 
constexpr derived_typeassign_char (char_type const c) noexcept
 Assigns a character.
 
constexpr derived_typeassign_phred (phred_type const c) noexcept
 Assigns a Phred score.
 

Static Public Attributes

static constexpr auto alphabet_size = seqan3::alphabet_size<alphabet_type>
 The alphabet size.
 

Private Types

using base_t = std::conditional_t< std::is_class_v< alphabet_type >, alphabet_type, alphabet_base< derived_type, alphabet_size< alphabet_type >, detail::valid_template_spec_or_t< void, alphabet_char_t, alphabet_type > > >
 Type of the base class.
 
using char_type = detail::valid_template_spec_or_t< char, alphabet_char_t, alphabet_type >
 The type of the alphabet character.
 
using phred_type = detail::valid_template_spec_or_t< int8_t, alphabet_phred_t, alphabet_type >
 The type of the Phred score.
 

Private Member Functions

Constructors, destructor and assignment
constexpr alphabet_proxy () noexcept=default
 Defaulted.
 
constexpr alphabet_proxy (alphabet_proxy const &)=default
 Defaulted.
 
constexpr alphabet_proxy (alphabet_proxy &&)=default
 Defaulted.
 
constexpr alphabet_proxyoperator= (alphabet_proxy const &)=default
 Defaulted.
 
constexpr alphabet_proxyoperator= (alphabet_proxy &&)=default
 Defaulted.
 
 ~alphabet_proxy ()=default
 Defaulted.
 
constexpr alphabet_proxy (alphabet_type const a) noexcept
 Construction from the emulated type.
 
constexpr alphabet_proxy (alphabet_type const a) noexcept
 Construction from the emulated type.
 
constexpr derived_typeoperator= (alphabet_type const &c) noexcept
 Assignment from the emulated type. This function triggers the specialisation in the derived_type.
 
template<typename indirect_assignable_type >
requires weakly_assignable_from<alphabet_type, indirect_assignable_type>
constexpr derived_typeoperator= (indirect_assignable_type const &c) noexcept
 Assignment from any type that the emulated type is assignable from.
 

Private Attributes

friend base_t
 Befriend the base type.
 
friend derived_type
 Befriend the derived type so it can instantiate.
 

Comparison operators

These are only required if the emulated type allows comparison with types it is not convertible to, e.g. seqan3::alphabet_variant.

template<typename t >
static constexpr bool is_alphabet_comparable_with
 work around a gcc bug that disables short-circuiting of operator&& in an enable_if_t of a friend function
 
template<typename t >
constexpr auto operator== (derived_type const lhs, t const rhs) noexcept -> std::enable_if_t< is_alphabet_comparable_with< t >, bool >
 Allow (in-)equality comparison with types that the emulated type is comparable with.
 
template<typename t >
constexpr auto operator== (t const lhs, derived_type const rhs) noexcept -> std::enable_if_t< is_alphabet_comparable_with< t >, bool >
 Allow (in-)equality comparison with types that the emulated type is comparable with.
 
template<typename t >
constexpr auto operator!= (derived_type const lhs, t const rhs) noexcept -> std::enable_if_t< is_alphabet_comparable_with< t >, bool >
 Allow (in-)equality comparison with types that the emulated type is comparable with.
 
template<typename t >
constexpr auto operator!= (t const lhs, derived_type const rhs) noexcept -> std::enable_if_t< is_alphabet_comparable_with< t >, bool >
 Allow (in-)equality comparison with types that the emulated type is comparable with.
 

Read functions

All of these call the emulated type's read functions.

constexpr operator alphabet_type () const noexcept
 Implicit conversion to the emulated type.
 
template<typename other_t >
requires (!std::is_class_v<alphabet_type>) && std::convertible_to<alphabet_type, other_t>
constexpr operator other_t () const noexcept
 Implicit conversion to types that the emulated type is convertible to.
 
constexpr auto to_rank () const noexcept
 Returns the rank.
 
constexpr auto to_char () const noexcept
 Returns the character.
 
constexpr auto to_phred () const noexcept
 Returns the Phred score.
 
constexpr alphabet_type complement () const noexcept
 Returns the complement.
 
static constexpr bool char_is_valid (char_type const c) noexcept
 Delegate to the emulated type's validator.
 

Detailed Description

template<typename derived_type, writable_semialphabet alphabet_type>
requires std::regular<alphabet_type>
class seqan3::alphabet_proxy< derived_type, alphabet_type >

A CRTP-base that eases the definition of proxy types returned in place of regular alphabets.

Template Parameters
derived_typeThe CRTP parameter type.
alphabet_typeThe type of the alphabet that this proxy emulates; must model at least seqan3::writable_semialphabet and std::regular.

Certain containers and other data structure hold alphabet values in a non-standard way so they can convert to that alphabet when being accessed, but cannot return a reference to the held value. These data structures may instead return a proxy to the held value which still allows changing it (and updating the underlying data structure to reflect this).

This CRTP base facilitates the definition of such proxies. Most users of SeqAn will not need to understand the details.

This class ensures that the proxy itself also models seqan3::semialphabet, seqan3::alphabet, seqan3::quality_alphabet, seqan3::nucleotide_alphabet and/or seqan3::aminoacid_alphabet if the emulated type models these. This makes sure that function templates which accept the original, also accept the proxy.

Implementation notes

The derived type needs to provide an .on_update() member function that performs the changes in the underlying data structure.

See seqan3::bitpacked_sequence or seqan3::alphabet_tuple_base for examples of how this class is used.

This entity is not part of the SeqAn API. Do not rely on it in your applications. Exposition only

Member Data Documentation

◆ is_alphabet_comparable_with

template<typename derived_type , writable_semialphabet alphabet_type>
template<typename t >
constexpr bool seqan3::alphabet_proxy< derived_type, alphabet_type >::is_alphabet_comparable_with
staticconstexprprivate
Initial value:
=
!std::is_same_v<derived_type, t> && detail::weakly_equality_comparable_with<alphabet_type, t>

work around a gcc bug that disables short-circuiting of operator&& in an enable_if_t of a friend function


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