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

Go to the SVN repository for this file.

1 /* $Id$
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  * File Description:
27  * This code was generated by application DATATOOL
28  * using the following specifications:
29  * 'pub.asn'.
30  *
31  * ATTENTION:
32  * Don't edit or commit this file into CVS as this file will
33  * be overridden (by DATATOOL) without warning!
34  * ===========================================================================
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 #include <serial/serialimpl.hpp>
40 
41 // generated includes
42 #include <objects/pub/Pub.hpp>
55 
56 BEGIN_objects_SCOPE // namespace ncbi::objects::
57 
58 
59 // generated classes
60 
61 void CPub_Base::Reset(void)
62 {
63  if ( m_choice != e_not_set )
65 }
66 
68 {
69  switch ( m_choice ) {
70  case e_Pmid:
71  m_Pmid.Destruct();
72  break;
73  case e_Gen:
74  case e_Sub:
75  case e_Medline:
76  case e_Article:
77  case e_Journal:
78  case e_Book:
79  case e_Proc:
80  case e_Patent:
81  case e_Pat_id:
82  case e_Man:
83  case e_Equiv:
84  m_object->RemoveReference();
85  break;
86  default:
87  break;
88  }
90 }
91 
92 void CPub_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
93 {
94  switch ( index ) {
95  case e_Gen:
96  (m_object = new(pool) ncbi::objects::CCit_gen())->AddReference();
97  break;
98  case e_Sub:
99  (m_object = new(pool) ncbi::objects::CCit_sub())->AddReference();
100  break;
101  case e_Medline:
102  (m_object = new(pool) ncbi::objects::CMedline_entry())->AddReference();
103  break;
104  case e_Muid:
105  m_Muid = 0;
106  break;
107  case e_Article:
108  (m_object = new(pool) ncbi::objects::CCit_art())->AddReference();
109  break;
110  case e_Journal:
111  (m_object = new(pool) ncbi::objects::CCit_jour())->AddReference();
112  break;
113  case e_Book:
114  (m_object = new(pool) ncbi::objects::CCit_book())->AddReference();
115  break;
116  case e_Proc:
117  (m_object = new(pool) ncbi::objects::CCit_proc())->AddReference();
118  break;
119  case e_Patent:
120  (m_object = new(pool) ncbi::objects::CCit_pat())->AddReference();
121  break;
122  case e_Pat_id:
123  (m_object = new(pool) ncbi::objects::CId_pat())->AddReference();
124  break;
125  case e_Man:
126  (m_object = new(pool) ncbi::objects::CCit_let())->AddReference();
127  break;
128  case e_Equiv:
129  (m_object = new(pool) ncbi::objects::CPub_equiv())->AddReference();
130  break;
131  case e_Pmid:
132  m_Pmid.Construct();
133  break;
134  default:
135  break;
136  }
137  m_choice = index;
138 }
139 
140 const char* const CPub_Base::sm_SelectionNames[] = {
141  "not set",
142  "gen",
143  "sub",
144  "medline",
145  "muid",
146  "article",
147  "journal",
148  "book",
149  "proc",
150  "patent",
151  "pat-id",
152  "man",
153  "equiv",
154  "pmid"
155 };
156 
158 {
159  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
160 }
161 
163 {
164  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
165 }
166 
168 {
170  return *static_cast<const TGen*>(m_object);
171 }
172 
174 {
176  return *static_cast<TGen*>(m_object);
177 }
178 
180 {
181  TGen* ptr = &value;
182  if ( m_choice != e_Gen || m_object != ptr ) {
183  ResetSelection();
184  (m_object = ptr)->AddReference();
185  m_choice = e_Gen;
186  }
187 }
188 
190 {
192  return *static_cast<const TSub*>(m_object);
193 }
194 
196 {
198  return *static_cast<TSub*>(m_object);
199 }
200 
202 {
203  TSub* ptr = &value;
204  if ( m_choice != e_Sub || m_object != ptr ) {
205  ResetSelection();
206  (m_object = ptr)->AddReference();
207  m_choice = e_Sub;
208  }
209 }
210 
212 {
214  return *static_cast<const TMedline*>(m_object);
215 }
216 
218 {
220  return *static_cast<TMedline*>(m_object);
221 }
222 
224 {
225  TMedline* ptr = &value;
226  if ( m_choice != e_Medline || m_object != ptr ) {
227  ResetSelection();
228  (m_object = ptr)->AddReference();
230  }
231 }
232 
234 {
236  return *static_cast<const TArticle*>(m_object);
237 }
238 
240 {
242  return *static_cast<TArticle*>(m_object);
243 }
244 
246 {
247  TArticle* ptr = &value;
248  if ( m_choice != e_Article || m_object != ptr ) {
249  ResetSelection();
250  (m_object = ptr)->AddReference();
252  }
253 }
254 
256 {
258  return *static_cast<const TJournal*>(m_object);
259 }
260 
262 {
264  return *static_cast<TJournal*>(m_object);
265 }
266 
268 {
269  TJournal* ptr = &value;
270  if ( m_choice != e_Journal || m_object != ptr ) {
271  ResetSelection();
272  (m_object = ptr)->AddReference();
274  }
275 }
276 
278 {
280  return *static_cast<const TBook*>(m_object);
281 }
282 
284 {
286  return *static_cast<TBook*>(m_object);
287 }
288 
290 {
291  TBook* ptr = &value;
292  if ( m_choice != e_Book || m_object != ptr ) {
293  ResetSelection();
294  (m_object = ptr)->AddReference();
295  m_choice = e_Book;
296  }
297 }
298 
300 {
302  return *static_cast<const TProc*>(m_object);
303 }
304 
306 {
308  return *static_cast<TProc*>(m_object);
309 }
310 
312 {
313  TProc* ptr = &value;
314  if ( m_choice != e_Proc || m_object != ptr ) {
315  ResetSelection();
316  (m_object = ptr)->AddReference();
317  m_choice = e_Proc;
318  }
319 }
320 
322 {
324  return *static_cast<const TPatent*>(m_object);
325 }
326 
328 {
330  return *static_cast<TPatent*>(m_object);
331 }
332 
334 {
335  TPatent* ptr = &value;
336  if ( m_choice != e_Patent || m_object != ptr ) {
337  ResetSelection();
338  (m_object = ptr)->AddReference();
339  m_choice = e_Patent;
340  }
341 }
342 
344 {
346  return *static_cast<const TPat_id*>(m_object);
347 }
348 
350 {
352  return *static_cast<TPat_id*>(m_object);
353 }
354 
356 {
357  TPat_id* ptr = &value;
358  if ( m_choice != e_Pat_id || m_object != ptr ) {
359  ResetSelection();
360  (m_object = ptr)->AddReference();
361  m_choice = e_Pat_id;
362  }
363 }
364 
366 {
368  return *static_cast<const TMan*>(m_object);
369 }
370 
372 {
374  return *static_cast<TMan*>(m_object);
375 }
376 
378 {
379  TMan* ptr = &value;
380  if ( m_choice != e_Man || m_object != ptr ) {
381  ResetSelection();
382  (m_object = ptr)->AddReference();
383  m_choice = e_Man;
384  }
385 }
386 
388 {
390  return *static_cast<const TEquiv*>(m_object);
391 }
392 
394 {
396  return *static_cast<TEquiv*>(m_object);
397 }
398 
400 {
401  TEquiv* ptr = &value;
402  if ( m_choice != e_Equiv || m_object != ptr ) {
403  ResetSelection();
404  (m_object = ptr)->AddReference();
405  m_choice = e_Equiv;
406  }
407 }
408 
410 {
412  *m_Pmid = value;
413 }
414 
415 // helper methods
416 
417 // type info
419 {
420  SET_CHOICE_MODULE("NCBI-Pub");
421  ADD_NAMED_REF_CHOICE_VARIANT("gen", m_object, CCit_gen);
422  ADD_NAMED_REF_CHOICE_VARIANT("sub", m_object, CCit_sub);
423  ADD_NAMED_REF_CHOICE_VARIANT("medline", m_object, CMedline_entry);
424  ADD_NAMED_STD_CHOICE_VARIANT("muid", m_Muid);
425  ADD_NAMED_REF_CHOICE_VARIANT("article", m_object, CCit_art);
426  ADD_NAMED_REF_CHOICE_VARIANT("journal", m_object, CCit_jour);
427  ADD_NAMED_REF_CHOICE_VARIANT("book", m_object, CCit_book);
428  ADD_NAMED_REF_CHOICE_VARIANT("proc", m_object, CCit_proc);
429  ADD_NAMED_REF_CHOICE_VARIANT("patent", m_object, CCit_pat);
430  ADD_NAMED_REF_CHOICE_VARIANT("pat-id", m_object, CId_pat);
431  ADD_NAMED_REF_CHOICE_VARIANT("man", m_object, CCit_let);
432  ADD_NAMED_REF_CHOICE_VARIANT("equiv", m_object, CPub_equiv);
433  ADD_NAMED_BUF_CHOICE_VARIANT("pmid", m_Pmid, CLASS, (CPubMedId));
434  info->CodeVersion(22400);
435  info->DataSpec(ncbi::EDataSpec::eASN);
436 }
438 
439 // constructor
441  : m_choice(e_not_set)
442 {
443 }
444 
445 // destructor
447 {
448  Reset();
449 }
450 
451 
452 
453 END_objects_SCOPE // namespace ncbi::objects::
454 
456 
BEGIN_NAMED_BASE_CHOICE_INFO("Pub", CPub)
Definition: Pub_.cpp:418
Definition: Pub.hpp:56
string
Definition: cgiapp.hpp:687
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
#define ADD_NAMED_REF_CHOICE_VARIANT(MemberAlias, MemberName, ClassName)
Definition: serialimpl.hpp:400
#define ADD_NAMED_STD_CHOICE_VARIANT(MemberAlias, MemberName)
Definition: serialimpl.hpp:388
#define END_CHOICE_INFO
Definition: serialimpl.hpp:506
#define SET_CHOICE_MODULE(ModuleName)
Definition: serialimpl.hpp:500
#define ADD_NAMED_BUF_CHOICE_VARIANT(MemberAlias, MemberName, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:385
@ eDoNotResetVariant
Definition: serialbase.hpp:78
void AddReference(void) const
Add reference to object.
Definition: ncbiobj.hpp:489
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TProc & SetProc(void)
Select the variant.
Definition: Pub_.cpp:305
TPmid & SetPmid(void)
Select the variant.
Definition: Pub_.hpp:690
E_Choice
Choice variants.
Definition: Pub_.hpp:100
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Pub_.hpp:541
const TMedline & GetMedline(void) const
Get the variant data.
Definition: Pub_.cpp:211
const TMan & GetMan(void) const
Get the variant data.
Definition: Pub_.cpp:365
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Pub_.cpp:92
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Pub_.cpp:157
NCBI_NS_NCBI::CUnionBuffer< TPmid > m_Pmid
Definition: Pub_.hpp:540
TBook & SetBook(void)
Select the variant.
Definition: Pub_.cpp:283
static const char *const sm_SelectionNames[]
Definition: Pub_.hpp:536
const TArticle & GetArticle(void) const
Get the variant data.
Definition: Pub_.cpp:233
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Pub_.cpp:255
const TSub & GetSub(void) const
Get the variant data.
Definition: Pub_.cpp:189
virtual ~CPub_Base(void)
Definition: Pub_.cpp:446
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Pub_.hpp:561
const TPatent & GetPatent(void) const
Get the variant data.
Definition: Pub_.cpp:321
const TProc & GetProc(void) const
Get the variant data.
Definition: Pub_.cpp:299
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TEquiv & SetEquiv(void)
Select the variant.
Definition: Pub_.cpp:393
const TEquiv & GetEquiv(void) const
Get the variant data.
Definition: Pub_.cpp:387
const TPat_id & GetPat_id(void) const
Get the variant data.
Definition: Pub_.cpp:343
TMan & SetMan(void)
Select the variant.
Definition: Pub_.cpp:371
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Pub_.cpp:162
CPub_Base(void)
Definition: Pub_.cpp:440
TSub & SetSub(void)
Select the variant.
Definition: Pub_.cpp:195
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Pub_.cpp:67
virtual void Reset(void)
Reset the whole object.
Definition: Pub_.cpp:61
TGen & SetGen(void)
Select the variant.
Definition: Pub_.cpp:173
E_Choice m_choice
Definition: Pub_.hpp:532
TMedline & SetMedline(void)
Select the variant.
Definition: Pub_.cpp:217
const TGen & GetGen(void) const
Get the variant data.
Definition: Pub_.cpp:167
TJournal & SetJournal(void)
Select the variant.
Definition: Pub_.cpp:261
TPatent & SetPatent(void)
Select the variant.
Definition: Pub_.cpp:327
TArticle & SetArticle(void)
Select the variant.
Definition: Pub_.cpp:239
TPat_id & SetPat_id(void)
Select the variant.
Definition: Pub_.cpp:349
const TBook & GetBook(void) const
Get the variant data.
Definition: Pub_.cpp:277
ncbi::TIntId m_Muid
Definition: Pub_.hpp:539
@ e_Pmid
PubMedId.
Definition: Pub_.hpp:114
@ e_Article
Definition: Pub_.hpp:106
@ e_Pat_id
identify a patent
Definition: Pub_.hpp:111
@ e_Book
Definition: Pub_.hpp:108
@ e_Medline
Definition: Pub_.hpp:104
@ e_Gen
general or generic unparsed
Definition: Pub_.hpp:102
@ e_not_set
No variant selected.
Definition: Pub_.hpp:101
@ e_Journal
Definition: Pub_.hpp:107
@ e_Patent
Definition: Pub_.hpp:110
@ e_Muid
medline uid
Definition: Pub_.hpp:105
@ e_Proc
proceedings of a meeting
Definition: Pub_.hpp:109
@ e_Equiv
to cite a variety of ways
Definition: Pub_.hpp:113
@ e_Man
manuscript, thesis, or letter
Definition: Pub_.hpp:112
@ e_Sub
submission
Definition: Pub_.hpp:103
@ e_not_set
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Tue May 21 10:56:19 2024 by modify_doxy.py rev. 669887