A toolkit for working with phylogenetic data.
v0.24.0
fastq_output_iterator.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_FORMATS_FASTQ_OUTPUT_ITERATOR_H_
2 #define GENESIS_SEQUENCE_FORMATS_FASTQ_OUTPUT_ITERATOR_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2020 Lucas Czech
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
36 
38 
39 #include <iterator>
40 #include <iostream>
41 
42 namespace genesis {
43 namespace sequence {
44 
45 // =================================================================================================
46 // Fastq Output Iterator
47 // =================================================================================================
48 
67 {
68 public:
69 
70  // -------------------------------------------------------------------------
71  // Member Types
72  // -------------------------------------------------------------------------
73 
75 
76  // -------------------------------------------------------------------------
77  // Constructors and Rule of Five
78  // -------------------------------------------------------------------------
79 
80  FastqOutputIterator() = delete;
81 
82  explicit FastqOutputIterator( std::shared_ptr<utils::BaseOutputTarget> target )
83  : target_( target )
84  , writer_()
85  {}
86 
87  FastqOutputIterator( std::shared_ptr<utils::BaseOutputTarget> target, FastqWriter const& writer )
88  : target_( target )
89  , writer_( writer )
90  {}
91 
92  ~FastqOutputIterator() = default;
93 
94  FastqOutputIterator( self_type const& ) = default;
95  FastqOutputIterator( self_type&& ) = default;
96 
97  self_type& operator= ( self_type const& ) = default;
98  self_type& operator= ( self_type&& ) = default;
99 
100  // -------------------------------------------------------------------------
101  // Accessors
102  // -------------------------------------------------------------------------
103 
105  {
106  writer_.write( seq, target_ );
107  return *this;
108  }
109 
117  {
118  return writer_;
119  }
120 
121  // -------------------------------------------------------------------------
122  // Data Members
123  // -------------------------------------------------------------------------
124 
125 private:
126 
127  std::shared_ptr<utils::BaseOutputTarget> target_;
128  FastqWriter writer_;
129 };
130 
131 } // namespace sequence
132 } // namespace genesis
133 
134 #endif // include guard
self_type & operator=(self_type const &)=default
FastqOutputIterator(std::shared_ptr< utils::BaseOutputTarget > target, FastqWriter const &writer)
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
self_type & operator<<(Sequence const &seq)
void write(Sequence const &sequence, std::shared_ptr< utils::BaseOutputTarget > target) const
Write a single Sequence to an output target, using the Fastq format.
FastqOutputIterator(std::shared_ptr< utils::BaseOutputTarget > target)
Write Fastq data, sequentially.
FastqWriter & writer()
Return the FastqWriter used for this iterator.