NCBI C++ ToolKit
reader_id1_base.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: reader_id1_base.cpp 94815 2021-09-15 15:09:33Z vasilche $
2  * ===========================================================================
3  * PUBLIC DOMAIN NOTICE
4  * National Center for Biotechnology Information
5  *
6  * This software/database is a "United States Government Work" under the
7  * terms of the United States Copyright Act. It was written as part of
8  * the author's official duties as a United States Government employee and
9  * thus cannot be copyrighted. This software/database is freely available
10  * to the public for use. The National Library of Medicine and the U.S.
11  * Government have not placed any restriction on its use or reproduction.
12  *
13  * Although all reasonable efforts have been taken to ensure the accuracy
14  * and reliability of the software and data, the NLM and the U.S.
15  * Government do not and cannot warrant the performance or results that
16  * may be obtained by using this software or data. The NLM and the U.S.
17  * Government disclaim all warranties, express or implied, including
18  * warranties of performance, merchantability or fitness for any particular
19  * purpose.
20  *
21  * Please cite the author in any work or product based on this material.
22  * ===========================================================================
23  *
24  * Author: Eugene Vasilchenko
25  *
26  * File Description: Base data reader interface
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 #include <corelib/ncbi_param.hpp>
36 #include <objtools/error_codes.hpp>
37 
39 #include <objmgr/impl/tse_info.hpp>
42 
43 #define NCBI_USE_ERRCODE_X Objtools_Reader_Id1
44 
47 
48 /////////////////////////////////////////////////////////////////////////////
49 // CId1ReaderBase
50 /////////////////////////////////////////////////////////////////////////////
51 
52 
54 {
55 }
56 
57 
59 {
60 }
61 
62 
64  const TBlobId& blob_id)
65 {
66  CLoadLockBlob blob(result, blob_id);
67  if ( blob.IsLoadedBlob() ) {
68  return true;
69  }
70 
71  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
72  dynamic_cast<const CProcessor_ExtAnnot&>
74  .Process(result, blob_id, kMain_ChunkId);
75  _ASSERT(blob.IsLoadedBlob());
76  return true;
77  }
78 
79  GetBlob(result, blob_id, kMain_ChunkId);
80  _ASSERT(blob.IsLoadedBlob());
81  return true;
82 }
83 
84 
86  const TBlobId& blob_id)
87 {
88  CLoadLockBlobState lock(result, blob_id);
89  if ( lock.IsLoadedBlobState() ) {
90  return true;
91  }
92 
93  GetBlobState(result, blob_id);
94  return true;
95 }
96 
97 
99  const TBlobId& blob_id)
100 {
101  CLoadLockBlobVersion blob(result, blob_id);
102  if ( blob.IsLoadedBlobVersion() ) {
103  return true;
104  }
105 
106  GetBlobVersion(result, blob_id);
107  return true;
108 }
109 
110 
112  const TBlobId& blob_id, TChunkId chunk_id)
113 {
114  _ASSERT(CProcessor_ExtAnnot::IsExtAnnot(blob_id, chunk_id));
115  _ASSERT(chunk_id == kDelayedMain_ChunkId);
116 
117  CLoadLockBlob blob(result, blob_id, chunk_id);
118  _ASSERT(blob.IsLoadedBlob());
119  if ( blob.IsLoadedChunk() ) {
120  return true;
121  }
122 
123  GetBlob(result, blob_id, chunk_id);
124  if ( !blob.IsLoadedChunk() ) {
125  CLoadLockSetter setter(blob);
126  if ( !setter.IsLoaded() ) {
127  ERR_POST_X(1, "ExtAnnot chunk is not loaded: "<<blob_id);
128  setter.SetLoaded();
129  }
130  }
131  _ASSERT(blob.IsLoadedChunk());
132  return true;
133 }
134 
135 
137 {
138  return sat == eSat_ANNOT || sat == eSat_ANNOT_CDD;
139 }
140 
141 
143 {
144  return subsat == eSubSat_CDD? eSat_ANNOT_CDD: eSat_ANNOT;
145 }
146 
147 
148 void CId1ReaderBase::CreateExtAnnotBlob_ids(TBlobIds& blob_ids, TIntId gi, int ext_feat)
149 {
150  while ( int bit = GetNextExtAnnotBit(ext_feat) ) {
151  CRef<CBlob_id> blob_id(new CBlob_id);
152  SetExtAnnotBlob_id(*blob_id, gi, bit);
153  blob_ids.push_back(CBlob_Info(blob_id, fBlobHasExtAnnot));
154  }
155 }
156 
157 
159 {
160  int bits = ext_feat;
161  int bit = bits & ~(bits-1);
162  ext_feat = bits - bit;
163  return bit;
164 }
165 
166 
168 {
169  blob_id.SetSat(GetAnnotSat(bit));
170  blob_id.SetSatKey(Int4(gi));
171  blob_id.SetSubSat(Int4((gi>>16)&0xffff0000)|(bit&0xffff));
172 }
173 
174 
176 {
177  return (TIntId(Int4(blob_id.GetSubSat()&0xffff0000))<<16)|Uint4(blob_id.GetSatKey());
178 }
179 
180 
182 {
183  return blob_id.GetSubSat()&0xffff;
184 }
185 
186 
void SetSubSat(TSubSat v)
Definition: blob_id.hpp:109
TSatKey GetSatKey() const
Definition: blob_id.hpp:64
void SetSatKey(TSatKey v)
Definition: blob_id.hpp:113
TSubSat GetSubSat() const
Definition: blob_id.hpp:60
void SetSat(TSat v)
Definition: blob_id.hpp:105
static TIntId GetExtAnnotGi(const CBlob_id &blob_id)
bool LoadBlob(CReaderRequestResult &result, const TBlobId &blob_id)
static void CreateExtAnnotBlob_ids(TBlobIds &blob_ids, TIntId gi, int ext_feat)
virtual void GetBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)=0
bool LoadBlobState(CReaderRequestResult &result, const TBlobId &blob_id)
bool LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
virtual void GetBlobState(CReaderRequestResult &result, const CBlob_id &blob_id)=0
static int GetNextExtAnnotBit(int &ext_feat)
static ESat GetAnnotSat(int subsat)
static void SetExtAnnotBlob_id(CBlob_id &blob_id, TIntId gi, int bit)
static bool IsAnnotSat(int sat)
virtual void GetBlobVersion(CReaderRequestResult &result, const CBlob_id &blob_id)=0
static int GetExtAnnotSubSat(const CBlob_id &blob_id)
bool LoadBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id)
bool IsLoadedBlobState(void) const
bool IsLoadedBlobVersion(void) const
bool IsLoadedChunk(void) const
bool IsLoadedBlob(void) const
void SetLoaded(void)
bool IsLoaded(void) const
static bool IsExtAnnot(const TBlobId &blob_id)
@ eType_ExtAnnot
Definition: processor.hpp:81
const CProcessor & GetProcessor(CProcessor::EType type) const
Definition: dispatcher.cpp:219
CReadDispatcher * m_Dispatcher
Definition: reader.hpp:353
vector< CBlob_Info > TBlobIds
Definition: reader.hpp:97
int TChunkId
Definition: reader.hpp:93
CRef –.
Definition: ncbiobj.hpp:618
Int8 TIntId
Definition: ncbimisc.hpp:999
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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
virtual void Process(SOCK sock)=0
Runs asynchronously (from a separate thread) for each request.
Definition of all error codes used in objtools libraries.
@ kMain_ChunkId
Definition: blob_id.hpp:147
@ kDelayedMain_ChunkId
Definition: blob_id.hpp:149
@ fBlobHasExtAnnot
Definition: blob_id.hpp:175
#define _ASSERT
else result
Definition: token2.c:20
Modified on Sun Jun 23 05:20:40 2024 by modify_doxy.py rev. 669887