source: trunk/yat/omic/BamWriteIterator.h @ 2883

Last change on this file since 2883 was 2883, checked in by Peter, 10 years ago

New classes to wrap around functionality provided by samtools. refs #729

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#ifndef theplu_yat_omic_bam_write_iterator
2#define theplu_yat_omic_bam_write_iterator
3
4// $Id: BamWriteIterator.h 2883 2012-12-03 12:48:51Z 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
25namespace theplu {
26namespace yat {
27namespace omic {
28
29  class BamRead;
30  class OutBamFile;
31
32  /**
33     Functor taking a BamRead and writing to an OutBamFile
34   */
35  class BamWriter : std::unary_function<const BamRead&, void>
36  {
37  public:
38    /**
39       \brief Default constructor
40
41       \note Created object cannot write, i.e., behaviour of
42       operator() is undefined.
43    */
44    BamWriter(void);
45
46    /**
47       \brief Constructor
48
49       Creates an object that will write to \a out.
50     */
51    explicit BamWriter(OutBamFile& out);
52
53    /**
54       write bam read \b to OutBamFile specified in constructor.
55     */
56    void operator()(const BamRead& b) const;
57  private:
58    OutBamFile* out_;
59  };
60
61
62  /**
63     \brief Output iterator for bam file.
64
65     A BamWriteIterator is an \output_iterator that writes output to a
66     specific OutBamFile. The writing is performed via
67     \code
68     *iter = bam;
69     \endcode
70     where operator* retunrns a proxy which when assigned writes the
71     right hand side to associated OutBamFile.
72
73     \see OutBamFile
74     \see std::ostream_iterator
75   */
76  class BamWriteIterator
77    : public boost::function_output_iterator<BamWriter>
78  {
79  public:
80    /**
81       \brief Default contructor
82
83       result is not dereferencable
84     */
85    BamWriteIterator(void);
86
87    /**
88       Creates an iterator that is associated with \a out.
89     */
90    explicit BamWriteIterator(OutBamFile& out);
91  private:
92  };
93}}}
94#endif
Note: See TracBrowser for help on using the repository browser.