source: trunk/yat/omic/BamPair.h @ 4025

Last change on this file since 4025 was 4025, checked in by Peter, 9 months ago

add move constructor for BamPair?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1#ifndef theplu_yat_omic_bam_pair
2#define theplu_yat_omic_bam_pair
3
4// $Id: BamPair.h 4025 2021-01-14 02:59:03Z peter $
5
6/*
7  Copyright (C) 2014, 2018 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "BamRead.h"
26
27namespace theplu {
28namespace yat {
29namespace omic {
30
31  /**
32     \since New in yat 0.12
33   */
34  class BamPair
35  {
36  public:
37    /**
38       \brief default constructor
39
40       Creating a pair using default constructor of BamRead.
41     */
42    BamPair(void);
43
44    /**
45       \brief Copy constructor
46     */
47    BamPair(const BamRead& first, const BamRead& second);
48
49    /**
50       \brief Move constructor
51
52       \since New in yat 0.19
53     */
54    BamPair(BamRead&& first, BamRead&& second);
55
56    /**
57       \brief access first BamRead
58    */
59    BamRead& first(void);
60
61    /**
62       \brief access first BamRead
63    */
64    const BamRead& first(void) const;
65
66    /**
67       \brief access second BamRead
68    */
69    BamRead& second(void);
70
71    /**
72       \brief access second BamRead
73    */
74    const BamRead& second(void) const;
75
76  private:
77    BamRead first_;
78    BamRead second_;
79  };
80
81
82  /**
83     A proxy class that behaves like a const BamPair&.
84
85     The class is used in BamPairIterator. The class allows to create
86     an object that looks like a const reference of BamPair from two
87     BamRead pointers without copying the BamRead objects. As the
88     class is aimed at looking like a const BamPair&, implicit
89     conversion to BamPair is allowed to mimic: BamPair = const BamPair&.
90   */
91  class BamPairProxy
92  {
93  public:
94    /**
95       \brief Default constructor
96    */
97    BamPairProxy(void);
98
99    /**
100       Create a proxy from \a first and \a second.
101
102       \note if the objects pointed to by \a first and \a second goes
103       out of scope, this class becomes invalid and behaviour is
104       undefined.
105     */
106    BamPairProxy(const BamRead* first, const BamRead* second);
107
108    /**
109       \return const reference to first BamRead
110     */
111    const BamRead& first(void) const;
112
113    /**
114       \return const reference to second BamRead
115    */
116    const BamRead& second(void) const;
117
118    /**
119       Implicit conversion from BamPairProxy to BamPair.
120     */
121    operator BamPair() const;
122  private:
123    const BamRead* first_;
124    const BamRead* second_;
125  };
126
127}}}
128#endif
Note: See TracBrowser for help on using the repository browser.