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

Go to the SVN repository for this file.

1 #ifndef PREFETCH_ACTIONS__HPP
2 #define PREFETCH_ACTIONS__HPP
3 
4 /* $Id: prefetch_actions.hpp 59914 2013-09-26 15:15:41Z 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: Eugene Vasilchenko
30 *
31 * File Description:
32 * Prefetch manager
33 *
34 */
35 
38 #include <objmgr/bioseq_handle.hpp>
39 #include <objmgr/feat_ci.hpp>
40 
43 
44 class CScope;
45 
46 /** @addtogroup ObjectManagerCore
47  *
48  * @{
49  */
50 
51 
53 {
54 public:
56  {
57  }
58  explicit
60  : m_Scope(scope)
61  {
62  }
63 
64  static CScopeSource New(CScope& scope)
65  {
66  CScopeSource ret;
67  ret.m_BaseScope.Set(&scope);
68  return ret;
69  }
70 
71  CScope& GetScope(void);
72 
73 private:
76 };
77 
78 
80  : public CObject, public IPrefetchAction, public CScopeSource
81 {
82 public:
84 
85  CPrefetchBioseq(const CScopeSource& scope,
86  const CSeq_id_Handle& id);
87 
88  virtual bool Execute(CRef<CPrefetchRequest> token);
89 
90  const CSeq_id_Handle& GetSeq_id(void) const
91  {
92  return m_Seq_id;
93  }
94  const CBioseq_Handle& GetBioseqHandle(void) const
95  {
96  return m_Result;
97  }
98  const CBioseq_Handle& GetResult(void) const
99  {
100  return m_Result;
101  }
102 
103 protected:
104  CPrefetchBioseq(const CScopeSource& scope);
105  CPrefetchBioseq(const CBioseq_Handle& bioseq);
106 
107 private:
110 };
111 
112 
114  : public CPrefetchBioseq
115 {
116 public:
117  typedef CFeat_CI TResult;
118 
119  // from location
120  CPrefetchFeat_CI(const CScopeSource& scope,
122  const SAnnotSelector& selector);
123 
124  // from bioseq
125  CPrefetchFeat_CI(const CBioseq_Handle& bioseq,
126  const CRange<TSeqPos>& range,
127  ENa_strand strand,
128  const SAnnotSelector& selector);
129  CPrefetchFeat_CI(const CScopeSource& scope,
130  const CSeq_id_Handle& seq_id,
131  const CRange<TSeqPos>& range,
132  ENa_strand strand,
133  const SAnnotSelector& selector);
134 
135  virtual bool Execute(CRef<CPrefetchRequest> token);
136 
137  const SAnnotSelector& GetSelector(void) const
138  {
139  return m_Selector;
140  }
141  const CFeat_CI& GetFeat_CI(void) const
142  {
143  return m_Result;
144  }
145  const CFeat_CI& GetResult(void) const
146  {
147  return m_Result;
148  }
149 
150 private:
151  // from location
153  // from bioseq
156  // filter
158  // result
160 };
161 
162 
163 template<class Handle>
165  : public IPrefetchAction
166 {
167 public:
168  typedef Handle THandle;
169  typedef typename THandle::TObject TObject;
171 
172  explicit
173  CPrefetchComplete(const THandle& handle)
174  : m_Handle(handle)
175  {
176  }
177 
178  virtual bool Execute(CRef<CPrefetchRequest> token)
179  {
180  m_Result = m_Handle.GetCompleteObject();
181  return m_Result;
182  }
183 
184  const THandle GetHandle(void) const
185  {
186  return m_Handle;
187  }
188  const CConstRef<TObject>& GetResult(void) const
189  {
190  return m_Result;
191  }
192 
193 private:
196 };
197 
198 
199 template<>
201  : public CPrefetchBioseq
202 {
203 public:
207 
208  explicit
209  CPrefetchComplete(const THandle& handle);
210  CPrefetchComplete(const CScopeSource& scope,
211  const CSeq_id_Handle& seq_id);
212 
213  virtual bool Execute(CRef<CPrefetchRequest> token);
214 
215  const THandle GetHandle(void) const
216  {
217  return GetBioseqHandle();
218  }
219  const CConstRef<TObject>& GetComplete(void) const
220  {
221  return m_Result;
222  }
223  const CConstRef<TObject>& GetResult(void) const
224  {
225  return m_Result;
226  }
227 
228 private:
230 };
231 
232 
234 {
235 public:
236  virtual ~ISeq_idSource(void);
237  virtual CSeq_id_Handle GetNextSeq_id(void) = 0;
238 };
239 
240 
241 template<class Container>
242 class CStdSeq_idSource : public CObject,
243  public ISeq_idSource
244 {
245 public:
246  typedef Container TContainer;
247  typedef typename TContainer::const_iterator TIterator;
248 
249  explicit
251  : m_Container(cont), m_Iterator(m_Container.begin())
252  {
253  }
254 
256  {
257  CSeq_id_Handle ret;
258  if ( m_Iterator != m_Container.end() ) {
259  ret = *m_Iterator++;
260  }
261  return ret;
262  }
263 
264 private:
267 };
268 
269 
271  : public CObject,
272  public IPrefetchActionSource
273 {
274 public:
275  typedef vector<CSeq_id_Handle> TIds;
276 
278  ISeq_idSource* ids);
280  const TIds& ids);
281 
282  virtual CIRef<IPrefetchAction> GetNextAction(void);
283 
284 private:
287 };
288 
289 
291  : public CObject,
292  public IPrefetchActionSource
293 {
294 public:
295  typedef vector<CSeq_id_Handle> TIds;
296 
298  ISeq_idSource* ids,
299  const SAnnotSelector& sel);
301  const TIds& ids,
302  const SAnnotSelector& sel);
303 
304  virtual CIRef<IPrefetchAction> GetNextAction(void);
305 
306 private:
310 };
311 
312 
314 {
315 public:
316  static void Wait(CRef<CPrefetchRequest> token);
317 
318  // GetBioseqHandle
319  static CRef<CPrefetchRequest> GetBioseqHandle(CPrefetchManager& manager,
320  const CScopeSource& scope,
321  const CSeq_id_Handle& id);
322  static CBioseq_Handle GetBioseqHandle(CRef<CPrefetchRequest> token);
323 
324  // GetFeat_CI
325  static CRef<CPrefetchRequest> GetFeat_CI(CPrefetchManager& manager,
326  const CBioseq_Handle& bioseq,
327  const CRange<TSeqPos>& range,
328  ENa_strand strand,
329  const SAnnotSelector& sel);
330  static CRef<CPrefetchRequest> GetFeat_CI(CPrefetchManager& manager,
331  const CScopeSource& scope,
332  const CSeq_id_Handle& seq_id,
333  const CRange<TSeqPos>& range,
334  ENa_strand strand,
335  const SAnnotSelector& sel);
336  static CRef<CPrefetchRequest> GetFeat_CI(CPrefetchManager& manager,
337  const CScopeSource& scope,
339  const SAnnotSelector& sel);
340  static CFeat_CI GetFeat_CI(CRef<CPrefetchRequest> token);
341 };
342 
343 
344 /* @} */
345 
346 
349 
350 #endif // PREFETCH_MANAGER__HPP
static CRef< CScope > m_Scope
CBioseq_Handle –.
CFeat_CI –.
Definition: feat_ci.hpp:64
void Set(CScope *scope)
Definition: heap_scope.cpp:56
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
#define Handle
Definition: ncbistd.hpp:119
virtual CSeq_id_Handle GetNextSeq_id(void)=0
CConstRef< CSeq_loc > m_Loc
const CConstRef< TObject > & GetResult(void) const
CStdSeq_idSource(const TContainer &cont)
CHeapScope m_Scope
vector< CSeq_id_Handle > TIds
CConstRef< TObject > TResult
TContainer::const_iterator TIterator
SAnnotSelector m_Selector
const CFeat_CI & GetFeat_CI(void) const
const SAnnotSelector & GetSelector(void) const
CIRef< ISeq_idSource > m_Ids
CHeapScope m_BaseScope
static CScopeSource New(CScope &scope)
CRange< TSeqPos > m_Range
THandle::TObject TObject
const CSeq_id_Handle & GetSeq_id(void) const
const CConstRef< TObject > & GetResult(void) const
const CFeat_CI & GetResult(void) const
const CBioseq_Handle & GetResult(void) const
const THandle GetHandle(void) const
const CConstRef< TObject > & GetComplete(void) const
CIRef< ISeq_idSource > m_Ids
const THandle GetHandle(void) const
CPrefetchComplete(const THandle &handle)
CSeq_id_Handle m_Seq_id
virtual CSeq_id_Handle GetNextSeq_id(void)
CBioseq_Handle TResult
const CBioseq_Handle & GetBioseqHandle(void) const
vector< CSeq_id_Handle > TIds
CScopeSource(CScope &scope)
virtual bool Execute(CRef< CPrefetchRequest > token)
#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
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
range(_Ty, _Ty) -> range< _Ty >
string Execute(const string &cmmd, const vector< string > &args, const string &data=kEmptyStr)
SAnnotSelector –.
CScope & GetScope()
Modified on Fri Jul 19 17:15:03 2024 by modify_doxy.py rev. 669887