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

Go to the SVN repository for this file.

1 /* $Id: project_converters.cpp 39528 2017-10-05 15:27:37Z katargir $
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  * Authors: Mike DiCuccio
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbiobj.hpp>
34 
38 
42 
44 
45 #include <serial/iterator.hpp>
46 
49 
51 {
52  CRef<CSeq_annot> annot(new CSeq_annot());
53  annot->SetData().SetAlign()
54  .push_back(CRef<CSeq_align>(const_cast<CSeq_align*>(&align)));
55  return annot;
56 }
57 
59 {
60  CRef<CSeq_annot> annot(new CSeq_annot());
61  ITERATE (CSeq_align_set::Tdata, iter, align_set.Get()) {
63  (const_cast<CSeq_align*>(iter->GetPointer()));
64  annot->SetData().SetAlign().push_back(ref);
65  }
66  return annot;
67 }
68 
70  CScope& scope,
71  const CObject& obj,
74  ICanceled*);
75 
76 /// Seq-align --> ProjectItem
78  CScope& scope,
79  const CObject& obj,
82  ICanceled*)
83 {
84  const CSeq_align* align = dynamic_cast<const CSeq_align*>(&obj);
85  if (align) {
86  Convert_Seq_annot_ProjectItem(scope, *s_Align2Annot(*align), objs, flags, NULL);
87  }
88 }
89 
90 /// Seq-align-set --> ProjectItem
92  CScope& scope,
93  const CObject& obj,
94  CBasicRelation::TObjects& related,
96  ICanceled*)
97 {
98  const CSeq_align_set* align =
99  dynamic_cast<const CSeq_align_set*>(&obj);
100  if (align) {
102  (scope, *s_AlignSet2Annot(*align), related, flags, NULL);
103  }
104 }
105 
106 /// Seq-annot --> ProjectItem
108  CScope& scope,
109  const CObject& obj,
112  ICanceled*)
113 {
114  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*>(&obj);
115  if (annot) {
116  CRef<CProjectItem> item(new CProjectItem());
117  item->SetItem().SetAnnot(const_cast<CSeq_annot&>(*annot));
118  objs.push_back(CRelation::SObject(*item));
119  }
120 }
121 
122 /// Seq-entry --> ProjectItem
124  CScope& scope,
125  const CObject& obj,
128  ICanceled*)
129 {
130  const CSeq_entry* entry = dynamic_cast<const CSeq_entry*> (&obj);
131  if (entry) {
132  CRef<CProjectItem> item(new CProjectItem());
133  item->SetItem().SetEntry(const_cast<CSeq_entry&>(*entry));
134 
135  objs.push_back(CRelation::SObject(*item));
136  }
137 }
138 
139 /// Seq-id --> ProjectItem
141  CScope& scope,
142  const CObject& obj,
145  ICanceled*)
146 {
147  const CSeq_id* id = dynamic_cast<const CSeq_id*>(&obj);
148  if (id) {
149  CRef<CProjectItem> item(new CProjectItem());
150  item->SetItem().SetId(const_cast<CSeq_id&>(*id));
151  objs.push_back(CRelation::SObject(*item));
152  }
153 }
154 
155 /// Seq-submit --> ProjectItem
157  CScope& scope,
158  const CObject& obj,
161  ICanceled*)
162 {
163  const CSeq_submit* submit = dynamic_cast<const CSeq_submit*>(&obj);
164  if (submit) {
165  CRef<CProjectItem> item(new CProjectItem());
166  item->SetItem().SetSubmit(const_cast<CSeq_submit&>(*submit));
167  objs.push_back(CRelation::SObject(*item));
168  }
169 }
170 
171 /// Container objects:
172 /// CDocument
173 /// CGBProjectHandle
174 /// CProjectItem
175 
177  CScope& scope,
178  const CObject& obj,
181  ICanceled*)
182 {
183  const CGBProjectHandle* proj = dynamic_cast<const CGBProjectHandle*> (&obj);
184  if (proj) {
185  const CGBProjectHandle::TData& data = proj->GetData();
187  for ( ; iter; ++iter) {
188  objs.push_back(CRelation::SObject(*iter));
189  }
190  }
191 }
192 
194  CScope& scope,
195  const CObject& obj,
198  ICanceled*)
199 {
200  const CProjectItem* item = dynamic_cast<const CProjectItem*> (&obj);
201  if (item && item->GetObject()) {
202  objs.push_back(CRelation::SObject(*item->GetObject()));
203  }
204 }
205 
207  CScope& scope,
208  const CObject& obj,
211  ICanceled*)
212 {
213  const CProjectItem* item = dynamic_cast<const CProjectItem*> (&obj);
214  if (item) {
215  Convert_ProjectItem_Object(scope, obj, objs, flags, NULL);
216  return;
217  }
218  const CGBProjectHandle* proj = dynamic_cast<const CGBProjectHandle*> (&obj);
219  if (proj) {
220  const CGBProjectHandle::TData& data = proj->GetData();
222  for ( ; iter; ++iter)
223  Convert_ProjectItem_Object(scope, *iter, objs, flags, NULL);
224  return;
225  }
226 }
227 
228 
229 
230 
232 {
233  const char* m_Name;
238 };
239 
241  // Seq-align
242  { "Seq-align --> ProjectItem", Convert_Seq_align_ProjectItem,
243  CSeq_align::GetTypeInfo(), CProjectItem::GetTypeInfo() },
244  // Seq-align-set
245  { "Seq-align-set --> ProjectItem", Convert_Seq_align_set_ProjectItem,
246  CSeq_align_set::GetTypeInfo(), CProjectItem::GetTypeInfo() },
247  // Seq-annot
248  { "Seq-annot --> ProjectItem", Convert_Seq_annot_ProjectItem,
249  CSeq_annot::GetTypeInfo(), CProjectItem::GetTypeInfo() },
250  // Seq-entry
251  { "Seq-entry --> ProjectItem", Convert_Seq_entry_ProjectItem,
252  CSeq_entry::GetTypeInfo(), CProjectItem::GetTypeInfo() },
253  // Seq-id
254  { "Seq-id --> ProjectItem", Convert_Seq_id_ProjectItem,
255  CSeq_id::GetTypeInfo(), CProjectItem::GetTypeInfo() },
256  // Seq-submit
257  { "Seq-submit --> ProjectItem", Convert_SeqSubmit_ProjectItem,
258  CSeq_submit::GetTypeInfo(), CProjectItem::GetTypeInfo() }
259 };
260 
262 {
263  for (size_t i = 0;
264  i < sizeof(m_ConverterEntries)/sizeof(m_ConverterEntries[0]); ++i) {
266  (new CBasicRelation(m_ConverterEntries[i].m_Name,
267  m_ConverterEntries[i].m_FromType->GetName(),
271  }
272 
274  ( new CBasicRelation("CGBProjectHandle --> Object",
275  CGBProjectHandle::GetTypeInfo()->GetName(),
276  "Object", Convert_GBProject_Object));
277 
279  (new CBasicRelation("CProjectItem --> Object",
280  CProjectItem::GetTypeInfo()->GetName(),
281  "Object",
283 
285  (new CBasicRelation("Any Container --> Object",
286  "Any Container", "Object",
288 }
289 
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(* TFNConvert)(objects::CScope &scope, const CObject &obj, TObjects &related, TFlags flags, ICanceled *cancel)
Definition: relation.hpp:224
const CProjectFolder & GetData() const
retrieve our project's data, in the form of a project folder this may be a contrived entity,...
static void Register(CRelation *rel)
Definition: obj_convert.cpp:58
CObject –.
Definition: ncbiobj.hpp:180
const CSerialObject * GetObject() const
retrieve the object pointed to as a CObject*
vector< SObject > TObjects
Definition: relation.hpp:130
int TFlags
Definition: relation.hpp:65
CScope –.
Definition: scope.hpp:92
Definition: Seq_entry.hpp:56
Template class for iteration on objects of class C (non-medifiable version)
Definition: iterator.hpp:767
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
static uch flags
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
void SetItem(TItem &value)
Assign a value to Item data member.
list< CRef< CSeq_align > > Tdata
const Tdata & Get(void) const
Get the member data.
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
int i
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static void Convert_Container_Object(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
USING_SCOPE(objects)
static void Convert_Seq_align_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-align –> ProjectItem.
void init_project_converters()
static CRef< CSeq_annot > s_AlignSet2Annot(const CSeq_align_set &align_set)
static void Convert_GBProject_Object(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Container objects: CDocument CGBProjectHandle CProjectItem.
static void Convert_SeqSubmit_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-submit –> ProjectItem.
static void Convert_Seq_align_set_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &related, CBasicRelation::TFlags flags, ICanceled *)
Seq-align-set –> ProjectItem.
static void Convert_Seq_annot_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CRelation::TFlags flags, ICanceled *)
static void Convert_Seq_entry_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-entry –> ProjectItem.
static SConverterEntry m_ConverterEntries[]
static void Convert_Seq_id_ProjectItem(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
Seq-id –> ProjectItem.
static void Convert_ProjectItem_Object(CScope &scope, const CObject &obj, CBasicRelation::TObjects &objs, CBasicRelation::TFlags flags, ICanceled *)
static CRef< CSeq_annot > s_Align2Annot(const CSeq_align &align)
struct SObject provides an interface for defining what is returned from object conversion.
Definition: relation.hpp:71
CBasicRelation::TFNConvert m_pFnCvt
const CBasicRelation::SPropPair * m_Properties
const CTypeInfo * m_ToType
const CTypeInfo * m_FromType
Modified on Fri Sep 20 14:56:58 2024 by modify_doxy.py rev. 669887