1 | #ifndef theplu_yat_omic_bam_write_iterator |
---|
2 | #define theplu_yat_omic_bam_write_iterator |
---|
3 | |
---|
4 | // $Id: BamWriteIterator.h 2910 2012-12-17 02:31:13Z peter $ |
---|
5 | // |
---|
6 | // Copyright (C) 2012 Peter Johansson |
---|
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, but |
---|
14 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | // 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 | #include <boost/function_output_iterator.hpp> |
---|
22 | |
---|
23 | #include <functional> |
---|
24 | |
---|
25 | namespace theplu { |
---|
26 | namespace yat { |
---|
27 | namespace omic { |
---|
28 | |
---|
29 | class BamRead; |
---|
30 | class OutBamFile; |
---|
31 | |
---|
32 | /** |
---|
33 | Functor taking a BamRead and writing to an OutBamFile. Class is |
---|
34 | primarily used by BamWriteIterator. |
---|
35 | |
---|
36 | \since New in yat 0.10 |
---|
37 | */ |
---|
38 | class BamWriter : std::unary_function<const BamRead&, void> |
---|
39 | { |
---|
40 | public: |
---|
41 | /** |
---|
42 | \brief Default constructor |
---|
43 | |
---|
44 | \note Created object cannot write, i.e., behaviour of |
---|
45 | operator() is undefined. |
---|
46 | */ |
---|
47 | BamWriter(void); |
---|
48 | |
---|
49 | /** |
---|
50 | \brief Constructor |
---|
51 | |
---|
52 | Creates an object that will write to \a out. |
---|
53 | */ |
---|
54 | explicit BamWriter(OutBamFile& out); |
---|
55 | |
---|
56 | /** |
---|
57 | write bam read \b to OutBamFile specified in constructor. |
---|
58 | */ |
---|
59 | void operator()(const BamRead& b) const; |
---|
60 | private: |
---|
61 | OutBamFile* out_; |
---|
62 | }; |
---|
63 | |
---|
64 | |
---|
65 | /** |
---|
66 | \brief Output iterator for bam file. |
---|
67 | |
---|
68 | A BamWriteIterator is an \output_iterator that writes output to a |
---|
69 | specific OutBamFile. The writing is performed via |
---|
70 | \code |
---|
71 | *iter = bam; |
---|
72 | \endcode |
---|
73 | where operator* retunrns a proxy which when assigned writes the |
---|
74 | right hand side to associated OutBamFile. |
---|
75 | |
---|
76 | \see OutBamFile and |
---|
77 | <a href="http://www.sgi.com/tech/stl/ostream_iterator.html"> |
---|
78 | std::ostream_iterator</a> |
---|
79 | |
---|
80 | \since New in yat 0.10 |
---|
81 | */ |
---|
82 | class BamWriteIterator |
---|
83 | : public boost::function_output_iterator<BamWriter> |
---|
84 | { |
---|
85 | public: |
---|
86 | /** |
---|
87 | \brief Default contructor |
---|
88 | |
---|
89 | result is not dereferencable |
---|
90 | */ |
---|
91 | BamWriteIterator(void); |
---|
92 | |
---|
93 | /** |
---|
94 | Creates an iterator that is associated with \a out. |
---|
95 | */ |
---|
96 | explicit BamWriteIterator(OutBamFile& out); |
---|
97 | private: |
---|
98 | }; |
---|
99 | }}} |
---|
100 | #endif |
---|