NCBI C++ ToolKit
Cit_art_.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 Cit_art_.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/biblio/biblio.asn">biblio.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/biblio/biblio.def">biblio.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_BIBLIO_CIT_ART_BASE_HPP
42 #define OBJECTS_BIBLIO_CIT_ART_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
47 
48 #ifndef BEGIN_objects_SCOPE
49 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
50 # define END_objects_SCOPE END_SCOPE(objects)
51 #endif
52 BEGIN_objects_SCOPE // namespace ncbi::objects::
53 
54 
55 // forward declarations
56 class CArticleIdSet;
57 class CAuth_list;
58 class CCit_book;
59 class CCit_jour;
60 class CCit_proc;
61 class CTitle;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_Biblio
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 /// Citation Types
74 /// article in journal or book
75 ///
76 /// CCit_art_Base --
77 ///
78 
80 {
82 public:
83  // constructor
84  CCit_art_Base(void);
85  // destructor
86  virtual ~CCit_art_Base(void);
87 
88  // type info
90 
91  /////////////////////////////////////////////////////////////////////////////
92  /// journal or book
93  ///
94  /// C_From --
95  ///
96 
98  {
100  public:
101  // constructor
102  C_From(void);
103  // destructor
104  ~C_From(void);
105 
106  // type info
108 
109 
110  /// Choice variants.
111  enum E_Choice {
112  e_not_set = 0, ///< No variant selected
115  e_Proc
116  };
117  /// Maximum+1 value of the choice variant enumerator.
119  e_MaxChoice = 4 ///< == e_Proc+1
120  };
121 
122  /// Reset the whole object
123  void Reset(void);
124 
125  /// Reset the selection (set it to e_not_set).
126  void ResetSelection(void);
127 
128  /// Which variant is currently selected.
129  ///
130  /// @return
131  /// Choice state enumerator.
132  E_Choice Which(void) const;
133 
134  /// Verify selection, throw exception if it differs from the expected.
135  ///
136  /// @param index
137  /// Expected selection.
138  void CheckSelected(E_Choice index) const;
139 
140  /// Throw 'InvalidSelection' exception.
141  ///
142  /// @param index
143  /// Expected selection.
144  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
145 
146  /// Retrieve selection name (for diagnostic purposes).
147  ///
148  /// @param index
149  /// One of possible selection states.
150  /// @return
151  /// Name string.
152  static string SelectionName(E_Choice index);
153 
154  /// Select the requested variant if needed.
155  ///
156  /// @param index
157  /// New selection state.
158  /// @param reset
159  /// Flag that defines the resetting of the variant data. The data will
160  /// be reset if either the current selection differs from the new one,
161  /// or the flag is set to eDoResetVariant.
163  /// Select the requested variant if needed,
164  /// allocating CObject variants from memory pool.
165  void Select(E_Choice index,
166  EResetVariant reset,
167  CObjectMemoryPool* pool);
168 
169  // types
171  typedef CCit_book TBook;
172  typedef CCit_proc TProc;
173 
174  // getters
175  // setters
176 
177 
178  /// Check if variant Journal is selected.
179  ///
180  /// Journal type is defined as 'typedef CCit_jour TJournal'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsJournal(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TJournal& GetJournal(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TJournal& SetJournal(void);
197  /// Select the variant and set its data.
198  ///
199  /// @param value
200  /// Reference to the data.
201  void SetJournal(TJournal& value);
202 
203 
204  /// Check if variant Book is selected.
205  ///
206  /// Book type is defined as 'typedef CCit_book TBook'.
207  /// @return
208  /// - true, if the variant is selected.
209  /// - false, otherwise.
210  bool IsBook(void) const;
211 
212  /// Get the variant data.
213  ///
214  /// @return
215  /// Reference to the data.
216  const TBook& GetBook(void) const;
217 
218  /// Select the variant.
219  ///
220  /// @return
221  /// Reference to the variant data.
222  TBook& SetBook(void);
223  /// Select the variant and set its data.
224  ///
225  /// @param value
226  /// Reference to the data.
227  void SetBook(TBook& value);
228 
229 
230  /// Check if variant Proc is selected.
231  ///
232  /// Proc type is defined as 'typedef CCit_proc TProc'.
233  /// @return
234  /// - true, if the variant is selected.
235  /// - false, otherwise.
236  bool IsProc(void) const;
237 
238  /// Get the variant data.
239  ///
240  /// @return
241  /// Reference to the data.
242  const TProc& GetProc(void) const;
243 
244  /// Select the variant.
245  ///
246  /// @return
247  /// Reference to the variant data.
248  TProc& SetProc(void);
249  /// Select the variant and set its data.
250  ///
251  /// @param value
252  /// Reference to the data.
253  void SetProc(TProc& value);
254 
255 
256  private:
257  // copy constructor and assignment operator
258  C_From(const C_From& );
260  // choice state
262  // helper methods
263  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
264 
265  static const char* const sm_SelectionNames[];
266  // data
267  NCBI_NS_NCBI::CSerialObject *m_object;
268  };
269  // types
270  typedef CTitle TTitle;
272  typedef C_From TFrom;
274 
275  // member index
276  enum class E_memberIndex {
277  e__allMandatory = 0,
278  e_title,
279  e_authors,
280  e_from,
281  e_ids
282  };
284 
285  // getters
286  // setters
287 
288  /// title of paper (ANSI requires)
289  /// Check if a value has been assigned to Title data member.
290  ///
291  /// Data member Title is optional;
292  /// its type is defined as 'typedef CTitle TTitle'
293  /// @return
294  /// - true, if a value has been assigned.
295  /// - false, otherwise.
296  bool IsSetTitle(void) const;
297 
298  /// Check if it is safe to call GetTitle method.
299  ///
300  /// @return
301  /// - true, if the data member is getatable.
302  /// - false, otherwise.
303  bool CanGetTitle(void) const;
304 
305  /// Reset Title data member.
306  void ResetTitle(void);
307 
308  /// Get the Title member data.
309  ///
310  /// @return
311  /// Reference to the member data.
312  const TTitle& GetTitle(void) const;
313 
314  /// Assign a value to Title data member.
315  ///
316  /// @param value
317  /// Reference to value.
318  void SetTitle(TTitle& value);
319 
320  /// Assign a value to Title data member.
321  ///
322  /// @return
323  /// Reference to the data value.
324  TTitle& SetTitle(void);
325 
326  /// authors (ANSI requires)
327  /// Check if a value has been assigned to Authors data member.
328  ///
329  /// Data member Authors is optional;
330  /// its type is defined as 'typedef CAuth_list TAuthors'
331  /// @return
332  /// - true, if a value has been assigned.
333  /// - false, otherwise.
334  bool IsSetAuthors(void) const;
335 
336  /// Check if it is safe to call GetAuthors method.
337  ///
338  /// @return
339  /// - true, if the data member is getatable.
340  /// - false, otherwise.
341  bool CanGetAuthors(void) const;
342 
343  /// Reset Authors data member.
344  void ResetAuthors(void);
345 
346  /// Get the Authors member data.
347  ///
348  /// @return
349  /// Reference to the member data.
350  const TAuthors& GetAuthors(void) const;
351 
352  /// Assign a value to Authors data member.
353  ///
354  /// @param value
355  /// Reference to value.
356  void SetAuthors(TAuthors& value);
357 
358  /// Assign a value to Authors data member.
359  ///
360  /// @return
361  /// Reference to the data value.
362  TAuthors& SetAuthors(void);
363 
364  /// Check if a value has been assigned to From data member.
365  ///
366  /// Data member From is mandatory;
367  /// its type is defined as 'typedef C_From TFrom'
368  /// @return
369  /// - true, if a value has been assigned.
370  /// - false, otherwise.
371  bool IsSetFrom(void) const;
372 
373  /// Check if it is safe to call GetFrom method.
374  ///
375  /// @return
376  /// - true, if the data member is getatable.
377  /// - false, otherwise.
378  bool CanGetFrom(void) const;
379 
380  /// Reset From data member.
381  void ResetFrom(void);
382 
383  /// Get the From member data.
384  ///
385  /// @return
386  /// Reference to the member data.
387  const TFrom& GetFrom(void) const;
388 
389  /// Assign a value to From data member.
390  ///
391  /// @param value
392  /// Reference to value.
393  void SetFrom(TFrom& value);
394 
395  /// Assign a value to From data member.
396  ///
397  /// @return
398  /// Reference to the data value.
399  TFrom& SetFrom(void);
400 
401  /// lots of ids
402  /// Check if a value has been assigned to Ids data member.
403  ///
404  /// Data member Ids is optional;
405  /// its type is defined as 'typedef CArticleIdSet TIds'
406  /// @return
407  /// - true, if a value has been assigned.
408  /// - false, otherwise.
409  bool IsSetIds(void) const;
410 
411  /// Check if it is safe to call GetIds method.
412  ///
413  /// @return
414  /// - true, if the data member is getatable.
415  /// - false, otherwise.
416  bool CanGetIds(void) const;
417 
418  /// Reset Ids data member.
419  void ResetIds(void);
420 
421  /// Get the Ids member data.
422  ///
423  /// @return
424  /// Reference to the member data.
425  const TIds& GetIds(void) const;
426 
427  /// Assign a value to Ids data member.
428  ///
429  /// @param value
430  /// Reference to value.
431  void SetIds(TIds& value);
432 
433  /// Assign a value to Ids data member.
434  ///
435  /// @return
436  /// Reference to the data value.
437  TIds& SetIds(void);
438 
439  /// Reset the whole object
440  virtual void Reset(void);
441 
442 
443 private:
444  // Prohibit copy constructor and assignment operator
447 
448  // data
449  Uint4 m_set_State[1];
454 };
455 
456 /* @} */
457 
458 
459 
460 
461 
462 ///////////////////////////////////////////////////////////
463 ///////////////////// inline methods //////////////////////
464 ///////////////////////////////////////////////////////////
465 inline
467 {
468  return m_choice;
469 }
470 
471 inline
473 {
474  if ( m_choice != index )
475  ThrowInvalidSelection(index);
476 }
477 
478 inline
479 void CCit_art_Base::C_From::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
480 {
481  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
482  if ( m_choice != e_not_set )
483  ResetSelection();
484  DoSelect(index, pool);
485  }
486 }
487 
488 inline
490 {
491  Select(index, reset, 0);
492 }
493 
494 inline
496 {
497  return m_choice == e_Journal;
498 }
499 
500 inline
502 {
503  return m_choice == e_Book;
504 }
505 
506 inline
508 {
509  return m_choice == e_Proc;
510 }
511 
512 inline
514 {
515  return m_Title.NotEmpty();
516 }
517 
518 inline
520 {
521  return IsSetTitle();
522 }
523 
524 inline
526 {
527  if (!CanGetTitle()) {
528  ThrowUnassigned(0);
529  }
530  return (*m_Title);
531 }
532 
533 inline
535 {
536  return m_Authors.NotEmpty();
537 }
538 
539 inline
541 {
542  return IsSetAuthors();
543 }
544 
545 inline
547 {
548  if (!CanGetAuthors()) {
549  ThrowUnassigned(1);
550  }
551  return (*m_Authors);
552 }
553 
554 inline
555 bool CCit_art_Base::IsSetFrom(void) const
556 {
557  return m_From.NotEmpty();
558 }
559 
560 inline
562 {
563  return true;
564 }
565 
566 inline
568 {
569  if ( !m_From ) {
570  const_cast<CCit_art_Base*>(this)->ResetFrom();
571  }
572  return (*m_From);
573 }
574 
575 inline
577 {
578  if ( !m_From ) {
579  ResetFrom();
580  }
581  return (*m_From);
582 }
583 
584 inline
585 bool CCit_art_Base::IsSetIds(void) const
586 {
587  return m_Ids.NotEmpty();
588 }
589 
590 inline
591 bool CCit_art_Base::CanGetIds(void) const
592 {
593  return IsSetIds();
594 }
595 
596 inline
598 {
599  if (!CanGetIds()) {
600  ThrowUnassigned(3);
601  }
602  return (*m_Ids);
603 }
604 
605 ///////////////////////////////////////////////////////////
606 ////////////////// end of inline methods //////////////////
607 ///////////////////////////////////////////////////////////
608 
609 
610 
611 
612 
613 END_objects_SCOPE // namespace ncbi::objects::
614 
616 
617 
618 #endif // OBJECTS_BIBLIO_CIT_ART_BASE_HPP
CArticleIdSet –.
@Auth_list.hpp User-defined methods of the data storage class.
Definition: Auth_list.hpp:57
journal or book
Definition: Cit_art_.hpp:98
Citation Types article in journal or book.
Definition: Cit_art_.hpp:80
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
Definition: Title.hpp:51
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
NCBI_XOBJUTIL_EXPORT string GetTitle(const CBioseq_Handle &hnd, TGetTitleFlags flags=0)
Definition: seqtitle.cpp:106
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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_BIBLIO_EXPORT
Definition: ncbi_export.h:312
bool IsProc(void) const
Check if variant Proc is selected.
Definition: Cit_art_.hpp:507
TFrom & SetFrom(void)
Assign a value to From data member.
Definition: Cit_art_.hpp:576
bool IsSetAuthors(void) const
authors (ANSI requires) Check if a value has been assigned to Authors data member.
Definition: Cit_art_.hpp:534
Tparent::CMemberIndex< E_memberIndex, 5 > TmemberIndex
Definition: Cit_art_.hpp:283
CSerialObject Tparent
Definition: Cit_art_.hpp:81
const TFrom & GetFrom(void) const
Get the From member data.
Definition: Cit_art_.hpp:567
E_Choice
Choice variants.
Definition: Cit_art_.hpp:111
CAuth_list TAuthors
Definition: Cit_art_.hpp:271
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Cit_art_.hpp:472
bool CanGetIds(void) const
Check if it is safe to call GetIds method.
Definition: Cit_art_.hpp:591
bool IsSetTitle(void) const
title of paper (ANSI requires) Check if a value has been assigned to Title data member.
Definition: Cit_art_.hpp:513
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TTitle & GetTitle(void) const
Get the Title member data.
Definition: Cit_art_.hpp:525
CRef< TTitle > m_Title
Definition: Cit_art_.hpp:450
void ResetFrom(void)
Reset From data member.
Definition: Cit_art_.cpp:239
C_From TFrom
Definition: Cit_art_.hpp:272
bool IsSetFrom(void) const
Check if a value has been assigned to From data member.
Definition: Cit_art_.hpp:555
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Cit_art_.hpp:267
CRef< TIds > m_Ids
Definition: Cit_art_.hpp:453
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Cit_art_.hpp:118
CRef< TFrom > m_From
Definition: Cit_art_.hpp:452
E_Choice Which(void) const
Which variant is currently selected.
Definition: Cit_art_.hpp:466
CCit_art_Base(const CCit_art_Base &)
DECLARE_INTERNAL_TYPE_INFO()
bool IsSetIds(void) const
lots of ids Check if a value has been assigned to Ids data member.
Definition: Cit_art_.hpp:585
C_From & operator=(const C_From &)
bool IsBook(void) const
Check if variant Book is selected.
Definition: Cit_art_.hpp:501
bool IsJournal(void) const
Check if variant Journal is selected.
Definition: Cit_art_.hpp:495
CCit_art_Base & operator=(const CCit_art_Base &)
C_From(const C_From &)
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
const TIds & GetIds(void) const
Get the Ids member data.
Definition: Cit_art_.hpp:597
CArticleIdSet TIds
Definition: Cit_art_.hpp:273
CRef< TAuthors > m_Authors
Definition: Cit_art_.hpp:451
bool CanGetAuthors(void) const
Check if it is safe to call GetAuthors method.
Definition: Cit_art_.hpp:540
const TAuthors & GetAuthors(void) const
Get the Authors member data.
Definition: Cit_art_.hpp:546
bool CanGetFrom(void) const
Check if it is safe to call GetFrom method.
Definition: Cit_art_.hpp:561
CTitle TTitle
Definition: Cit_art_.hpp:270
CSerialObject Tparent
Definition: Cit_art_.hpp:99
bool CanGetTitle(void) const
Check if it is safe to call GetTitle method.
Definition: Cit_art_.hpp:519
@ e_not_set
static bool IsJournal(const CPub &pub)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static bool GetIds(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
static void SetTitle(CRef< CSeq_entry > entry, string title)
Modified on Fri Jun 14 16:48:00 2024 by modify_doxy.py rev. 669887