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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR_IMPL___BIOOBJID__HPP
2 #define OBJECTS_OBJMGR_IMPL___BIOOBJID__HPP
3 
4 /* $Id: bio_object_id.hpp 89909 2020-04-30 12:40:14Z grichenk $
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: Maxim Didenko
30 *
31 * File Description:
32 *
33 */
34 
35 #include <corelib/ncbiobj.hpp>
36 
38 
41 
43 {
44 public:
45  enum EType {
49  eUnSet
50  };
51  CBioObjectId() : m_Id(eUnSet, CSeq_id_Handle()) {}
52  explicit CBioObjectId(const CSeq_id_Handle& id) : m_Id(eSeqId,id) {}
54  : m_Id(type, CSeq_id_Handle::GetGiHandle(GI_FROM(TIntId, id)))
55  {
56  _ASSERT(type == eSeqId || type == eSetId || type == eUniqNumber);
57  }
58 
59  const CSeq_id_Handle& GetSeqId() const {
60  _ASSERT(m_Id.first == eSeqId); return m_Id.second;
61  }
62 
63  TIntId GetSetId() const {
64  _ASSERT(m_Id.first == eSetId); return GI_TO(TIntId, m_Id.second.GetGi());
65  }
66 
67  TIntId GetUniqNumber() const {
68  _ASSERT(m_Id.first == eUniqNumber); return GI_TO(TIntId, m_Id.second.GetGi());
69  }
70 
71  bool operator == (const CBioObjectId& other) const {
72  return m_Id == other.m_Id;
73  }
74  bool operator != (const CBioObjectId& other) const {
75  return m_Id != other.m_Id;
76  }
77  bool operator < (const CBioObjectId& other) const {
78  return m_Id < other.m_Id;
79  }
80 
81  EType GetType() const { return m_Id.first; }
82  const CSeq_id_Handle& x_GetSeqIdNoCheck() const { return m_Id.second; }
83 
84 private:
85  pair<EType, CSeq_id_Handle> m_Id;
86 };
87 
88 
89 
92 
93 #endif//OBJECTS_OBJMGR_IMPL___BIOOBJID__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
TIntId GetUniqNumber() const
TIntId GetSetId() const
pair< EType, CSeq_id_Handle > m_Id
CBioObjectId(EType type, TIntId id)
CBioObjectId(const CSeq_id_Handle &id)
const CSeq_id_Handle & GetSeqId() const
EType GetType() const
const CSeq_id_Handle & x_GetSeqIdNoCheck() const
bool operator<(const CEquivRange &A, const CEquivRange &B)
bool operator==(const CEquivRange &A, const CEquivRange &B)
#define GI_FROM(T, value)
Definition: ncbimisc.hpp:1086
Int8 TIntId
Definition: ncbimisc.hpp:999
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
#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
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Definition: type.c:6
#define _ASSERT
Modified on Fri Sep 20 14:57:33 2024 by modify_doxy.py rev. 669887