NCBI C++ ToolKit
Pub_.hpp
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  */
27 
28 /// @file Pub_.hpp
29 /// Data storage class.
30 ///
31 /// This file was generated by application DATATOOL
32 /// using the following specifications:
33 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/pub/pub.asn">pub.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/pub/pub.def">pub.def</a>
36 ///
37 /// ATTENTION:
38 /// Don't edit or commit this file into CVS as this file will
39 /// be overridden (by DATATOOL) without warning!
40 
41 #ifndef OBJECTS_PUB_PUB_BASE_HPP
42 #define OBJECTS_PUB_PUB_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
49 
51 
52 #ifndef BEGIN_objects_SCOPE
53 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
54 # define END_objects_SCOPE END_SCOPE(objects)
55 #endif
56 BEGIN_objects_SCOPE // namespace ncbi::objects::
57 
58 
59 // forward declarations
60 class CCit_art;
61 class CCit_book;
62 class CCit_gen;
63 class CCit_jour;
64 class CCit_let;
65 class CCit_pat;
66 class CCit_proc;
67 class CCit_sub;
68 class CId_pat;
69 class CMedline_entry;
70 class CPub_equiv;
71 
72 
73 // generated classes
74 
75 
76 /** @addtogroup dataspec_NCBI_Pub
77  *
78  * @{
79  */
80 
81 /////////////////////////////////////////////////////////////////////////////
82 ///
83 /// CPub_Base --
84 ///
85 
87 {
89 public:
90  // constructor
91  CPub_Base(void);
92  // destructor
93  virtual ~CPub_Base(void);
94 
95  // type info
97 
98 
99  /// Choice variants.
100  enum E_Choice {
101  e_not_set = 0, ///< No variant selected
102  e_Gen, ///< general or generic unparsed
103  e_Sub, ///< submission
105  e_Muid, ///< medline uid
109  e_Proc, ///< proceedings of a meeting
111  e_Pat_id, ///< identify a patent
112  e_Man, ///< manuscript, thesis, or letter
113  e_Equiv, ///< to cite a variety of ways
114  e_Pmid ///< PubMedId
115  };
116  /// Maximum+1 value of the choice variant enumerator.
118  e_MaxChoice = 14 ///< == e_Pmid+1
119  };
120 
121  /// Reset the whole object
122  virtual void Reset(void);
123 
124  /// Reset the selection (set it to e_not_set).
125  virtual void ResetSelection(void);
126 
127  /// Which variant is currently selected.
128  ///
129  /// @return
130  /// Choice state enumerator.
131  E_Choice Which(void) const;
132 
133  /// Verify selection, throw exception if it differs from the expected.
134  ///
135  /// @param index
136  /// Expected selection.
137  void CheckSelected(E_Choice index) const;
138 
139  /// Throw 'InvalidSelection' exception.
140  ///
141  /// @param index
142  /// Expected selection.
143  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
144 
145  /// Retrieve selection name (for diagnostic purposes).
146  ///
147  /// @param index
148  /// One of possible selection states.
149  /// @return
150  /// Name string.
151  static string SelectionName(E_Choice index);
152 
153  /// Select the requested variant if needed.
154  ///
155  /// @param index
156  /// New selection state.
157  /// @param reset
158  /// Flag that defines the resetting of the variant data. The data will
159  /// be reset if either the current selection differs from the new one,
160  /// or the flag is set to eDoResetVariant.
162  /// Select the requested variant if needed,
163  /// allocating CObject variants from memory pool.
164  void Select(E_Choice index,
165  EResetVariant reset,
166  CObjectMemoryPool* pool);
167 
168  // types
169  typedef CCit_gen TGen;
170  typedef CCit_sub TSub;
175  typedef CCit_book TBook;
176  typedef CCit_proc TProc;
177  typedef CCit_pat TPatent;
178  typedef CId_pat TPat_id;
179  typedef CCit_let TMan;
181  typedef CPubMedId TPmid;
182 
183  // getters
184  // setters
185 
186 
187  /// Check if variant Gen is selected.
188  ///
189  /// Gen type is defined as 'typedef CCit_gen TGen'.
190  /// @return
191  /// - true, if the variant is selected.
192  /// - false, otherwise.
193  bool IsGen(void) const;
194 
195  /// Get the variant data.
196  ///
197  /// @return
198  /// Reference to the data.
199  const TGen& GetGen(void) const;
200 
201  /// Select the variant.
202  ///
203  /// @return
204  /// Reference to the variant data.
205  TGen& SetGen(void);
206  /// Select the variant and set its data.
207  ///
208  /// @param value
209  /// Reference to the data.
210  void SetGen(TGen& value);
211 
212 
213  /// Check if variant Sub is selected.
214  ///
215  /// Sub type is defined as 'typedef CCit_sub TSub'.
216  /// @return
217  /// - true, if the variant is selected.
218  /// - false, otherwise.
219  bool IsSub(void) const;
220 
221  /// Get the variant data.
222  ///
223  /// @return
224  /// Reference to the data.
225  const TSub& GetSub(void) const;
226 
227  /// Select the variant.
228  ///
229  /// @return
230  /// Reference to the variant data.
231  TSub& SetSub(void);
232  /// Select the variant and set its data.
233  ///
234  /// @param value
235  /// Reference to the data.
236  void SetSub(TSub& value);
237 
238 
239  /// Check if variant Medline is selected.
240  ///
241  /// Medline type is defined as 'typedef CMedline_entry TMedline'.
242  /// @return
243  /// - true, if the variant is selected.
244  /// - false, otherwise.
245  bool IsMedline(void) const;
246 
247  /// Get the variant data.
248  ///
249  /// @return
250  /// Reference to the data.
251  const TMedline& GetMedline(void) const;
252 
253  /// Select the variant.
254  ///
255  /// @return
256  /// Reference to the variant data.
257  TMedline& SetMedline(void);
258  /// Select the variant and set its data.
259  ///
260  /// @param value
261  /// Reference to the data.
262  void SetMedline(TMedline& value);
263 
264 
265  /// Check if variant Muid is selected.
266  ///
267  /// Muid type is defined as 'typedef NCBI_NS_NCBI::TEntrezId TMuid'.
268  /// @return
269  /// - true, if the variant is selected.
270  /// - false, otherwise.
271  bool IsMuid(void) const;
272 
273  /// Get the variant data.
274  ///
275  /// @return
276  /// Copy of the variant data.
277  TMuid GetMuid(void) const;
278 
279  /// Select the variant.
280  ///
281  /// @return
282  /// Reference to the variant data.
283  TMuid& SetMuid(void);
284 
285  /// Select the variant and set its data.
286  ///
287  /// @param value
288  /// Variant data.
289  void SetMuid(TMuid value);
290 
291 
292  /// Check if variant Article is selected.
293  ///
294  /// Article type is defined as 'typedef CCit_art TArticle'.
295  /// @return
296  /// - true, if the variant is selected.
297  /// - false, otherwise.
298  bool IsArticle(void) const;
299 
300  /// Get the variant data.
301  ///
302  /// @return
303  /// Reference to the data.
304  const TArticle& GetArticle(void) const;
305 
306  /// Select the variant.
307  ///
308  /// @return
309  /// Reference to the variant data.
310  TArticle& SetArticle(void);
311  /// Select the variant and set its data.
312  ///
313  /// @param value
314  /// Reference to the data.
315  void SetArticle(TArticle& value);
316 
317 
318  /// Check if variant Journal is selected.
319  ///
320  /// Journal type is defined as 'typedef CCit_jour TJournal'.
321  /// @return
322  /// - true, if the variant is selected.
323  /// - false, otherwise.
324  bool IsJournal(void) const;
325 
326  /// Get the variant data.
327  ///
328  /// @return
329  /// Reference to the data.
330  const TJournal& GetJournal(void) const;
331 
332  /// Select the variant.
333  ///
334  /// @return
335  /// Reference to the variant data.
336  TJournal& SetJournal(void);
337  /// Select the variant and set its data.
338  ///
339  /// @param value
340  /// Reference to the data.
341  void SetJournal(TJournal& value);
342 
343 
344  /// Check if variant Book is selected.
345  ///
346  /// Book type is defined as 'typedef CCit_book TBook'.
347  /// @return
348  /// - true, if the variant is selected.
349  /// - false, otherwise.
350  bool IsBook(void) const;
351 
352  /// Get the variant data.
353  ///
354  /// @return
355  /// Reference to the data.
356  const TBook& GetBook(void) const;
357 
358  /// Select the variant.
359  ///
360  /// @return
361  /// Reference to the variant data.
362  TBook& SetBook(void);
363  /// Select the variant and set its data.
364  ///
365  /// @param value
366  /// Reference to the data.
367  void SetBook(TBook& value);
368 
369 
370  /// Check if variant Proc is selected.
371  ///
372  /// Proc type is defined as 'typedef CCit_proc TProc'.
373  /// @return
374  /// - true, if the variant is selected.
375  /// - false, otherwise.
376  bool IsProc(void) const;
377 
378  /// Get the variant data.
379  ///
380  /// @return
381  /// Reference to the data.
382  const TProc& GetProc(void) const;
383 
384  /// Select the variant.
385  ///
386  /// @return
387  /// Reference to the variant data.
388  TProc& SetProc(void);
389  /// Select the variant and set its data.
390  ///
391  /// @param value
392  /// Reference to the data.
393  void SetProc(TProc& value);
394 
395 
396  /// Check if variant Patent is selected.
397  ///
398  /// Patent type is defined as 'typedef CCit_pat TPatent'.
399  /// @return
400  /// - true, if the variant is selected.
401  /// - false, otherwise.
402  bool IsPatent(void) const;
403 
404  /// Get the variant data.
405  ///
406  /// @return
407  /// Reference to the data.
408  const TPatent& GetPatent(void) const;
409 
410  /// Select the variant.
411  ///
412  /// @return
413  /// Reference to the variant data.
414  TPatent& SetPatent(void);
415  /// Select the variant and set its data.
416  ///
417  /// @param value
418  /// Reference to the data.
419  void SetPatent(TPatent& value);
420 
421 
422  /// Check if variant Pat_id is selected.
423  ///
424  /// Pat_id type is defined as 'typedef CId_pat TPat_id'.
425  /// @return
426  /// - true, if the variant is selected.
427  /// - false, otherwise.
428  bool IsPat_id(void) const;
429 
430  /// Get the variant data.
431  ///
432  /// @return
433  /// Reference to the data.
434  const TPat_id& GetPat_id(void) const;
435 
436  /// Select the variant.
437  ///
438  /// @return
439  /// Reference to the variant data.
440  TPat_id& SetPat_id(void);
441  /// Select the variant and set its data.
442  ///
443  /// @param value
444  /// Reference to the data.
445  void SetPat_id(TPat_id& value);
446 
447 
448  /// Check if variant Man is selected.
449  ///
450  /// Man type is defined as 'typedef CCit_let TMan'.
451  /// @return
452  /// - true, if the variant is selected.
453  /// - false, otherwise.
454  bool IsMan(void) const;
455 
456  /// Get the variant data.
457  ///
458  /// @return
459  /// Reference to the data.
460  const TMan& GetMan(void) const;
461 
462  /// Select the variant.
463  ///
464  /// @return
465  /// Reference to the variant data.
466  TMan& SetMan(void);
467  /// Select the variant and set its data.
468  ///
469  /// @param value
470  /// Reference to the data.
471  void SetMan(TMan& value);
472 
473 
474  /// Check if variant Equiv is selected.
475  ///
476  /// Equiv type is defined as 'typedef CPub_equiv TEquiv'.
477  /// @return
478  /// - true, if the variant is selected.
479  /// - false, otherwise.
480  bool IsEquiv(void) const;
481 
482  /// Get the variant data.
483  ///
484  /// @return
485  /// Reference to the data.
486  const TEquiv& GetEquiv(void) const;
487 
488  /// Select the variant.
489  ///
490  /// @return
491  /// Reference to the variant data.
492  TEquiv& SetEquiv(void);
493  /// Select the variant and set its data.
494  ///
495  /// @param value
496  /// Reference to the data.
497  void SetEquiv(TEquiv& value);
498 
499 
500  /// Check if variant Pmid is selected.
501  ///
502  /// Pmid type is defined as 'typedef CPubMedId TPmid'.
503  /// @return
504  /// - true, if the variant is selected.
505  /// - false, otherwise.
506  bool IsPmid(void) const;
507 
508  /// Get the variant data.
509  ///
510  /// @return
511  /// Reference to the data.
512  const TPmid& GetPmid(void) const;
513 
514  /// Select the variant.
515  ///
516  /// @return
517  /// Reference to the variant data.
518  TPmid& SetPmid(void);
519 
520  /// Select the variant and set its data.
521  ///
522  /// @param value
523  /// Variant data.
524  void SetPmid(const TPmid& value);
525 
526 
527 private:
528  // copy constructor and assignment operator
531  // choice state
533  // helper methods
534  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
535 
536  static const char* const sm_SelectionNames[];
537  // data
538  union {
540  NCBI_NS_NCBI::CUnionBuffer<TPmid> m_Pmid;
541  NCBI_NS_NCBI::CSerialObject *m_object;
542  };
543 };
544 
545 /* @} */
546 
547 
548 
549 
550 
551 ///////////////////////////////////////////////////////////
552 ///////////////////// inline methods //////////////////////
553 ///////////////////////////////////////////////////////////
554 inline
556 {
557  return m_choice;
558 }
559 
560 inline
562 {
563  if ( m_choice != index )
564  ThrowInvalidSelection(index);
565 }
566 
567 inline
568 void CPub_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
569 {
570  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
571  if ( m_choice != e_not_set )
572  ResetSelection();
573  DoSelect(index, pool);
574  }
575 }
576 
577 inline
578 void CPub_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
579 {
580  Select(index, reset, 0);
581 }
582 
583 inline
584 bool CPub_Base::IsGen(void) const
585 {
586  return m_choice == e_Gen;
587 }
588 
589 inline
590 bool CPub_Base::IsSub(void) const
591 {
592  return m_choice == e_Sub;
593 }
594 
595 inline
596 bool CPub_Base::IsMedline(void) const
597 {
598  return m_choice == e_Medline;
599 }
600 
601 inline
602 bool CPub_Base::IsMuid(void) const
603 {
604  return m_choice == e_Muid;
605 }
606 
607 inline
609 {
611  return reinterpret_cast<const TMuid&>(m_Muid);
612 }
613 
614 inline
616 {
618  return reinterpret_cast<TMuid&>(m_Muid);
619 }
620 
621 inline
623 {
625  reinterpret_cast<TMuid&>(m_Muid) = value;
626 }
627 
628 inline
629 bool CPub_Base::IsArticle(void) const
630 {
631  return m_choice == e_Article;
632 }
633 
634 inline
635 bool CPub_Base::IsJournal(void) const
636 {
637  return m_choice == e_Journal;
638 }
639 
640 inline
641 bool CPub_Base::IsBook(void) const
642 {
643  return m_choice == e_Book;
644 }
645 
646 inline
647 bool CPub_Base::IsProc(void) const
648 {
649  return m_choice == e_Proc;
650 }
651 
652 inline
653 bool CPub_Base::IsPatent(void) const
654 {
655  return m_choice == e_Patent;
656 }
657 
658 inline
659 bool CPub_Base::IsPat_id(void) const
660 {
661  return m_choice == e_Pat_id;
662 }
663 
664 inline
665 bool CPub_Base::IsMan(void) const
666 {
667  return m_choice == e_Man;
668 }
669 
670 inline
671 bool CPub_Base::IsEquiv(void) const
672 {
673  return m_choice == e_Equiv;
674 }
675 
676 inline
677 bool CPub_Base::IsPmid(void) const
678 {
679  return m_choice == e_Pmid;
680 }
681 
682 inline
684 {
686  return *m_Pmid;
687 }
688 
689 inline
691 {
693  return *m_Pmid;
694 }
695 
696 ///////////////////////////////////////////////////////////
697 ////////////////// end of inline methods //////////////////
698 ///////////////////////////////////////////////////////////
699 
700 
701 
702 
703 
704 END_objects_SCOPE // namespace ncbi::objects::
705 
707 
708 
709 #endif // OBJECTS_PUB_PUB_BASE_HPP
User-defined methods of the data storage class.
CPub_Base –.
Definition: Pub_.hpp:87
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
SStrictId_Entrez::TId TEntrezId
TEntrezId type for entrez ids which require the same strictness as TGi.
Definition: ncbimisc.hpp:1041
Int8 TIntId
Definition: ncbimisc.hpp:999
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_PUB_EXPORT
Definition: ncbi_export.h:720
bool IsPmid(void) const
Check if variant Pmid is selected.
Definition: Pub_.hpp:677
bool IsMedline(void) const
Check if variant Medline is selected.
Definition: Pub_.hpp:596
TPmid & SetPmid(void)
Select the variant.
Definition: Pub_.hpp:690
bool IsBook(void) const
Check if variant Book is selected.
Definition: Pub_.hpp:641
E_Choice
Choice variants.
Definition: Pub_.hpp:100
CCit_book TBook
Definition: Pub_.hpp:175
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Pub_.cpp:92
CCit_pat TPatent
Definition: Pub_.hpp:177
NCBI_NS_NCBI::CUnionBuffer< TPmid > m_Pmid
Definition: Pub_.hpp:540
TMuid & SetMuid(void)
Select the variant.
Definition: Pub_.hpp:615
const TPmid & GetPmid(void) const
Get the variant data.
Definition: Pub_.hpp:683
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
NCBI_NS_NCBI::TEntrezId TMuid
Definition: Pub_.hpp:172
bool IsPat_id(void) const
Check if variant Pat_id is selected.
Definition: Pub_.hpp:659
CMedline_entry TMedline
Definition: Pub_.hpp:171
CCit_sub TSub
Definition: Pub_.hpp:170
CCit_proc TProc
Definition: Pub_.hpp:176
bool IsJournal(void) const
Check if variant Journal is selected.
Definition: Pub_.hpp:635
DECLARE_INTERNAL_TYPE_INFO()
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Pub_.hpp:561
CCit_jour TJournal
Definition: Pub_.hpp:174
CPub_Base(const CPub_Base &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
CId_pat TPat_id
Definition: Pub_.hpp:178
NCBI_NS_NCBI::CUnionBuffer< TPmid > m_Pmid
Definition: Pub_.hpp:540
CCit_gen TGen
Definition: Pub_.hpp:169
E_Choice Which(void) const
Which variant is currently selected.
Definition: Pub_.hpp:555
bool IsEquiv(void) const
Check if variant Equiv is selected.
Definition: Pub_.hpp:671
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Pub_.cpp:162
bool IsProc(void) const
Check if variant Proc is selected.
Definition: Pub_.hpp:647
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Pub_.hpp:541
bool IsSub(void) const
Check if variant Sub is selected.
Definition: Pub_.hpp:590
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Pub_.cpp:67
CPub_Base & operator=(const CPub_Base &)
CPub_equiv TEquiv
Definition: Pub_.hpp:180
CSerialObject Tparent
Definition: Pub_.hpp:88
E_Choice m_choice
Definition: Pub_.hpp:532
ncbi::TIntId m_Muid
Definition: Pub_.hpp:539
TMuid GetMuid(void) const
Get the variant data.
Definition: Pub_.hpp:608
bool IsPatent(void) const
Check if variant Patent is selected.
Definition: Pub_.hpp:653
bool IsMuid(void) const
Check if variant Muid is selected.
Definition: Pub_.hpp:602
bool IsArticle(void) const
Check if variant Article is selected.
Definition: Pub_.hpp:629
bool IsGen(void) const
Check if variant Gen is selected.
Definition: Pub_.hpp:584
CCit_let TMan
Definition: Pub_.hpp:179
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Pub_.hpp:117
CPubMedId TPmid
Definition: Pub_.hpp:181
bool IsMan(void) const
Check if variant Man is selected.
Definition: Pub_.hpp:665
CCit_art TArticle
Definition: Pub_.hpp:173
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 bool IsJournal(const CPub &pub)
Modified on Mon Dec 11 02:36:41 2023 by modify_doxy.py rev. 669887