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

Go to the SVN repository for this file.

1 /* $Id: loaderpatcher.cpp 33815 2007-05-04 17:18:18Z kazimird $
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: Maxim Didenko
27 *
28 * File Description:
29 *
30 * ===========================================================================
31 */
32 #include <ncbi_pch.hpp>
35 
38 #include <objmgr/annot_name.hpp>
39 
48 
52 #include <objects/seq/Seqdesc.hpp>
55 
79 
80 
81 //=======================================================================
82 // CDataLoaderPatcher Public interface
83 //
84 
87 
88 
92  CRef<CDataLoader> data_loader,
93  CRef<IEditsDBEngine> db_engine,
94  CRef<IEditSaver> saver,
95  CObjectManager::EIsDefault is_default,
97 {
98  SParam param(data_loader, db_engine, saver);
99  TMaker maker(param);
100  CDataLoader::RegisterInObjectManager(om, maker, is_default, priority);
101  return maker.GetRegisterInfo();
102 }
103 
104 
105 
107 {
108  return "PATCHER_" + param.m_DataLoader->GetName();
109 }
110 
111 
112 CDataLoaderPatcher::CDataLoaderPatcher(const string& loader_name,
113  const SParam& param)
114  : CDataLoader (loader_name),
115  m_DataLoader(param.m_DataLoader),
116  m_DBEngine (param.m_DBEngine),
117  m_EditSaver (param.m_EditSaver)
118 {
119 }
120 
122 {
123 }
124 
127  EChoice choice)
128 {
129  TTSE_LockSet locks;
130  string sblobid;
131  bool found = m_DBEngine->FindSeqId(idh, sblobid);
132  if (found) {
133  if (!sblobid.empty()) {
134  TBlobId blobid = m_DataLoader->GetBlobIdFromString(sblobid);
135  TTSE_Lock lock = m_DataLoader->GetBlobById(blobid);
136  locks.insert(lock);
137  }
138  } else {
139  locks = m_DataLoader->GetRecords(idh, choice);
140  }
141  TTSE_LockSet nlocks;
142  x_PatchLockSet(locks, nlocks);
143  return nlocks;
144 }
145 
148  const SRequestDetails& details)
149 {
150  TTSE_LockSet locks;
151  string sblobid;
152  bool found = m_DBEngine->FindSeqId(idh, sblobid);
153  if (found) {
154  if (!sblobid.empty()) {
155  TBlobId blobid = m_DataLoader->GetBlobIdFromString(sblobid);
156  TTSE_Lock lock = m_DataLoader->GetBlobById(blobid);
157  locks.insert(lock);
158  }
159  } else {
160  locks = m_DataLoader->GetDetailedRecords(idh, details);
161  }
162  TTSE_LockSet nlocks;
163  x_PatchLockSet(locks, nlocks);
164  return nlocks;
165 }
166 
167 
170 {
172  TTSE_LockSet nlocks;
173  x_PatchLockSet(locks, nlocks);
174  return nlocks;
175 }
176 
177 
180 {
181  string sblobid;
182  bool found = m_DBEngine->FindSeqId(idh, sblobid);
183  if (found) {
184  if (!sblobid.empty()) {
185  return m_DataLoader->GetBlobIdFromString(sblobid);
186  } else {
187  return TBlobId();
188  }
189  } else {
190  return m_DataLoader->GetBlobId(idh);
191  }
192 }
193 
196 {
198 }
199 
202 {
203  return m_DataLoader->GetBlobVersion(id);
204 }
205 
207 {
208  return m_DataLoader->CanGetBlobById();
209 }
212 {
213  return x_PatchLock(m_DataLoader->GetBlobById(blob_id));
214 }
215 
217 {
218  m_DataLoader->GetChunk(chunk_info);
219 }
221 {
222  m_DataLoader->GetChunks(chunks);
223 }
224 
225 /*
226 SRequestDetails CDataLoaderPatcher::ChoiceToDetails(EChoice choice) const
227 {
228  return m_DataLoader->ChoiceToDetails(choice);
229 }
230 CDataLoaderPatcher::EChoice
231 CDataLoaderPatcher::DetailsToChoice(const SRequestDetails::TAnnotSet& annots) const
232 {
233  return m_DataLoader->DetailsToChoice(annots);
234 }
235 
236 CDataLoaderPatcher::EChoice
237 CDataLoaderPatcher::DetailsToChoice(const SRequestDetails& details) const
238 {
239  return m_DataLoader->DetailsToChoice(details);
240 }
241 */
242 
245 {
246  const TBlobId& blob_id = (*lock).GetBlobId();
247  CTSE_LoadLock nlock = GetDataSource()->GetTSE_LoadLock(blob_id);
248 
249  if (!nlock.IsLoaded()) {
250  if ( x_IsPatchNeeded(*lock) ) {
251  CRef<CSeq_entry> entry;
252  CConstRef<CSeq_entry> orig_entry = lock->GetSeq_entrySkeleton();
253  if( orig_entry ) {
254  entry.Reset(new CSeq_entry);
255  entry->Assign(*orig_entry);
256  }
257  nlock->Assign(lock, entry);//, CRef<ITSE_Assigner>());
258  x_ApplyPatches(*nlock);
259  } else
260  nlock->Assign(lock);
261 
262  nlock.SetLoaded();
263  }
264  return TTSE_Lock(nlock);
265 }
267  TTSE_LockSet& new_locks)
268 {
269  ITERATE(TTSE_LockSet, it, orig_locks) {
270  const TTSE_Lock& lock = *it;
271  new_locks.insert(x_PatchLock(lock));
272  }
273 }
274 
276 {
277  return m_EditSaver;
278 }
279 
281 {
282  string blob_id = tse.GetBlobId().ToString();
283  return m_DBEngine->HasBlob(blob_id);
284 }
285 
286 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_AddId& cmd);
287 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_RemoveId& cmd);
288 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_ResetIds& cmd);
293 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_AddDescr& cmd);
294 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_SetDescr& cmd);
296 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_AddDesc& cmd);
305 void x_ApplyCmd(CTSE_Info& tse, const CSeqEdit_Cmd_AddAnnot& cmd);
307 
309 {
311  string blob_id = tse.GetBlobId().ToString();
312  m_DBEngine->GetCommands(blob_id, cmds);
313 
315  const CSeqEdit_Cmd& cmd = **it;
316  switch(cmd.Which()) {
318  x_ApplyCmd(tse,cmd.GetAdd_id());
319  break;
321  x_ApplyCmd(tse,cmd.GetRemove_id());
322  break;
324  x_ApplyCmd(tse,cmd.GetReset_ids());
325  break;
327  x_ApplyCmd(tse,cmd.GetChange_seqattr());
328  break;
330  x_ApplyCmd(tse,cmd.GetReset_seqattr());
331  break;
333  x_ApplyCmd(tse,cmd.GetChange_setattr());
334  break;
336  x_ApplyCmd(tse,cmd.GetReset_setattr());
337  break;
339  x_ApplyCmd(tse,cmd.GetAdd_descr());
340  break;
342  x_ApplyCmd(tse,cmd.GetSet_descr());
343  break;
345  x_ApplyCmd(tse,cmd.GetReset_descr());
346  break;
348  x_ApplyCmd(tse,cmd.GetAdd_desc());
349  break;
351  x_ApplyCmd(tse,cmd.GetRemove_desc());
352  break;
354  x_ApplyCmd(tse,cmd.GetAttach_seq());
355  break;
357  x_ApplyCmd(tse,cmd.GetAttach_set());
358  break;
360  x_ApplyCmd(tse,cmd.GetReset_seqentry());
361  break;
363  x_ApplyCmd(tse,cmd.GetAttach_seqentry());
364  break;
366  x_ApplyCmd(tse,cmd.GetRemove_seqentry());
367  break;
369  x_ApplyCmd(tse,cmd.GetAttach_annot());
370  break;
372  x_ApplyCmd(tse,cmd.GetRemove_annot());
373  break;
375  x_ApplyCmd(tse,cmd.GetAdd_annot());
376  break;
378  x_ApplyCmd(tse,cmd.GetReplace_annot());
379  break;
381  NCBI_THROW(CLoaderException, eOtherError,
382  "SeqEdit_Cmd is not set");
383  }
384  }
385 }
386 
387 static inline CBioObjectId s_Convert(const CSeqEdit_Id& id)
388 {
389  switch (id.Which()) {
391  return CBioObjectId(CSeq_id_Handle::GetHandle(id.GetBioseq_id()));
393  return CBioObjectId(CBioObjectId::eSetId, id.GetBioseqset_id());
395  return CBioObjectId(CBioObjectId::eUniqNumber, id.GetUnique_num());
396  default:
397  NCBI_THROW(CLoaderException, eOtherError,
398  "SeqEdit_Id is not set");
399  }
400 }
401 
403 {
404  CTSE_Info_Object* to = tse.x_FindBioObject(id);
405  CBioseq_Info* seq = dynamic_cast<CBioseq_Info*>(to);
406  if (seq)
407  return *seq;
408  NCBI_THROW(CLoaderException, eOtherError,
409  "BioObjectId does not point to Bioseq");
410 
411 }
412 
414 {
415  CTSE_Info_Object* to = tse.x_FindBioObject(id);
416  CBioseq_set_Info* bset = dynamic_cast<CBioseq_set_Info*>(to);
417  if (bset)
418  return *bset;
419  NCBI_THROW(CLoaderException, eOtherError,
420  "BioObjectId does not point to Bioseq_set");
421 
422 }
423 
425 {
426  CTSE_Info_Object* to = tse.x_FindBioObject(id);
427  CBioseq_Base_Info* base = dynamic_cast<CBioseq_Base_Info*>(to);
428  if (base)
429  return *base;
430  NCBI_THROW(CLoaderException, eOtherError,
431  "BioObjectId does not point to Bioseq_set");
432 
433 }
435 {
436  CTSE_Info_Object* to = tse.x_FindBioObject(id);
437  CSeq_entry_Info* entry = dynamic_cast<CSeq_entry_Info*>(to);
438  if (entry)
439  return *entry;
440  CBioseq_Base_Info* base = dynamic_cast<CBioseq_Base_Info*>(to);
441  if (base)
442  return base->GetParentSeq_entry_Info();
443 
444  NCBI_THROW(CLoaderException, eOtherError,
445  "BioObjectId does not point to Seq_entry");
446 
447 }
448 
449 
450 
452 {
453  CBioObjectId id = s_Convert(cmd.GetId());
454  const CSeq_id& seqid = cmd.GetAdd_id();
455  CBioseq_Info& bioseq = GetBioseq(tse, id);
456  bioseq.AddId(CSeq_id_Handle::GetHandle(seqid));
457 }
459 {
460  CBioObjectId id = s_Convert(cmd.GetId());
461  const CSeq_id& seqid = cmd.GetRemove_id();
462  CBioseq_Info& bioseq = GetBioseq(tse, id);
463  bioseq.RemoveId(CSeq_id_Handle::GetHandle(seqid));
464 }
465 
467 {
468  CBioObjectId id = s_Convert(cmd.GetId());
469  CBioseq_Info& bioseq = GetBioseq(tse, id);
470  bioseq.ResetId();
471 }
472 
474 {
475  CBioObjectId id = s_Convert(cmd.GetId());
476  CBioseq_Info& info = GetBioseq(tse, id);
477 
478  switch (cmd.GetData().Which()) {
480  info.SetInst(const_cast<CSeq_inst&>(cmd.GetData().GetInst()));
481  break;
483  info.SetInst_Repr((CSeq_inst::ERepr)cmd.GetData().GetRepr());
484  break;
486  info.SetInst_Mol((CSeq_inst::EMol)cmd.GetData().GetMol());
487  break;
489  info.SetInst_Length(cmd.GetData().GetLength());
490  break;
492  info.SetInst_Fuzz(const_cast<CInt_fuzz&>(cmd.GetData().GetFuzz()));
493  break;
495  info.SetInst_Topology((CSeq_inst::ETopology)cmd.GetData().GetTopology());
496  break;
498  info.SetInst_Strand((CSeq_inst::EStrand)cmd.GetData().GetStrand());
499  break;
501  info.SetInst_Ext(const_cast<CSeq_ext&>(cmd.GetData().GetExt()));
502  break;
504  info.SetInst_Hist(const_cast<CSeq_hist&>(cmd.GetData().GetHist()));
505  break;
507  info.SetInst_Seq_data(const_cast<CSeq_data&>(cmd.GetData().GetSeq_data()));
508  break;
509  default:
510  _ASSERT(0);
511  }
512 }
514 {
515  CBioObjectId id = s_Convert(cmd.GetId());
516  CBioseq_Info& info = GetBioseq(tse, id);
517  switch (cmd.GetWhat()) {
519  info.ResetInst();
520  break;
522  info.ResetInst_Repr();
523  break;
525  info.ResetInst_Mol();
526  break;
528  info.ResetInst_Length();
529  break;
531  info.ResetInst_Fuzz();
532  break;
534  info.ResetInst_Topology();
535  break;
537  info.ResetInst_Strand();
538  break;
540  info.ResetInst_Ext();
541  break;
543  info.ResetInst_Hist();
544  break;
546  info.ResetInst_Seq_data();
547  break;
548  default:
549  _ASSERT(0);
550  }
551 
552 }
553 
555 {
556  CBioObjectId id = s_Convert(cmd.GetId());
557  CBioseq_set_Info& info = GetBioseq_set(tse, id);
558  switch (cmd.GetData().Which()) {
560  info.SetId(const_cast<CObject_id&>(cmd.GetData().GetId()));
561  break;
563  info.SetColl(const_cast<CDbtag&>(cmd.GetData().GetColl()));
564  break;
566  info.SetLevel(cmd.GetData().GetLevel());
567  break;
569  info.SetClass((CBioseq_set::TClass)cmd.GetData().GetClass());
570  break;
572  info.SetRelease(const_cast<string&>(cmd.GetData().GetRelease()));
573  break;
575  info.SetDate(const_cast<CDate&>(cmd.GetData().GetDate()));
576  break;
577  default:
578  _ASSERT(0);
579  }
580 }
582 {
583  CBioObjectId id = s_Convert(cmd.GetId());
584  CBioseq_set_Info& info = GetBioseq_set(tse, id);
585  switch (cmd.GetWhat()) {
587  info.ResetId();
588  break;
590  info.ResetColl();
591  break;
593  info.ResetLevel();
594  break;
596  info.ResetClass();
597  break;
599  info.ResetRelease();
600  break;
602  info.ResetDate();
603  break;
604  default:
605  _ASSERT(0);
606  }
607 }
608 
610 {
611  CBioObjectId id = s_Convert(cmd.GetId());
612  const CSeq_descr& descr = cmd.GetAdd_descr();
613  CBioseq_Base_Info& base = GetBase(tse, id);
614  base.AddSeq_descr(descr);
615 }
617 {
618  CBioObjectId id = s_Convert(cmd.GetId());
619  CSeq_descr& descr = const_cast<CSeq_descr&>(cmd.GetSet_descr());
620  CBioseq_Base_Info& base = GetBase(tse, id);
621  base.SetDescr(descr);
622 }
623 
625 {
626  CBioObjectId id = s_Convert(cmd.GetId());
627  CBioseq_Base_Info& base = GetBase(tse, id);
628  base.ResetDescr();
629 }
631 {
632  CBioObjectId id = s_Convert(cmd.GetId());
633  CSeqdesc& desc = const_cast<CSeqdesc&>(cmd.GetAdd_desc());
634  CBioseq_Base_Info& base = GetBase(tse, id);
635  base.AddSeqdesc(desc);
636 }
638 {
639  CBioObjectId id = s_Convert(cmd.GetId());
640  const CSeqdesc& desc = cmd.GetRemove_desc();
641  CBioseq_Base_Info& base = GetBase(tse, id);
642  const CSeq_descr& descr = base.GetDescr();
643  ITERATE(CSeq_descr::Tdata, it, descr.Get()) {
644  const CSeqdesc& d = **it;
645  if (d.Equals(desc)) {
646  base.RemoveSeqdesc(d);
647  break;
648  }
649  }
650 }
651 
653 {
654  CBioObjectId id = s_Convert(cmd.GetId());
655  CSeq_entry_Info& info = GetSeq_entry(tse,id);
656  CBioseq& seq = const_cast<CBioseq&>(cmd.GetSeq());
657  info.SelectSeq(seq);
658 }
659 
661 {
662  CBioObjectId id = s_Convert(cmd.GetId());
663  CSeq_entry_Info& info = GetSeq_entry(tse,id);
664  CBioseq_set& set = const_cast<CBioseq_set&>(cmd.GetSet());
665  info.SelectSet(set);
666 }
668 {
669  CBioObjectId id = s_Convert(cmd.GetId());
670  CSeq_entry_Info& info = GetSeq_entry(tse,id);
671  info.Reset();
672 }
674 {
675  CBioObjectId id = s_Convert(cmd.GetId());
676  CBioseq_set_Info& info = GetBioseq_set(tse, id);
677  CRef<CSeq_entry> entry;
678  if (cmd.IsSetSeq_entry())
679  entry.Reset(const_cast<CSeq_entry*>(&cmd.GetSeq_entry()));
680  else
681  entry.Reset(new CSeq_entry);
682  int index = cmd.GetIndex();
683  info.AddEntry(*entry, index, true);
684 }
685 
687 {
688  CBioObjectId id = s_Convert(cmd.GetId());
689  CBioseq_set_Info& info = GetBioseq_set(tse, id);
690  CBioObjectId entry_id = s_Convert(cmd.GetEntry_id());
691  CSeq_entry_Info& entry_info = GetSeq_entry(tse,entry_id);
692  info.RemoveEntry(Ref(&entry_info));
693 }
694 
695 
697 {
698  CBioObjectId id = s_Convert(cmd.GetId());
699  CSeq_entry_Info& info = GetSeq_entry(tse,id);
700  CSeq_annot& annot = const_cast<CSeq_annot&>(cmd.GetAnnot());
701  info.AddAnnot(annot);
702 }
703 
704 template<typename T> static inline
706  const CAnnotName& name, const T& old_value)
707 {
708  CSeq_annot_Finder finder(tse);
709  const CAnnotObject_Info* annot_obj = finder.Find(info,name,old_value);
710  if (!annot_obj)
711  NCBI_THROW(CLoaderException, eOtherError,
712  "Annotation object is not found");
713  CSeq_annot_Info& annot = const_cast<CSeq_annot_Info&>
714  (annot_obj->GetSeq_annot_Info());
715  annot.Remove(annot_obj->GetAnnotIndex());
716 }
717 
719 {
720  CBioObjectId id = s_Convert(cmd.GetId());
721  CSeq_entry_Info& info = GetSeq_entry(tse,id);
722  CAnnotName annot_name;
723  if (cmd.GetNamed()) {
724  annot_name.SetNamed(cmd.GetName());
725  }
726 
727  switch (cmd.GetData().Which()) {
729  x_MakeRemove(tse, info, annot_name, cmd.GetData().GetFeat());
730  break;
732  x_MakeRemove(tse, info, annot_name, cmd.GetData().GetAlign());
733  break;
735  x_MakeRemove(tse, info, annot_name, cmd.GetData().GetGraph());
736  break;
737  default:
738  NCBI_THROW(CLoaderException, eOtherError,
739  "Annotation is not set");
740  }
741 }
742 
744 {
745  CBioObjectId id = s_Convert(cmd.GetId());
746  CSeq_entry_Info& info = GetSeq_entry(tse,id);
747  CAnnotName annot_name;
748  if (cmd.GetNamed()) {
749  annot_name.SetNamed(cmd.GetName());
750  }
751 
752  CSeq_annot_Finder finder(tse);
753  CSeq_annot_Info* annot = NULL;
754 
755  if (cmd.IsSetSearch_param() &&
756  cmd.GetSearch_param().Which() == CSeqEdit_Cmd_AddAnnot::TSearch_param::e_Obj) {
757  const CAnnotObject_Info* annot_obj = NULL;
758  switch (cmd.GetData().Which()) {
760  annot_obj = finder.Find(info, annot_name,
761  cmd.GetSearch_param().GetObj().GetFeat());
762  break;
764  annot_obj = finder.Find(info, annot_name,
765  cmd.GetSearch_param().GetObj().GetAlign());
766  break;
768  annot_obj = finder.Find(info, annot_name,
769  cmd.GetSearch_param().GetObj().GetGraph());
770  break;
771  default:
772  NCBI_THROW(CLoaderException, eOtherError,
773  "Annotation is not set");
774  }
775  if (!annot_obj)
776  NCBI_THROW(CLoaderException, eOtherError,
777  "Seq_annot object is not found");
778  annot = &const_cast<CAnnotObject_Info*>(annot_obj)->GetSeq_annot_Info();
779  } else if (cmd.IsSetSearch_param() &&
780  cmd.GetSearch_param().Which()
782  annot = const_cast<CSeq_annot_Info*>(finder.Find(info, annot_name,
783  cmd.GetSearch_param().GetDescr()));
784  } else {
785  annot = const_cast<CSeq_annot_Info*>(finder.Find(info, annot_name));
786  }
787  if (!annot)
788  NCBI_THROW(CLoaderException, eOtherError,
789  "Seq_annot object is not found");
790 
791  switch (cmd.GetData().Which()) {
793  annot->Add(cmd.GetData().GetFeat());
794  break;
796  annot->Add(cmd.GetData().GetAlign());
797  break;
799  annot->Add(cmd.GetData().GetGraph());
800  break;
801  default:
802  NCBI_THROW(CLoaderException, eOtherError,
803  "Annotation is not set");
804  }
805 }
806 
807 template<typename T> static inline
809  const CAnnotName& name,
810  const T& old_value, const T& new_value)
811 {
812  CSeq_annot_Finder finder(tse);
813  const CAnnotObject_Info* annot_obj = finder.Find(info, name, old_value);
814  if (!annot_obj)
815  NCBI_THROW(CLoaderException, eOtherError,
816  "Annotation object is not found");
817  CSeq_annot_Info& annot = const_cast<CSeq_annot_Info&>
818  (annot_obj->GetSeq_annot_Info());
819  annot.Replace(annot_obj->GetAnnotIndex(), new_value);
820 }
821 
823 {
824  CBioObjectId id = s_Convert(cmd.GetId());
825  CSeq_entry_Info& info = GetSeq_entry(tse,id);
826  CAnnotName annot_name;
827  if (cmd.GetNamed()) {
828  annot_name.SetNamed(cmd.GetName());
829  }
830 
831  switch (cmd.GetData().Which()) {
833  x_MakeReplace(tse,info, annot_name,
834  cmd.GetData().GetFeat().GetOvalue(),
835  cmd.GetData().GetFeat().GetNvalue());
836  break;
838  x_MakeReplace(tse, info, annot_name,
839  cmd.GetData().GetAlign().GetOvalue(),
840  cmd.GetData().GetAlign().GetNvalue());
841  break;
843  x_MakeReplace(tse, info, annot_name,
844  cmd.GetData().GetGraph().GetOvalue(),
845  cmd.GetData().GetGraph().GetNvalue());
846  break;
847  default:
848  NCBI_THROW(CLoaderException, eOtherError,
849  "Annotation is not set");
850  }
851 }
852 
854 
855 // ===========================================================================
856 
858 
860 {
861  // Typedef to silence compiler warning. A better solution to this
862  // problem is probably possible.
863 
864  typedef void(*TArgFuncType)(list<CPluginManager<CDataLoader>
865  ::SDriverInfo> &,
867  ::EEntryPointRequest);
868 
869  RegisterEntryPoint<CDataLoader>((TArgFuncType)
871 }
872 
873 const string kDataLoader_Patcher_DriverName("dlpatcher");
874 
875 /// Data Loader Factory for BlastDbDataLoader
876 ///
877 /// This class provides an interface which builds an instance of the
878 /// BlastDbDataLoader and registers it with the object manager.
879 
881 {
882 public:
883  /// Constructor
886 
887  /// Destructor
888  virtual ~CDLPatcher_DataLoaderCF(void) {}
889 
890 protected:
891  /// Create and register a data loader
892  /// @param om
893  /// A reference to the object manager
894  /// @param params
895  /// Arguments for the data loader constructor
898  const TPluginManagerParamTree* params) const;
899 };
900 
901 
904  const TPluginManagerParamTree* params) const
905 {
906  if ( !ValidParams(params) ) {
907  return NULL;
908  }
909  //Parse params, select constructor
910  const string& data_loader =
911  GetParam(GetDriverName(), params,
912  kCFParam_DLP_DataLoader, false);
913  const string& db_engine =
914  GetParam(GetDriverName(), params,
916 
917  if ( !data_loader.empty() && !db_engine.empty() ) {
918  const TPluginManagerParamTree* dl_tree =
919  params->FindNode(data_loader);
920 
921  typedef CPluginManager<CDataLoader> TDLManager;
922  TDLManager dl_manager;
923  CRef<CDataLoader> dl(dl_manager.CreateInstance(data_loader,
924  TDLManager::GetDefaultDrvVers(),
925  dl_tree));
926  const TPluginManagerParamTree* db_tree =
927  params->FindNode(db_engine);
928 
929  typedef CPluginManager<IEditsDBEngine> TDBManager;
930  TDBManager db_manager;
931  CRef<IEditsDBEngine> db(db_manager.CreateInstance(db_engine,
932  TDBManager::GetDefaultDrvVers(),
933  db_tree));
934  const string& edit_saver =
935  GetParam(GetDriverName(), params,
936  kCFParam_DLP_EditSaver, false);
937 
938  CRef<IEditSaver> es;
939  if ( !edit_saver.empty() ) {
940  const TPluginManagerParamTree* es_tree =
941  params->FindNode(edit_saver);
942 
943  typedef CPluginManager<IEditSaver> TESManager;
944  TESManager es_manager;
945  es = es_manager.CreateInstance(edit_saver,
946  TESManager::GetDefaultDrvVers(),
947  es_tree);
948  }
949 
950  if (dl && db) {
952  om,
953  dl,
954  db,
955  es,
956  GetIsDefault(params),
957  GetPriority(params)).GetLoader();
958  }
959  }
960  return NULL;
961 }
962 
963 
967 {
969  NCBI_EntryPointImpl(info_list, method);
970 }
971 
972 
976 {
977  NCBI_EntryPoint_DataLoader_Patcher(info_list, method);
978 }
979 
980 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
void SetNamed(const string &name)
Definition: annot_name.hpp:73
const CSeq_annot_Info & GetSeq_annot_Info(void) const
TIndex GetAnnotIndex(void) const
CRef< CSeqdesc > RemoveSeqdesc(const CSeqdesc &d)
const TDescr & GetDescr(void) const
void AddSeq_descr(const TDescr &v)
bool AddSeqdesc(CSeqdesc &d)
TDescr & SetDescr(void)
const CSeq_entry_Info & GetParentSeq_entry_Info(void) const
bool RemoveId(const CSeq_id_Handle &id)
void ResetId(void)
bool AddId(const CSeq_id_Handle &id)
Data Loader Factory for BlastDbDataLoader.
virtual ~CDLPatcher_DataLoaderCF(void)
Destructor.
CDLPatcher_DataLoaderCF(void)
Constructor.
virtual CDataLoader * CreateAndRegister(CObjectManager &om, const TPluginManagerParamTree *params) const
Create and register a data loader.
CObjectManager::TPriority GetPriority(const TPluginManagerParamTree *params) const
const string & GetDriverName(void) const
CObjectManager::EIsDefault GetIsDefault(const TPluginManagerParamTree *params) const
bool ValidParams(const TPluginManagerParamTree *params) const
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CRef< CDataLoader >, CRef< IEditsDBEngine >, CRef< IEditSaver > saver=CRef< IEditSaver >(), CObjectManager::EIsDefault is_default=CObjectManager::eNonDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
void x_PatchLockSet(const TTSE_LockSet &orig_locks, TTSE_LockSet &new_locks)
virtual TEditSaver GetEditSaver() const
virtual ~CDataLoaderPatcher()
virtual void GetChunks(const TChunkSet &chunks)
CDataLoaderPatcher(const string &loader_name, const SParam &param)
CRef< IEditsDBEngine > m_DBEngine
CRef< CDataLoader > m_DataLoader
CRef< IEditSaver > m_EditSaver
bool x_IsPatchNeeded(const CTSE_Info &tse)
TTSE_Lock x_PatchLock(const TTSE_Lock &lock)
virtual TTSE_Lock GetBlobById(const TBlobId &blob_id)
virtual TBlobId GetBlobId(const CSeq_id_Handle &idh)
virtual TTSE_LockSet GetExternalRecords(const CBioseq_Info &bioseq)
Request from a datasource set of blobs with external annotations.
virtual bool CanGetBlobById(void) const
virtual TTSE_LockSet GetRecords(const CSeq_id_Handle &idh, EChoice choice)
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
virtual TTSE_LockSet GetDetailedRecords(const CSeq_id_Handle &idh, const SRequestDetails &details)
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
void x_ApplyPatches(CTSE_Info &tse)
virtual TBlobId GetBlobIdFromString(const string &str) const
virtual TBlobVersion GetBlobVersion(const TBlobId &id)
static string GetLoaderNameFromArgs(const SParam &param)
virtual void GetChunk(TChunk chunk_info)
CTSE_LoadLock GetTSE_LoadLock(const TBlobId &blob_id)
Definition: Date.hpp:53
Definition: Dbtag.hpp:53
Data loader exceptions, used by GenBank loader.
CObjectManager –.
CPluginManager<> –.
CSeqEdit_Cmd_AddAnnot –.
CSeqEdit_Cmd_AddDesc –.
CSeqEdit_Cmd_AddDescr –.
CSeqEdit_Cmd_AddId –.
CSeqEdit_Cmd_AttachAnnot –.
CSeqEdit_Cmd_AttachSeqEntry –.
CSeqEdit_Cmd_AttachSeq –.
CSeqEdit_Cmd_AttachSet –.
CSeqEdit_Cmd_ChangeSeqAttr –.
CSeqEdit_Cmd_ChangeSetAttr –.
CSeqEdit_Cmd_RemoveAnnot –.
CSeqEdit_Cmd_RemoveDesc –.
CSeqEdit_Cmd_RemoveId –.
CSeqEdit_Cmd_RemoveSeqEntry –.
CSeqEdit_Cmd_ReplaceAnnot –.
CSeqEdit_Cmd_ResetDescr –.
CSeqEdit_Cmd_ResetIds –.
CSeqEdit_Cmd_ResetSeqAttr –.
CSeqEdit_Cmd_ResetSeqEntry –.
CSeqEdit_Cmd_ResetSetAttr –.
CSeqEdit_Cmd_SetDescr –.
CSeqEdit_Id –.
Definition: SeqEdit_Id.hpp:66
const CAnnotObject_Info * Find(const CSeq_entry_Info &entry, const CAnnotName &name, const CSeq_feat &feat)
void Remove(TAnnotIndex index)
pair< TAnnotIndex, bool > Add(const CSeq_feat &new_obj)
bool Replace(TAnnotIndex index, const CSeq_feat &new_obj)
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
CConstRef< TObject > GetSeq_entrySkeleton(void) const
Definition: Seq_entry.hpp:56
CSeq_ext –.
Definition: Seq_ext.hpp:66
CSeq_hist –.
Definition: Seq_hist.hpp:66
const TBlobId & GetBlobId(void) const
Definition: tse_info.hpp:907
CTSE_Info & Assign(const CTSE_Lock &tse)
Definition: tse_info.cpp:232
CTSE_Info_Object * x_FindBioObject(const CBioObjectId &uniq_id) const
Definition: tse_info.cpp:463
bool IsLoaded(void) const
void SetLoaded(void)
definition of a Culling tree
Definition: ncbi_tree.hpp:100
virtual bool HasBlob(const string &blobid) const =0
list< CRef< CSeqEdit_Cmd > > TCommands
virtual void GetCommands(const string &blobid, TCommands &cmds) const =0
virtual bool FindSeqId(const CSeq_id_Handle &id, string &blobid) const =0
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
#define T(s)
Definition: common.h:230
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static const char * str(char *buf, int n)
Definition: stats.c:84
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
string ToString(void) const
Definition: blob_id.hpp:176
TLoader * GetLoader(void) const
Get pointer to the loader.
CBlobIdKey TBlobId
virtual TBlobId GetBlobIdFromString(const string &str) const
string GetName(void) const
CDataSource * GetDataSource(void) const
Definition: data_loader.cpp:92
virtual bool CanGetBlobById(void) const
virtual TTSE_Lock GetBlobById(const TBlobId &blob_id)
EChoice
main blob is blob with sequence all other blobs are external and contain external annotations
virtual TTSE_LockSet GetRecords(const CSeq_id_Handle &idh, EChoice choice)
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
virtual TTSE_LockSet GetDetailedRecords(const CSeq_id_Handle &idh, const SRequestDetails &details)
Request from a datasource using handles and ranges instead of seq-loc The TSEs loaded in this call wi...
EIsDefault
Flag defining if the data loader is included in the "default" group.
TRegisterInfo GetRegisterInfo(void)
static void RegisterInObjectManager(CObjectManager &om, CLoaderMaker_Base &loader_maker, CObjectManager::EIsDefault is_default, CObjectManager::TPriority priority)
Register the loader only if the name is not yet registered in the object manager.
Definition: data_loader.cpp:53
virtual TBlobVersion GetBlobVersion(const TBlobId &id)
virtual void GetChunks(const TChunkSet &chunks)
virtual TTSE_LockSet GetExternalRecords(const CBioseq_Info &bioseq)
Request from a datasource set of blobs with external annotations.
vector< TChunk > TChunkSet
virtual void GetChunk(TChunk chunk_info)
virtual TBlobId GetBlobId(const CSeq_id_Handle &idh)
CTSE_Lock TTSE_Lock
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
string GetParam(const string &driver_name, const TPluginManagerParamTree *params, const string &param_name, bool mandatory, const string &default_value) const
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
#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
const TTreeType * FindNode(const TKeyType &key, TNodeSearchMode sflag=eImmediateAndTop) const
Search for node.
Definition: ncbi_tree.hpp:970
@ e_Seq_data
seq-data field of seq-inst object
@ e_Topology
topology field of seq-inst object
@ e_Remove_seqentry
Remove a seq entry from bioseq-set.
@ e_Add_descr
Add descriptors to an object.
@ e_Attach_seqentry
Attach a seq entry to bioseq-set.
@ e_Add_desc
Add a descriptor ot an object.
@ e_not_set
No variant selected.
@ e_Attach_seq
Attach a bioseq to seq entry.
@ e_Remove_id
Remove a seq-id from bioseq.
@ e_Reset_seqentry
Detach an object from seq entry.
@ e_Attach_annot
Add a compelte annotation.
@ e_Reset_setattr
Reset bioseq-set's attribute.
@ e_Reset_ids
Reset ids field of bioseq.
@ e_Add_annot
Add an annotaion object.
@ e_Remove_desc
Remove a descripor from an object.
@ e_Set_descr
Set an objects's descriptors.
@ e_Remove_annot
Remove an annotation object.
@ e_Change_setattr
Change bioseq-set's attribure.
@ e_Attach_set
Attach a bioseq-set to seq entry.
@ e_Replace_annot
Replace an annotation object.
@ e_Add_id
Add a new seq-id to bioseq.
@ e_Reset_descr
Reset an objects's descriptors.
@ e_Reset_seqattr
Reset bioseq's attribute.
@ e_Change_seqattr
Change bioseq's attribure.
@ eWhat_strand
strand field of seq-inst object
@ eWhat_repr
repr field of seq-inst object
@ eWhat_mol
mol field of seq-inst object
@ eWhat_ext
extr field of seq-inst object
@ eWhat_length
length field of seq-inst object
@ eWhat_hist
hist field of seq-inst object
@ eWhat_fuzz
fuzz field of seq-inst object
@ eWhat_topology
topology field of seq-inst object
@ eWhat_seq_data
seq-data field of seq-inst object
@ e_Descr
If an annotation does not have any objects,.
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
ERepr
representation class
Definition: Seq_inst_.hpp:91
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
ETopology
topology of molecule
Definition: Seq_inst_.hpp:121
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
EStrand
strandedness in living organism
Definition: Seq_inst_.hpp:133
USING_SCOPE(objects)
CSeq_entry_Info & GetSeq_entry(CTSE_Info &tse, const CBioObjectId &id)
CBioseq_Info & GetBioseq(CTSE_Info &tse, const CBioObjectId &id)
CBioseq_set_Info & GetBioseq_set(CTSE_Info &tse, const CBioObjectId &id)
const string kDataLoader_Patcher_DriverName("dlpatcher")
void x_ApplyCmd(CTSE_Info &tse, const CSeqEdit_Cmd_AddId &cmd)
static CBioObjectId s_Convert(const CSeqEdit_Id &id)
static void x_MakeRemove(CTSE_Info &tse, const CSeq_entry_Info &info, const CAnnotName &name, const T &old_value)
void DataLoaders_Register_Patcher(void)
CBioseq_Base_Info & GetBase(CTSE_Info &tse, const CBioObjectId &id)
static void x_MakeReplace(CTSE_Info &tse, const CSeq_entry_Info &info, const CAnnotName &name, const T &old_value, const T &new_value)
void NCBI_EntryPoint_xloader_Patcher(CPluginManager< objects::CDataLoader >::TDriverInfoList &info_list, CPluginManager< objects::CDataLoader >::EEntryPointRequest method)
void NCBI_EntryPoint_DataLoader_Patcher(CPluginManager< CDataLoader >::TDriverInfoList &info_list, CPluginManager< CDataLoader >::EEntryPointRequest method)
const string kCFParam_DLP_EditsDBEngine
const string kCFParam_DLP_DataLoader
const string kCFParam_DLP_EditSaver
static MDB_envinfo info
Definition: mdb_load.c:37
Helper classes and templates to implement plugins.
CRef< objects::CObjectManager > om
CRef< CDataLoader > m_DataLoader
SRegisterLoaderInfo –.
#define _ASSERT
Modified on Fri Sep 20 14:58:19 2024 by modify_doxy.py rev. 669887