SeqAn3
output.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
46 
51 namespace seqan3::detail
52 {
53 
55 struct search_output_index_iterator {};
57 struct search_output_text_position {};
58 
59 } // namespace seqan3::detail
60 
61 namespace seqan3::search_cfg
62 {
63 
65 inline detail::search_output_index_iterator constexpr index_iterator;
67 inline detail::search_output_text_position constexpr text_position;
68 
69 } // namespace seqan3::search_cfg
70 
71 namespace seqan3::detail
72 {
76 template <typename output_t>
77 struct search_config_output
78 {
80  output_t value;
82 };
83 
87 template <template <typename ...> typename search_config_output_type>
88 struct search_config_output_adaptor :
89  public configuration_fn_base<search_config_output_adaptor<search_config_output_type>>
90 {
91 
97  template <typename configuration_t, typename output_t>
99  requires is_algorithm_configuration_v<remove_cvref_t<configuration_t>> &&
100  (std::Same<remove_cvref_t<output_t>, search_output_index_iterator> ||
101  std::Same<remove_cvref_t<output_t>, search_output_text_position>)
103  constexpr auto invoke(configuration_t && cfg, output_t output) const
104  {
105  static_assert(is_valid_search_configuration_v<search_cfg::id::output, remove_cvref_t<configuration_t>>,
106  SEQAN3_INVALID_CONFIG(search_cfg::id::output));
107 
108  return std::forward<configuration_t>(cfg).push_front(search_config_output<output_t>{std::move(output)});
109  }
110 };
111 
114 template <>
115 struct on_search_config<search_cfg::id::output>
116 {
118  template <config_element_concept t>
119  using invoke = typename is_type_specialisation_of<t, search_config_output>::type;
120 };
121 
124 template <typename output_t>
125 struct search_config_type_to_id<search_config_output<output_t>>
126 {
128  static constexpr search_cfg::id value = search_cfg::id::output;
129 };
130 } // namespace seqan3::detail
131 
132 namespace seqan3::search_cfg
133 {
137 inline detail::search_config_output_adaptor<seqan3::detail::search_config_output> constexpr output;
138 
139 } // namespace seqan3::search_cfg
140 
detail::search_output_text_position constexpr text_position
Configuration element to receive all hits within the lowest number of errors.
Definition: output.hpp:67
Provides functionality to access get function by enum values.
Provides seqan3::type_list and auxiliary metafunctions.
A special sub namespace for the search configurations.
detail::search_config_output_adaptor< seqan3::detail::search_config_output > constexpr output
Configuration element to determine the output type of hits.
Definition: output.hpp:137
id
Specifies an id for every configuration element.
Definition: utility.hpp:68
std::remove_cv_t< std::remove_reference_t< t > > remove_cvref_t
Return the input type with const, volatile and references removed [Type metafunction].
Definition: basic.hpp:64
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Definition: aligned_sequence_concept.hpp:288
Provides various metafunctions on generic types.
Meta-Header for components of the algorithm submodule.
detail::search_output_index_iterator constexpr index_iterator
Configuration element to receive all hits within the error bounds.
Definition: output.hpp:65