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

Go to the SVN repository for this file.

1 #ifndef SEQ_ANNOT_HANDLE__HPP
2 #define SEQ_ANNOT_HANDLE__HPP
3 
4 /* $Id: seq_annot_handle.hpp 62729 2014-05-01 19:40:00Z vasilche $
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 * Handle to Seq-annot object
33 *
34 */
35 
36 #include <corelib/ncbiobj.hpp>
37 
38 #include <objmgr/tse_handle.hpp>
40 
43 
44 
45 /** @addtogroup ObjectManagerHandles
46  *
47  * @{
48  */
49 
50 class CSeq_annot;
51 
52 class CScope;
53 
54 class CSeq_annot_CI;
55 class CAnnotTypes_CI;
56 class CAnnot_CI;
57 class CFeat_CI;
58 class CSeq_annot_Handle;
60 class CSeq_entry_Handle;
62 class CSeq_feat_Handle;
63 class CSeq_align_Handle;
64 class CSeq_graph_Handle;
66 class CSeq_align_EditHandle;
67 class CSeq_graph_EditHandle;
68 class CSeq_annot_Info;
69 
70 
72 {
73 public:
75 
77  : CScopeInfo_Base(tse, reinterpret_cast<const CTSE_Info_Object&>(info))
78  {
79  }
80 
81  const TObjectInfo& GetObjectInfo(void) const
82  {
83  return reinterpret_cast<const TObjectInfo&>(GetObjectInfo_Base());
84  }
86  {
87  return const_cast<TObjectInfo&>(GetObjectInfo());
88  }
89 };
90 
91 
92 
93 /////////////////////////////////////////////////////////////////////////////
94 ///
95 /// CSeq_annot_Handle --
96 ///
97 /// Proxy to access seq-annot objects
98 ///
99 
101 {
102 public:
103  CSeq_annot_Handle(void);
104 
105 
106  DECLARE_OPERATOR_BOOL(m_Info.IsValid());
107 
108  bool IsRemoved(void) const;
109 
110 
111  // Get CTSE_Handle of containing TSE
112  const CTSE_Handle& GetTSE_Handle(void) const;
113 
114 
115  // Reset handle and make it not to point to any seq-annot
116  void Reset(void);
117 
118  /// Check if handles point to the same seq-annot
119  ///
120  /// @sa
121  /// operator!=()
122  bool operator==(const CSeq_annot_Handle& annot) const;
123 
124  // Check if handles point to different seq-annot
125  ///
126  /// @sa
127  /// operator==()
128  bool operator!=(const CSeq_annot_Handle& annot) const;
129 
130  /// For usage in containers
131  bool operator<(const CSeq_annot_Handle& annot) const;
132  /// More stable comparison - takes loading order in account
133  bool OrderedBefore(const CSeq_annot_Handle& annot) const;
134 
135  /// Get scope this handle belongs to
136  CScope& GetScope(void) const;
137 
138  /// Complete and return const reference to the current seq-annot
139  CConstRef<CSeq_annot> GetCompleteSeq_annot(void) const;
140  CConstRef<CSeq_annot> GetSeq_annotCore(void) const;
141 
142  /// Unified interface for templates
144  CConstRef<TObject> GetCompleteObject(void) const;
145  CConstRef<TObject> GetObjectCore(void) const;
146 
147  /// Get parent Seq-entry handle
148  ///
149  /// @sa
150  /// GetSeq_entry_Handle()
151  CSeq_entry_Handle GetParentEntry(void) const;
152 
153  /// Get top level Seq-entry handle
154  CSeq_entry_Handle GetTopLevelEntry(void) const;
155 
156  /// Get 'edit' version of handle
157  CSeq_annot_EditHandle GetEditHandle(void) const;
158 
159  // Seq-annot accessors
160  bool IsNamed(void) const;
161  const string& GetName(void) const;
162 
163  // Mappings for CSeq_annot::C_Data methods
164  CSeq_annot::C_Data::E_Choice Which(void) const;
165  bool IsFtable(void) const;
166  bool IsAlign(void) const;
167  bool IsGraph(void) const;
168  bool IsIds(void) const;
169  bool IsLocs(void) const;
170  bool IsSeq_table(void) const;
171 
172  size_t GetSeq_tableNumRows(void) const;
173 
174  bool Seq_annot_IsSetId(void) const;
175  bool Seq_annot_CanGetId(void) const;
176  const CSeq_annot::TId& Seq_annot_GetId(void) const;
177 
178  bool Seq_annot_IsSetDb(void) const;
179  bool Seq_annot_CanGetDb(void) const;
180  CSeq_annot::TDb Seq_annot_GetDb(void) const;
181 
182  bool Seq_annot_IsSetName(void) const;
183  bool Seq_annot_CanGetName(void) const;
184  const CSeq_annot::TName& Seq_annot_GetName(void) const;
185 
186  bool Seq_annot_IsSetDesc(void) const;
187  bool Seq_annot_CanGetDesc(void) const;
188  const CSeq_annot::TDesc& Seq_annot_GetDesc(void) const;
189 
190  void Swap(CSeq_annot_Handle& annot);
191 
192 protected:
193  friend class CScope_Impl;
194  friend class CSeq_annot_CI;
195  friend class CAnnot_Collector;
196  friend class CMappedFeat;
197  friend class CAnnotObject_Ref;
198 
200  CSeq_annot_Handle(const CSeq_annot_Info& annot, const CTSE_Handle& tse);
201  void x_Set(const CSeq_annot_Info& annot, const CTSE_Handle& tse);
202 
204 
205 public: // non-public section
206  const TScopeInfo& x_GetScopeInfo(void) const;
207  const CSeq_annot_Info& x_GetInfo(void) const;
208  const CSeq_annot& x_GetSeq_annotCore(void) const;
209 
210  CScope_Impl& x_GetScopeImpl(void) const;
211 };
212 
213 
214 /////////////////////////////////////////////////////////////////////////////
215 ///
216 /// CSeq_annot_EditHandle --
217 ///
218 /// Proxy to access and edit seq-annot objects
219 ///
220 
221 template<typename Handle>
223 
225 {
226 public:
227  CSeq_annot_EditHandle(void);
228  /// create edit interface class to the object which already allows editing
229  /// throw an exception if the argument is not in editing mode
230  explicit CSeq_annot_EditHandle(const CSeq_annot_Handle& h);
231 
232  /// Navigate object tree
233  CSeq_entry_EditHandle GetParentEntry(void) const;
234 
235  /// Remove current annot
236  void Remove(void) const;
237 
238  // Individual annotations modifications.
239  // For all AddXxx and ReplaceXxx methods the ownership
240  // of new_obj argument will be taken by CSeq_annot_Handle,
241  // and the object should not be modified after the call.
242 
243  CSeq_feat_EditHandle AddFeat(const CSeq_feat& new_obj) const;
244  CSeq_align_Handle AddAlign(const CSeq_align& new_obj) const;
245  CSeq_graph_Handle AddGraph(const CSeq_graph& new_obj) const;
246 
247  // Remove handle from its current Seq-annot and add it here
248  CSeq_feat_EditHandle TakeFeat(const CSeq_feat_EditHandle& handle) const;
249  CSeq_align_Handle TakeAlign(const CSeq_align_Handle& handle) const;
250  CSeq_graph_Handle TakeGraph(const CSeq_graph_Handle& handle) const;
251 
252  void TakeAllAnnots(const CSeq_annot_EditHandle& annot) const;
253 
254  // Reorder features in the order of CFeat_CI
255  void ReorderFtable(CFeat_CI& feat_ci) const;
256  void ReorderFtable(const vector<CSeq_feat_Handle>& feats) const;
257 
258  /// Update index after manual modification of the object
259  void Update(void) const;
260 
261 protected:
262  friend class CScope_Impl;
263  friend class CBioseq_EditHandle;
265  friend class CSeq_entry_EditHandle;
266 
268 
269 public: // non-public section
270  TScopeInfo& x_GetScopeInfo(void) const;
272 
273 public:
277 
278  CSeq_feat_EditHandle x_RealAdd(const CSeq_feat& new_obj) const;
279  CSeq_align_Handle x_RealAdd(const CSeq_align& new_obj) const;
280  CSeq_graph_Handle x_RealAdd(const CSeq_graph& new_obj) const;
281 
282 };
283 
284 
285 /////////////////////////////////////////////////////////////////////////////
286 // CSeq_annot_Handle inline methods
287 /////////////////////////////////////////////////////////////////////////////
288 
289 
290 inline
292 {
293 }
294 
295 
296 inline
298 {
299  return m_Info->GetTSE_Handle();
300 }
301 
302 
303 inline
305 {
306  return GetTSE_Handle().GetScope();
307 }
308 
309 
310 inline
312 {
313  return GetTSE_Handle().x_GetScopeImpl();
314 }
315 
316 
317 inline
319 {
320  return *m_Info;
321 }
322 
323 
324 inline
326 {
327  m_Info.Swap(annot.m_Info);
328 }
329 
330 
331 inline
333 {
334  return m_Info.IsRemoved();
335 }
336 
337 
338 inline
340 {
341  return m_Info == handle.m_Info;
342 }
343 
344 
345 inline
347 {
348  return m_Info != handle.m_Info;
349 }
350 
351 
352 inline
354 {
355  return m_Info < handle.m_Info;
356 }
357 
358 
359 inline
361 {
362  return GetCompleteSeq_annot();
363 }
364 
365 
366 inline
368 {
369  return GetSeq_annotCore();
370 }
371 
372 
373 inline
375 {
376 }
377 
378 
379 inline
381 {
382  return m_Info.GetNCObject();
383 }
384 
385 
386 /* @} */
387 
388 
391 
392 #endif//SEQ_ANNOT_HANDLE__HPP
bool operator!=(const _Ht_iterator< _Val, _Nonconst_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__x, const _Ht_iterator< _Val, _Const_traits< _Val >, _Key, _HF, _ExK, _EqK, _All > &__y)
Definition: _hashtable.h:173
CAnnot_CI –.
Definition: annot_ci.hpp:59
CAnnot_descr –.
Definition: Annot_descr.hpp:66
CBioseq_EditHandle –.
CBioseq_set_EditHandle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
CMappedFeat –.
Definition: mapped_feat.hpp:59
const CTSE_Handle & GetTSE_Handle(void) const
Definition: tse_handle.hpp:445
const CTSE_Info_Object & GetObjectInfo_Base(void) const
Definition: tse_handle.hpp:452
bool IsRemoved(void) const
Definition: tse_handle.hpp:633
TScopeInfo & GetNCObject(void) const
Definition: tse_handle.hpp:671
CScope –.
Definition: scope.hpp:92
CSeq_annot_CI –.
CSeq_annot_Handle –.
CSeq_entry_Handle –.
CSeq_entry_Handle –.
CSeq_feat_EditHandle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CScope_Impl & x_GetScopeImpl(void) const
Definition: tse_handle.hpp:332
CScope & GetScope(void) const
Returns scope.
Definition: tse_handle.hpp:325
bool operator<(const CEquivRange &A, const CEquivRange &B)
bool operator==(const CEquivRange &A, const CEquivRange &B)
bool operator<(const CSeq_annot_Handle &annot) const
For usage in containers.
CSeq_annot TObject
Unified interface for templates.
const TScopeInfo & x_GetScopeInfo(void) const
TScopeInfo & x_GetScopeInfo(void) const
DECLARE_OPERATOR_BOOL(m_Info.IsValid())
CSeq_annot_Info TObjectInfo
friend class CSeq_annot_EditHandle
TScopeInfo & x_GetScopeInfo(void) const
void Swap(CSeq_annot_Handle &annot)
CSeq_annot_ScopeInfo TScopeInfo
CScopeInfo_Ref< TScopeInfo > m_Info
CScope_Impl & x_GetScopeImpl(void) const
const CTSE_Handle & GetTSE_Handle(void) const
CSeq_annot_ScopeInfo(const CTSE_Handle &tse, const TObjectInfo &info)
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
bool IsRemoved(void) const
CConstRef< TObject > GetObjectCore(void) const
CConstRef< TObject > GetCompleteObject(void) const
bool operator==(const CSeq_annot_Handle &annot) const
Check if handles point to the same seq-annot.
CScope & GetScope(void) const
Get scope this handle belongs to.
bool operator!=(const CSeq_annot_Handle &annot) const
CSeq_entry_Info & x_GetInfo(void) const
CConstRef< CSeq_annot > GetSeq_annotCore(void) const
TObjectInfo & GetNCObjectInfo(void)
const TObjectInfo & GetObjectInfo(void) const
void Swap(TThisType &ref)
Swaps the pointer with another reference.
Definition: ncbiobj.hpp:754
#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
list< CRef< CAnnot_id > > TId
Definition: Seq_annot_.hpp:356
E_Choice
Choice variants.
Definition: Seq_annot_.hpp:131
static MDB_envinfo info
Definition: mdb_load.c:37
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
Definition: swap.h:33
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
CScope & GetScope()
CRef< objects::CSeq_annot > AddFeat(CRef< objects::CSeq_feat > feat, CRef< objects::CSeq_entry > entry)
#define const
Definition: zconf.h:232
Modified on Sun Apr 14 05:26:08 2024 by modify_doxy.py rev. 669887