Changeset 3176
- Timestamp:
- Mar 15, 2014, 10:10:37 AM (9 years ago)
- Location:
- trunk/yat/omic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/omic/BamPair.cc
r3175 r3176 23 23 24 24 #include "BamPair.h" 25 26 #include <cassert> 25 27 26 28 namespace theplu { … … 60 62 } 61 63 64 ///////////// BamPairProxy //////////////////// 65 66 BamPairProxy::BamPairProxy(void) 67 : first_(NULL), second_(NULL) {} 68 69 BamPairProxy::BamPairProxy(const BamRead* first, const BamRead* second) 70 : first_(first), second_(second) {} 71 72 const BamRead& BamPairProxy::first(void) const 73 { 74 assert(first_); 75 return *first_; 76 } 77 78 79 const BamRead& BamPairProxy::second(void) const 80 { 81 assert(second_); 82 return *second_; 83 } 84 85 86 BamPairProxy::operator BamPair() const 87 { 88 return BamPair(*first_, *second_); 89 } 90 62 91 }}} -
trunk/yat/omic/BamPair.h
r3175 r3176 72 72 }; 73 73 74 75 /** 76 A proxy class that behaves like a const BamPair&. 77 78 The class is used in BamPairIterator. The class allows to create 79 an object that looks like a const reference of BamPair from two 80 BamRead pointers without copying the BamRead objects. As the 81 class is aimed at looking like a const BamPair&, implicit 82 conversion to BamPair is allowed to mimic: BamPair = const BamPair&. 83 */ 84 class BamPairProxy 85 { 86 public: 87 /** 88 \brief Default constructor 89 */ 90 BamPairProxy(void); 91 92 /** 93 Create a proxy from \a first and \a second. 94 95 \note if the objects pointed to by \a first and \a second goes 96 out of scope, this class becomes invalid and behaviour is 97 undefined. 98 */ 99 BamPairProxy(const BamRead* first, const BamRead* second); 100 101 /** 102 \return const reference to first BamRead 103 */ 104 const BamRead& first(void) const; 105 106 /** 107 \return const reference to second BamRead 108 */ 109 const BamRead& second(void) const; 110 111 /** 112 Implicit conversion from BamPairProxy to BamPair. 113 */ 114 operator BamPair() const; 115 private: 116 const BamRead* first_; 117 const BamRead* second_; 118 }; 119 74 120 }}} 75 121 #endif -
trunk/yat/omic/BamPairIterator.h
r3175 r3176 60 60 class BamPairIterator 61 61 : public boost::iterator_facade< 62 BamPairIterator<Base>, const BamPair, std::input_iterator_tag 62 BamPairIterator<Base>, const BamPair, std::input_iterator_tag, 63 const BamPairProxy 63 64 > 64 65 { … … 81 82 Base iter_; 82 83 Base end_; 83 BamPair x_;84 const BamRead* mate_; 84 85 boost::shared_ptr<std::map<std::string, BamRead> > siam_reads_; 85 86 typedef std::pair<int32_t, int32_t> Position; … … 87 88 friend class boost::iterator_core_access; 88 89 89 const BamPair &dereference(void) const;90 const BamPairProxy dereference(void) const; 90 91 bool equal(const BamPairIterator& other) const; 91 92 void increment(void); … … 143 144 144 145 template<typename Base> 145 const BamPair &146 const BamPairProxy 146 147 BamPairIterator<Base>::dereference(void) const 147 148 { 148 return x_;149 return BamPairProxy(mate_, &*iter_); 149 150 } 150 151 … … 189 190 for (; lower!=reads_->end() && lower->first == position; ++lower) 190 191 if (same_query_name(lower->second, *iter_)) { 191 x_.first() = lower->second; 192 x_.second() = *iter_; 192 mate_ = &lower->second; 193 193 return; 194 194 } … … 199 199 mate = siam_reads_->lower_bound(iter_->name()); 200 200 if (mate!=siam_reads_->end() && same_query_name(mate->second, *iter_)) { 201 x_.first() = mate->second; 202 x_.second() = *iter_; 201 mate_ = &mate->second; 203 202 return; 204 203 }
Note: See TracChangeset
for help on using the changeset viewer.