NCBI C++ ToolKit
Pub_set_.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_set_.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_SET_BASE_HPP
42 #define OBJECTS_PUB_PUB_SET_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
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_jour;
63 class CCit_pat;
64 class CCit_proc;
65 class CMedline_entry;
66 class CPub;
67 
68 
69 // generated classes
70 
71 
72 /** @addtogroup dataspec_NCBI_Pub
73  *
74  * @{
75  */
76 
77 /////////////////////////////////////////////////////////////////////////////
78 ///
79 /// CPub_set_Base --
80 ///
81 
83 {
85 public:
86  // constructor
87  CPub_set_Base(void);
88  // destructor
89  virtual ~CPub_set_Base(void);
90 
91  // type info
93 
94 
95  /// Choice variants.
96  enum E_Choice {
97  e_not_set = 0, ///< No variant selected
103  e_Proc, ///< proceedings of a meeting
104  e_Patent
105  };
106  /// Maximum+1 value of the choice variant enumerator.
108  e_MaxChoice = 8 ///< == e_Patent+1
109  };
110 
111  /// Reset the whole object
112  virtual void Reset(void);
113 
114  /// Reset the selection (set it to e_not_set).
115  virtual void ResetSelection(void);
116 
117  /// Which variant is currently selected.
118  ///
119  /// @return
120  /// Choice state enumerator.
121  E_Choice Which(void) const;
122 
123  /// Verify selection, throw exception if it differs from the expected.
124  ///
125  /// @param index
126  /// Expected selection.
127  void CheckSelected(E_Choice index) const;
128 
129  /// Throw 'InvalidSelection' exception.
130  ///
131  /// @param index
132  /// Expected selection.
133  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
134 
135  /// Retrieve selection name (for diagnostic purposes).
136  ///
137  /// @param index
138  /// One of possible selection states.
139  /// @return
140  /// Name string.
141  static string SelectionName(E_Choice index);
142 
143  /// Select the requested variant if needed.
144  ///
145  /// @param index
146  /// New selection state.
147  /// @param reset
148  /// Flag that defines the resetting of the variant data. The data will
149  /// be reset if either the current selection differs from the new one,
150  /// or the flag is set to eDoResetVariant.
152  /// Select the requested variant if needed,
153  /// allocating CObject variants from memory pool.
154  void Select(E_Choice index,
155  EResetVariant reset,
156  CObjectMemoryPool* pool);
157 
158  // types
159  typedef list< CRef< CPub > > TPub;
160  typedef list< CRef< CMedline_entry > > TMedline;
161  typedef list< CRef< CCit_art > > TArticle;
162  typedef list< CRef< CCit_jour > > TJournal;
163  typedef list< CRef< CCit_book > > TBook;
164  typedef list< CRef< CCit_proc > > TProc;
165  typedef list< CRef< CCit_pat > > TPatent;
166 
167  // getters
168  // setters
169 
170 
171  /// Check if variant Pub is selected.
172  ///
173  /// Pub type is defined as 'typedef list< CRef< CPub > > TPub'.
174  /// @return
175  /// - true, if the variant is selected.
176  /// - false, otherwise.
177  bool IsPub(void) const;
178 
179  /// Get the variant data.
180  ///
181  /// @return
182  /// Reference to the data.
183  const TPub& GetPub(void) const;
184 
185  /// Select the variant.
186  ///
187  /// @return
188  /// Reference to the variant data.
189  TPub& SetPub(void);
190 
191 
192  /// Check if variant Medline is selected.
193  ///
194  /// Medline type is defined as 'typedef list< CRef< CMedline_entry > > TMedline'.
195  /// @return
196  /// - true, if the variant is selected.
197  /// - false, otherwise.
198  bool IsMedline(void) const;
199 
200  /// Get the variant data.
201  ///
202  /// @return
203  /// Reference to the data.
204  const TMedline& GetMedline(void) const;
205 
206  /// Select the variant.
207  ///
208  /// @return
209  /// Reference to the variant data.
210  TMedline& SetMedline(void);
211 
212 
213  /// Check if variant Article is selected.
214  ///
215  /// Article type is defined as 'typedef list< CRef< CCit_art > > TArticle'.
216  /// @return
217  /// - true, if the variant is selected.
218  /// - false, otherwise.
219  bool IsArticle(void) const;
220 
221  /// Get the variant data.
222  ///
223  /// @return
224  /// Reference to the data.
225  const TArticle& GetArticle(void) const;
226 
227  /// Select the variant.
228  ///
229  /// @return
230  /// Reference to the variant data.
231  TArticle& SetArticle(void);
232 
233 
234  /// Check if variant Journal is selected.
235  ///
236  /// Journal type is defined as 'typedef list< CRef< CCit_jour > > TJournal'.
237  /// @return
238  /// - true, if the variant is selected.
239  /// - false, otherwise.
240  bool IsJournal(void) const;
241 
242  /// Get the variant data.
243  ///
244  /// @return
245  /// Reference to the data.
246  const TJournal& GetJournal(void) const;
247 
248  /// Select the variant.
249  ///
250  /// @return
251  /// Reference to the variant data.
252  TJournal& SetJournal(void);
253 
254 
255  /// Check if variant Book is selected.
256  ///
257  /// Book type is defined as 'typedef list< CRef< CCit_book > > TBook'.
258  /// @return
259  /// - true, if the variant is selected.
260  /// - false, otherwise.
261  bool IsBook(void) const;
262 
263  /// Get the variant data.
264  ///
265  /// @return
266  /// Reference to the data.
267  const TBook& GetBook(void) const;
268 
269  /// Select the variant.
270  ///
271  /// @return
272  /// Reference to the variant data.
273  TBook& SetBook(void);
274 
275 
276  /// Check if variant Proc is selected.
277  ///
278  /// Proc type is defined as 'typedef list< CRef< CCit_proc > > TProc'.
279  /// @return
280  /// - true, if the variant is selected.
281  /// - false, otherwise.
282  bool IsProc(void) const;
283 
284  /// Get the variant data.
285  ///
286  /// @return
287  /// Reference to the data.
288  const TProc& GetProc(void) const;
289 
290  /// Select the variant.
291  ///
292  /// @return
293  /// Reference to the variant data.
294  TProc& SetProc(void);
295 
296 
297  /// Check if variant Patent is selected.
298  ///
299  /// Patent type is defined as 'typedef list< CRef< CCit_pat > > TPatent'.
300  /// @return
301  /// - true, if the variant is selected.
302  /// - false, otherwise.
303  bool IsPatent(void) const;
304 
305  /// Get the variant data.
306  ///
307  /// @return
308  /// Reference to the data.
309  const TPatent& GetPatent(void) const;
310 
311  /// Select the variant.
312  ///
313  /// @return
314  /// Reference to the variant data.
315  TPatent& SetPatent(void);
316 
317 
318 private:
319  // copy constructor and assignment operator
322  // choice state
324  // helper methods
325  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
326 
327  static const char* const sm_SelectionNames[];
328  // data
329  union {
330  NCBI_NS_NCBI::CUnionBuffer<TPub> m_Pub;
331  NCBI_NS_NCBI::CUnionBuffer<TMedline> m_Medline;
332  NCBI_NS_NCBI::CUnionBuffer<TArticle> m_Article;
333  NCBI_NS_NCBI::CUnionBuffer<TJournal> m_Journal;
334  NCBI_NS_NCBI::CUnionBuffer<TBook> m_Book;
335  NCBI_NS_NCBI::CUnionBuffer<TProc> m_Proc;
336  NCBI_NS_NCBI::CUnionBuffer<TPatent> m_Patent;
338  };
339 };
340 
341 /* @} */
342 
343 
344 
345 
346 
347 ///////////////////////////////////////////////////////////
348 ///////////////////// inline methods //////////////////////
349 ///////////////////////////////////////////////////////////
350 inline
352 {
353  return m_choice;
354 }
355 
356 inline
358 {
359  if ( m_choice != index )
360  ThrowInvalidSelection(index);
361 }
362 
363 inline
364 void CPub_set_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
365 {
366  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
367  if ( m_choice != e_not_set )
368  ResetSelection();
369  DoSelect(index, pool);
370  }
371 }
372 
373 inline
374 void CPub_set_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
375 {
376  Select(index, reset, 0);
377 }
378 
379 inline
380 bool CPub_set_Base::IsPub(void) const
381 {
382  return m_choice == e_Pub;
383 }
384 
385 inline
387 {
389  return *m_Pub;
390 }
391 
392 inline
394 {
396  return *m_Pub;
397 }
398 
399 inline
400 bool CPub_set_Base::IsMedline(void) const
401 {
402  return m_choice == e_Medline;
403 }
404 
405 inline
407 {
409  return *m_Medline;
410 }
411 
412 inline
414 {
416  return *m_Medline;
417 }
418 
419 inline
420 bool CPub_set_Base::IsArticle(void) const
421 {
422  return m_choice == e_Article;
423 }
424 
425 inline
427 {
429  return *m_Article;
430 }
431 
432 inline
434 {
436  return *m_Article;
437 }
438 
439 inline
440 bool CPub_set_Base::IsJournal(void) const
441 {
442  return m_choice == e_Journal;
443 }
444 
445 inline
447 {
449  return *m_Journal;
450 }
451 
452 inline
454 {
456  return *m_Journal;
457 }
458 
459 inline
460 bool CPub_set_Base::IsBook(void) const
461 {
462  return m_choice == e_Book;
463 }
464 
465 inline
467 {
469  return *m_Book;
470 }
471 
472 inline
474 {
476  return *m_Book;
477 }
478 
479 inline
480 bool CPub_set_Base::IsProc(void) const
481 {
482  return m_choice == e_Proc;
483 }
484 
485 inline
487 {
489  return *m_Proc;
490 }
491 
492 inline
494 {
496  return *m_Proc;
497 }
498 
499 inline
500 bool CPub_set_Base::IsPatent(void) const
501 {
502  return m_choice == e_Patent;
503 }
504 
505 inline
507 {
509  return *m_Patent;
510 }
511 
512 inline
514 {
516  return *m_Patent;
517 }
518 
519 ///////////////////////////////////////////////////////////
520 ////////////////// end of inline methods //////////////////
521 ///////////////////////////////////////////////////////////
522 
523 
524 
525 
526 
527 END_objects_SCOPE // namespace ncbi::objects::
528 
530 
531 
532 #endif // OBJECTS_PUB_PUB_SET_BASE_HPP
CPub_set_Base –.
Definition: Pub_set_.hpp:83
Definition: Pub.hpp:56
Base class for all serializable objects.
Definition: serialbase.hpp:150
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
void * m_dummy_pointer_for_alignment
Definition: Pub_set_.hpp:337
NCBI_NS_NCBI::CUnionBuffer< TPub > m_Pub
Definition: Pub_set_.hpp:330
NCBI_NS_NCBI::CUnionBuffer< TBook > m_Book
Definition: Pub_set_.hpp:334
NCBI_NS_NCBI::CUnionBuffer< TMedline > m_Medline
Definition: Pub_set_.hpp:331
E_Choice
Choice variants.
Definition: Pub_set_.hpp:96
bool IsArticle(void) const
Check if variant Article is selected.
Definition: Pub_set_.hpp:420
TMedline & SetMedline(void)
Select the variant.
Definition: Pub_set_.hpp:413
NCBI_NS_NCBI::CUnionBuffer< TPatent > m_Patent
Definition: Pub_set_.hpp:336
CPub_set_Base(const CPub_set_Base &)
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Pub_set_.cpp:139
E_Choice Which(void) const
Which variant is currently selected.
Definition: Pub_set_.hpp:351
DECLARE_INTERNAL_TYPE_INFO()
TProc & SetProc(void)
Select the variant.
Definition: Pub_set_.hpp:493
const TArticle & GetArticle(void) const
Get the variant data.
Definition: Pub_set_.hpp:426
const TBook & GetBook(void) const
Get the variant data.
Definition: Pub_set_.hpp:466
bool IsPatent(void) const
Check if variant Patent is selected.
Definition: Pub_set_.hpp:500
const TMedline & GetMedline(void) const
Get the variant data.
Definition: Pub_set_.hpp:406
TBook & SetBook(void)
Select the variant.
Definition: Pub_set_.hpp:473
list< CRef< CCit_jour > > TJournal
Definition: Pub_set_.hpp:162
list< CRef< CCit_proc > > TProc
Definition: Pub_set_.hpp:164
bool IsBook(void) const
Check if variant Book is selected.
Definition: Pub_set_.hpp:460
TArticle & SetArticle(void)
Select the variant.
Definition: Pub_set_.hpp:433
const TPub & GetPub(void) const
Get the variant data.
Definition: Pub_set_.hpp:386
NCBI_NS_NCBI::CUnionBuffer< TProc > m_Proc
Definition: Pub_set_.hpp:335
CPub_set_Base & operator=(const CPub_set_Base &)
bool IsProc(void) const
Check if variant Proc is selected.
Definition: Pub_set_.hpp:480
NCBI_NS_NCBI::CUnionBuffer< TPub > m_Pub
Definition: Pub_set_.hpp:330
NCBI_NS_NCBI::CUnionBuffer< TBook > m_Book
Definition: Pub_set_.hpp:334
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Pub_set_.cpp:93
const TJournal & GetJournal(void) const
Get the variant data.
Definition: Pub_set_.hpp:446
TJournal & SetJournal(void)
Select the variant.
Definition: Pub_set_.hpp:453
list< CRef< CPub > > TPub
Definition: Pub_set_.hpp:159
NCBI_NS_NCBI::CUnionBuffer< TJournal > m_Journal
Definition: Pub_set_.hpp:333
NCBI_NS_NCBI::CUnionBuffer< TJournal > m_Journal
Definition: Pub_set_.hpp:333
list< CRef< CCit_pat > > TPatent
Definition: Pub_set_.hpp:165
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Pub_set_.hpp:357
bool IsPub(void) const
Check if variant Pub is selected.
Definition: Pub_set_.hpp:380
bool IsMedline(void) const
Check if variant Medline is selected.
Definition: Pub_set_.hpp:400
NCBI_NS_NCBI::CUnionBuffer< TPatent > m_Patent
Definition: Pub_set_.hpp:336
TPub & SetPub(void)
Select the variant.
Definition: Pub_set_.hpp:393
TPatent & SetPatent(void)
Select the variant.
Definition: Pub_set_.hpp:513
const TPatent & GetPatent(void) const
Get the variant data.
Definition: Pub_set_.hpp:506
NCBI_NS_NCBI::CUnionBuffer< TArticle > m_Article
Definition: Pub_set_.hpp:332
bool IsJournal(void) const
Check if variant Journal is selected.
Definition: Pub_set_.hpp:440
NCBI_NS_NCBI::CUnionBuffer< TProc > m_Proc
Definition: Pub_set_.hpp:335
list< CRef< CCit_art > > TArticle
Definition: Pub_set_.hpp:161
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Pub_set_.hpp:107
list< CRef< CMedline_entry > > TMedline
Definition: Pub_set_.hpp:160
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CSerialObject Tparent
Definition: Pub_set_.hpp:84
E_Choice m_choice
Definition: Pub_set_.hpp:323
NCBI_NS_NCBI::CUnionBuffer< TMedline > m_Medline
Definition: Pub_set_.hpp:331
list< CRef< CCit_book > > TBook
Definition: Pub_set_.hpp:163
const TProc & GetProc(void) const
Get the variant data.
Definition: Pub_set_.hpp:486
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Pub_set_.cpp:63
NCBI_NS_NCBI::CUnionBuffer< TArticle > m_Article
Definition: Pub_set_.hpp:332
@ e_not_set
No variant selected.
Definition: Pub_set_.hpp:97
@ e_Proc
proceedings of a meeting
Definition: Pub_set_.hpp:103
@ e_not_set
static bool IsJournal(const CPub &pub)
Modified on Thu Feb 22 17:12:56 2024 by modify_doxy.py rev. 669887