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

Go to the SVN repository for this file.

1 #ifndef SEQ_ANNOT_CI__HPP
2 #define SEQ_ANNOT_CI__HPP
3 
4 /* $Id: seq_annot_ci.hpp 33815 2007-05-04 17:18:18Z kazimird $
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 * Author: Aleksey Grichenko, Eugene Vasilchenko
30 *
31 * File Description:
32 * Seq-annot iterator
33 *
34 */
35 
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <objmgr/scope.hpp>
41 #include <objmgr/seq_entry_ci.hpp>
42 
43 #include <vector>
44 #include <stack>
45 
48 
49 
50 /** @addtogroup ObjectManagerIterators
51  *
52  * @{
53  */
54 
55 
56 class CSeq_annot_Handle;
57 class CSeq_entry_Info;
58 class CSeq_annot_Info;
59 class CBioseq_set_Info;
60 class CBioseq_Handle;
61 class CBioseq_set_Handle;
62 
63 
64 /////////////////////////////////////////////////////////////////////////////
65 ///
66 /// CSeq_annot_CI --
67 ///
68 /// enumerate CSeq_annot objects - packs of annotations
69 /// (features, graphs, alignments etc.)
70 ///
71 
73 {
74 public:
75  enum EFlags {
76  eSearch_entry, //< Search only in this entry
77  eSearch_recursive //< Search recursively
78  };
79 
80  /// Create an empty iterator
81  CSeq_annot_CI(void);
82 
83  /// Create an iterator that enumerates CSeq_annot objects
84  /// related to the given seq-entry
85  explicit CSeq_annot_CI(const CSeq_entry_Handle& entry,
86  EFlags flags = eSearch_recursive);
87 
88  /// Create an iterator that enumerates CSeq_annot objects
89  /// related to the given seq-set
90  explicit CSeq_annot_CI(const CBioseq_set_Handle& bioseq_set,
91  EFlags flags = eSearch_recursive);
92 
93  /// Create an iterator that enumerates CSeq_annot objects
94  /// related to the given seq-entry from different scope
95  CSeq_annot_CI(CScope& scope, const CSeq_entry& entry,
96  EFlags flags = eSearch_recursive);
97 
98  /// Create an iterator that enumerates CSeq_aannot objects
99  /// related to the given bioseq up to the TSE
100  explicit CSeq_annot_CI(const CBioseq_Handle& bioseq);
101 
102  CSeq_annot_CI(const CSeq_annot_CI& iter);
103  ~CSeq_annot_CI(void);
104 
105  CSeq_annot_CI& operator=(const CSeq_annot_CI& iter);
106 
107  /// Check if iterator points to an object
108  DECLARE_OPERATOR_BOOL(m_CurrentAnnot);
109 
110  /// Move to the next object in iterated sequence
111  CSeq_annot_CI& operator++(void);
112 
113  /// Get the current scope of the iterator
114  CScope& GetScope(void) const;
115 
116  const CSeq_annot_Handle& operator*(void) const;
117  const CSeq_annot_Handle* operator->(void) const;
118 
119 private:
120  void x_Initialize(const CSeq_entry_Handle& entry_handle, EFlags flags);
121 
122  void x_SetEntry(const CSeq_entry_Handle& entry);
123  void x_Push(void);
124  void x_Settle(void);
125 
126  typedef vector< CRef<CSeq_annot_Info> > TAnnots;
127  typedef TAnnots::const_iterator TAnnot_CI;
128  typedef stack<CSeq_entry_CI> TEntryStack;
129 
130  const TAnnots& x_GetAnnots(void) const;
131 
136  // Used when initialized with a bioseq handle to iterate upwards
137  bool m_UpTree;
138 };
139 
140 
141 /////////////////////////////////////////////////////////////////////
142 //
143 // Inline methods
144 //
145 /////////////////////////////////////////////////////////////////////
146 
147 
148 inline
150 {
151  return m_CurrentEntry.GetScope();
152 }
153 
154 
155 inline
157 {
158  _ASSERT(*this);
159  return m_CurrentAnnot;
160 }
161 
162 
163 inline
165 {
166  _ASSERT(*this);
167  return &m_CurrentAnnot;
168 }
169 
170 
171 /* @} */
172 
173 
176 
177 #endif // SEQ_ANNOT_CI__HPP
CBioseq_Handle –.
CBioseq_set_Handle –.
CScope –.
Definition: scope.hpp:92
CSeq_annot_CI –.
CSeq_annot_Handle –.
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
static uch flags
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
Definition: globals.hpp:371
CScope & GetScope(void) const
Get scope this handle belongs to.
DECLARE_OPERATOR_BOOL(m_CurrentAnnot)
Check if iterator points to an object.
CSeq_entry_Handle m_CurrentEntry
TEntryStack m_EntryStack
TAnnot_CI m_AnnotIter
const CSeq_annot_Handle * operator->(void) const
const CSeq_annot_Handle & operator*(void) const
TAnnots::const_iterator TAnnot_CI
CSeq_annot_Handle m_CurrentAnnot
CScope & GetScope(void) const
Get the current scope of the iterator.
vector< CRef< CSeq_annot_Info > > TAnnots
stack< CSeq_entry_CI > TEntryStack
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
#define _ASSERT
CScope & GetScope()
Modified on Fri Sep 20 14:58:19 2024 by modify_doxy.py rev. 669887