NCBI C++ ToolKit
alnvec_iterator.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_ALNMGR___ALNVEC_ITERATOR__HPP
2 #define OBJTOOLS_ALNMGR___ALNVEC_ITERATOR__HPP
3 
4 /* $Id: alnvec_iterator.hpp 36644 2008-01-23 21:08:23Z todorov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 
38 
39 
41 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// CAlnChunkSegment - IAlnSegment implementation for CAlnMap::CAlnChunk
45 
47  : public IAlnSegment
48 {
49 public:
50  typedef objects::CAlnMap::CAlnChunk TChunk;
51 
53  CAlnChunkSegment(CConstRef<TChunk> chunk, bool reversed);
54  //CAlnChunkSegment& operator=(CConstRef<TChunk> chunk);
55  void Init(CConstRef<TChunk> chunk, bool reversed);
56  void Reset() { m_Chunk.Reset(); }
57 
58  virtual operator bool() const;
59 
60  virtual TSegTypeFlags GetType() const;
61  virtual const TSignedRange& GetAlnRange() const;
62  virtual const TSignedRange& GetRange() const;
63 
64 
65 protected:
66  CConstRef<TChunk> m_Chunk;
67  bool m_Reversed;
68 };
69 
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// CAlnVecIterator - IAlnSegmentIterator implementation for CAlnMap::CAlnChunkVec
73 
75  : public IAlnSegmentIterator
76 {
77 public:
78  typedef objects::CAlnMap::CAlnChunkVec TChunkVec;
79 
81  CAlnVecIterator(const TChunkVec& vec, bool reversed, size_t index = 0);
82 
83  virtual IAlnSegmentIterator* Clone() const;
84 
85  // returns true if iterator points to a valid segment
86  virtual operator bool() const;
87 
89 
90  virtual bool operator==(const IAlnSegmentIterator& it) const;
91  virtual bool operator!=(const IAlnSegmentIterator& it) const;
92 
93  virtual const value_type& operator*() const;
94  virtual const value_type* operator->() const;
95 
96 protected:
97  inline bool x_Equals(const CAlnVecIterator& it) const
98  {
99  return m_ChunkVec == it.m_ChunkVec && m_ChunkIndex == it.m_ChunkIndex;
100  }
101  inline bool x_IsValidChunk() const
102  {
103  return m_ChunkVec && m_ChunkIndex >=0 && m_ChunkIndex < m_ChunkVec->size();
104  }
105 
106 protected:
107  CConstRef<TChunkVec> m_ChunkVec;
108  bool m_Reversed;
109 
110  int m_ChunkIndex;
111  CAlnChunkSegment m_Segment;
112 };
113 
114 
116 
117 #endif // OBJTOOLS_ALNMGR___ALNVEC_ITERATOR__HPP
CAlnChunkSegment - IAlnSegment implementation for CAlnMap::CAlnChunk.
virtual const TSignedRange & GetAlnRange() const
Get alignment range for the segment.
virtual TSegTypeFlags GetType() const
Get current segment type.
virtual const TSignedRange & GetRange() const
Get the selected row range.
CAlnChunkSegment(CConstRef< TChunk > chunk, bool reversed)
void Init(CConstRef< TChunk > chunk, bool reversed)
objects::CAlnMap::CAlnChunk TChunk
CAlnVecIterator - IAlnSegmentIterator implementation for CAlnMap::CAlnChunkVec.
objects::CAlnMap::CAlnChunkVec TChunkVec
virtual const value_type & operator*() const
virtual IAlnSegmentIterator * Clone() const
Create a copy of the iterator.
bool x_Equals(const CAlnVecIterator &it) const
virtual bool operator!=(const IAlnSegmentIterator &it) const
CAlnVecIterator(const TChunkVec &vec, bool reversed, size_t index=0)
virtual IAlnSegmentIterator & operator++()
Advance to the next segment.
virtual const value_type * operator->() const
CConstRef< TChunkVec > m_ChunkVec
virtual bool operator==(const IAlnSegmentIterator &it) const
Compare iterators.
bool x_IsValidChunk() const
Alignment segment iterator interface.
Alignment segment interface.
unsigned TSegTypeFlags
#define bool
Definition: bool.h:34
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XALNMGR_EXPORT
Definition: ncbi_export.h:1065
Modified on Sat Jun 22 10:44:21 2024 by modify_doxy.py rev. 669887