BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
bio::alphabet::proxy_base< 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 <bio/alphabet/proxy_base.hpp>

+ Inheritance diagram for bio::alphabet::proxy_base< 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_type & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters.
 
constexpr derived_type const & assign_char (char_type const c) const noexcept
 Assign from a character, implicitly converts invalid characters.
 
constexpr derived_type & assign_phred (phred_type const c) noexcept
 Assign from the numeric phred value.
 
constexpr derived_type const & assign_phred (phred_type const c) const noexcept
 Assign from the numeric phred value.
 

Static Public Attributes

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

Friends

constexpr void swap (derived_type &lhs, derived_type &rhs)
 Checks order of lhs and rhs.
 
constexpr void swap (derived_type const &lhs, derived_type const &rhs)
 Checks order of lhs and rhs.
 
constexpr derived_type & tag_invoke (custom::assign_char_to, char_type const c, derived_type &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr derived_type const & tag_invoke (custom::assign_char_to, char_type const c, derived_type const &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr derived_type & tag_invoke (custom::assign_phred_to, phred_type const p, derived_type &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr derived_type const & tag_invoke (custom::assign_phred_to, phred_type const p, derived_type const &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr derived_type & tag_invoke (custom::assign_rank_to, auto const r, derived_type &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr derived_type const & tag_invoke (custom::assign_rank_to, auto const r, derived_type const &a) noexcept
 tag_invoke() wrapper around member.
 
constexpr bool tag_invoke (custom::char_is_valid_for, char_type const c, derived_type) noexcept
 tag_invoke() wrapper around member.
 
constexpr bool tag_invoke (custom::char_is_valid_for, char_type const c, std::type_identity< derived_type >) noexcept
 tag_invoke() wrapper around member.
 
constexpr auto tag_invoke (custom::complement, derived_type const a) noexcept
 tag_invoke() wrapper around member.
 
consteval auto tag_invoke (custom::size, derived_type) noexcept
 tag_invoke() wrapper around member.
 
consteval auto tag_invoke (custom::size, std::type_identity< derived_type >) noexcept
 tag_invoke() wrapper around member.
 
constexpr auto tag_invoke (custom::to_char, derived_type const a) noexcept
 tag_invoke() wrapper around member.
 
constexpr phred_type tag_invoke (custom::to_phred, derived_type const a) noexcept
 tag_invoke() wrapper around member.
 
constexpr auto tag_invoke (custom::to_rank, derived_type const a) noexcept
 tag_invoke() wrapper around member.
 
Comparison operators

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

constexpr bool operator== (derived_type const lhs, derived_type const rhs)
 Checks whether the letters lhs and rhs are equal.
 
constexpr auto operator<=> (derived_type const lhs, derived_type const rhs)
 Checks order of lhs and rhs.
 
template<meta::different_from< derived_type > t>
requires (meta::weakly_equality_comparable_with<alphabet_type, t>)
constexpr bool operator== (derived_type const lhs, t const rhs) noexcept
 Allow (in-)equality comparison with types that the emulated type is comparable with.
 
template<meta::different_from< derived_type > t>
requires (meta::weakly_equality_comparable_with<alphabet_type, t>)
constexpr bool operator== (t const lhs, derived_type const rhs) noexcept
 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::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_char () const noexcept
 Return the letter as a character of char_type.
 
constexpr auto to_phred () const noexcept
 Return the alphabet's value in phred representation.
 
constexpr alphabet_type complement () const noexcept
 Return the complement of the letter.
 
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 bio::alphabet::proxy_base< 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 bio::alphabet::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 BioC++ will not need to understand the details.

This class ensures that the proxy itself also models bio::alphabet::semialphabet, bio::alphabet::alphabet, bio::alphabet::quality, bio::alphabet::nucleotide and/or bio::alphabet::aminoacid 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 a .to_rank() member and an .assign_rank() member with the actual implementations. Additionally, there needs to be a const qualified overload for .assign_rank().

Most derived_types will also want to specify the default assignment operator to implement "assign-through" and to also provide a const-qualified overload of the same.

See bio::ranges::bitcompressed_vector or bio::alphabet::tuple_base for examples of how this class is used.

Member Function Documentation

◆ assign_char() [1/2]

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr derived_type const & bio::alphabet::proxy_base< derived_type, alphabet_type >::assign_char ( char_type const  c) const
inlineconstexprnoexcept

Assign from a character, implicitly converts invalid characters.

Parameters
cThe character to be assigned.

Provides an implementation for bio::alphabet::assign_char_to, required to model bio::alphabet::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_char() [2/2]

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr derived_type & bio::alphabet::proxy_base< derived_type, alphabet_type >::assign_char ( char_type const  c)
inlineconstexprnoexcept

Assign from a character, implicitly converts invalid characters.

Parameters
cThe character to be assigned.

Provides an implementation for bio::alphabet::assign_char_to, required to model bio::alphabet::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_phred() [1/2]

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr derived_type const & bio::alphabet::proxy_base< derived_type, alphabet_type >::assign_phred ( phred_type const  c) const
inlineconstexprnoexcept

Assign from the numeric phred value.

Satisfies the bio::alphabet::writable_quality::assign_phred() requirement via the bio::alphabet::assign_rank() wrapper.

Complexity

Constant.

◆ assign_phred() [2/2]

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr derived_type & bio::alphabet::proxy_base< derived_type, alphabet_type >::assign_phred ( phred_type const  c)
inlineconstexprnoexcept

Assign from the numeric phred value.

Satisfies the bio::alphabet::writable_quality::assign_phred() requirement via the bio::alphabet::assign_rank() wrapper.

Complexity

Constant.

◆ complement()

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr alphabet_type bio::alphabet::proxy_base< derived_type, alphabet_type >::complement ( ) const
inlineconstexprnoexcept

Return the complement of the letter.

See Nucleotide for the actual values.

Provides an implementation for bio::alphabet::complement, required to model bio::alphabet::nucleotide.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ to_char()

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr auto bio::alphabet::proxy_base< derived_type, alphabet_type >::to_char ( ) const
inlineconstexprnoexcept

Return the letter as a character of char_type.

Provides an implementation for bio::alphabet::to_char, required to model bio::alphabet::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ to_phred()

template<typename derived_type , writable_semialphabet alphabet_type>
constexpr auto bio::alphabet::proxy_base< derived_type, alphabet_type >::to_phred ( ) const
inlineconstexprnoexcept

Return the alphabet's value in phred representation.


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