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

Go to the SVN repository for this file.

1 /* $Id: tse_info_object.cpp 99886 2023-05-18 18:01:35Z vasilche $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * CTSE_Info_Object
30 *
31 */
32 
33 
34 #include <ncbi_pch.hpp>
36 #include <objmgr/impl/tse_info.hpp>
38 
41 
42 
44  : m_TSE_Info(0),
45  m_Parent_Info(0),
46  m_DirtyAnnotIndex(true),
47  m_NeedUpdateFlags(0)
48 {
49 }
50 
51 
53  TObjectCopyMap* copy_map)
54  : m_TSE_Info(0),
55  m_Parent_Info(0),
56  m_DirtyAnnotIndex(true),
57  m_NeedUpdateFlags(src.m_NeedUpdateFlags.load())
58 {
59  if ( copy_map ) {
60  (*copy_map)[CConstRef<CObject>(&src)] = this;
61  }
62 }
63 
64 
66 {
67 }
68 
69 
71 {
72  return HasTSE_Info() && GetTSE_Info().HasDataSource();
73 }
74 
75 
77 {
79  return *m_TSE_Info;
80 }
81 
82 
84 {
86  return *m_TSE_Info;
87 }
88 
89 
91 {
92  return GetTSE_Info().GetDataSource();
93 }
94 
95 
97 {
99  return *m_Parent_Info;
100 }
101 
102 
104 {
106  return *m_Parent_Info;
107 }
108 
109 
111 {
113  _ASSERT(m_Parent_Info || &tse == this);
114  x_TSEAttachContents(tse);
115  _ASSERT(m_TSE_Info == &tse);
116 }
117 
118 
120 {
121  _ASSERT(m_TSE_Info == &tse);
122  _ASSERT(m_Parent_Info || &tse == this);
123  x_TSEDetachContents(tse);
125 }
126 
127 
129 {
131  m_TSE_Info = &tse;
133 }
134 
135 
137 {
138  _ASSERT(m_TSE_Info == &tse);
140  m_TSE_Info = 0;
141 }
142 
143 
145 {
147  _ASSERT(m_Parent_Info || m_TSE_Info == this);
148  _ASSERT(!m_Parent_Info || &ds == &GetDataSource());
149  x_DSAttachContents(ds);
150 }
151 
152 
154 {
156  _ASSERT(m_Parent_Info || m_TSE_Info == this);
157  _ASSERT(!m_Parent_Info || &ds == &GetDataSource());
158  x_DSDetachContents(ds);
159 }
160 
161 
163 {
164  _ASSERT(&ds == &GetDataSource());
165 }
166 
167 
169 {
170  _ASSERT(&ds == &GetDataSource());
171 }
172 
173 
175 {
178  m_Parent_Info = &parent;
179  if ( x_DirtyAnnotIndex() ) {
181  }
182  if ( m_NeedUpdateFlags ) {
184  }
185 }
186 
187 
189 {
190  _ASSERT(m_Parent_Info == &parent);
192  m_Parent_Info = 0;
193 }
194 
195 
197 {
198  _ASSERT(&object.GetBaseParent_Info() == this);
199  if ( HasTSE_Info() ) {
200  object.x_TSEAttach(GetTSE_Info());
201  }
202  if ( HasDataSource() ) {
203  object.x_DSAttach(GetDataSource());
204  }
205 }
206 
207 
209 {
210  _ASSERT(&object.GetBaseParent_Info() == this);
211  if ( HasDataSource() ) {
212  object.x_DSDetach(GetDataSource());
213  }
214  if ( HasTSE_Info() ) {
215  object.x_TSEDetach(GetTSE_Info());
216  }
217 }
218 
219 
221 {
222  if ( !x_DirtyAnnotIndex() ) {
223  m_DirtyAnnotIndex = true;
225  }
226 }
227 
228 
230 {
231  if ( HasParent_Info() ) {
233  }
234  else {
236  }
237 }
238 
239 
241 {
242 }
243 
244 
246 {
250 }
251 
252 
254 {
255  if ( x_DirtyAnnotIndex() ) {
256  m_DirtyAnnotIndex = false;
257  if ( !HasParent_Info() ) {
259  }
260  }
261 }
262 
263 
265 {
266 }
267 
268 
270 {
271  if ( x_DirtyAnnotIndex() ) {
274  }
275 }
276 
277 
279 {
280 }
281 
282 
284 {
285  flags &= ~m_NeedUpdateFlags; // already set
286  if ( flags ) {
288  if ( HasParent_Info() ) {
290  }
291  }
292 }
293 
294 
296 {
297  int retry_count = 3;
298  while ( m_NeedUpdateFlags & flags ) {
299  if ( --retry_count < 0 ) {
300  ERR_POST("CTSE_Info_Object::x_Update("<<flags<<"): "
301  "Failed to update "<<m_NeedUpdateFlags);
302  break;
303  }
304  const_cast<CTSE_Info_Object*>(this)->
306  }
307 }
308 
309 
311 {
313 }
314 
315 
317 {
318  x_Update(~0);
319 }
320 
321 
323 {
325 }
326 
327 
329 {
330  GetTSE_Info().x_LoadChunk(chunk_id);
331 }
332 
333 
334 void CTSE_Info_Object::x_LoadChunks(const TChunkIds& chunk_ids) const
335 {
336  GetTSE_Info().x_LoadChunks(chunk_ids);
337 }
338 
340 {
341  return m_UniqueId;
342 }
343 
345 {
346  m_UniqueId = id;
347 }
348 
349 
351 {
352  if ( HasParent_Info() ) {
354  }
355  return string();
356 }
357 
358 
atomic< TNeedUpdateFlags > m_NeedUpdateFlags
virtual void x_SetNeedUpdateParent(TNeedUpdateFlags flags)
void x_SetDirtyAnnotIndex(void)
virtual void x_DoUpdate(TNeedUpdateFlags flags)
void x_UpdateCore(void) const
virtual void SetBioObjectId(const CBioObjectId &id)
virtual void x_DSDetachContents(CDataSource &ds)
void x_SetNeedUpdate(TNeedUpdateFlags flags)
CDataSource & GetDataSource(void) const
atomic< bool > m_DirtyAnnotIndex
CBioObjectId m_UniqueId
void x_BaseParentAttach(CTSE_Info_Object &parent)
void x_Update(TNeedUpdateFlags flags) const
void x_LoadChunks(const TChunkIds &chunk_ids) const
void x_DetachObject(CTSE_Info_Object &object)
virtual ~CTSE_Info_Object(void)
bool HasDataSource(void) const
void x_LoadChunk(TChunkId chunk_id) const
void x_UpdateAnnotIndex(CTSE_Info &tse)
void x_BaseParentDetach(CTSE_Info_Object &parent)
virtual void x_TSEAttachContents(CTSE_Info &tse)
@ fNeedUpdate_children
all fields of children objects
void x_DSAttach(CDataSource &ds)
virtual void x_DSAttachContents(CDataSource &ds)
virtual void x_ResetDirtyAnnotIndexNoParent(void)
void x_TSEAttach(CTSE_Info &tse)
void x_SetParentDirtyAnnotIndex(void)
virtual void x_TSEDetachContents(CTSE_Info &tse)
const CTSE_Info & GetTSE_Info(void) const
bool x_DirtyAnnotIndex(void) const
void x_UpdateComplete(void) const
const CTSE_Info_Object & GetBaseParent_Info(void) const
void x_ResetDirtyAnnotIndex(void)
bool HasParent_Info(void) const
CTSE_Info * m_TSE_Info
void x_TSEDetach(CTSE_Info &tse)
virtual string GetDescription(void) const
void x_AttachObject(CTSE_Info_Object &object)
virtual const CBioObjectId & GetBioObjectId(void) const
virtual void x_SetDirtyAnnotIndexNoParent(void)
void x_DSDetach(CDataSource &ds)
virtual void x_UpdateAnnotIndexContents(CTSE_Info &tse)
vector< TChunkId > TChunkIds
CTSE_Info_Object * m_Parent_Info
@ kNeedUpdate_bits
number of bits for fields
bool HasTSE_Info(void) const
CDataSource & GetDataSource(void) const
Definition: tse_info.hpp:805
void x_LoadChunk(TChunkId chunk_id) const
Definition: tse_info.cpp:856
bool HasDataSource(void) const
Definition: tse_info.hpp:798
void x_UnregisterBioObject(CTSE_Info_Object &info)
Definition: tse_info.cpp:451
void x_LoadChunks(const TChunkIds &chunk_ids) const
Definition: tse_info.cpp:862
Definition: map.hpp:338
static uch flags
#define true
Definition: bool.h:35
string
Definition: cgiapp.hpp:690
#define _DEBUG_ARG(arg)
Definition: ncbidbg.hpp:134
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#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 _ASSERT
Modified on Fri Sep 20 14:57:22 2024 by modify_doxy.py rev. 669887