NCBI C++ ToolKit
Auth_list_.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 Auth_list_.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_AUTH_LIST_BASE_HPP
42 #define OBJECTS_BIBLIO_AUTH_LIST_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
49 #include <string>
50 #include <serial/delaybuf.hpp>
51 
53 
54 #ifndef BEGIN_objects_SCOPE
55 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
56 # define END_objects_SCOPE END_SCOPE(objects)
57 #endif
58 BEGIN_objects_SCOPE // namespace ncbi::objects::
59 
60 
61 // forward declarations
62 class CAffil;
63 class CAuthor;
64 
65 
66 // generated classes
67 
68 
69 /** @addtogroup dataspec_NCBI_Biblio
70  *
71  * @{
72  */
73 
74 /////////////////////////////////////////////////////////////////////////////
75 /// Authorship Group
76 ///
77 /// CAuth_list_Base --
78 ///
79 
81 {
83 public:
84  // constructor
85  CAuth_list_Base(void);
86  // destructor
87  virtual ~CAuth_list_Base(void);
88 
89  // type info
91 
92  /////////////////////////////////////////////////////////////////////////////
93  ///
94  /// C_Names --
95  ///
96 
98  {
100  public:
101  // constructor
102  C_Names(void);
103  // destructor
104  ~C_Names(void);
105 
106  // type info
108 
109 
110  /// Choice variants.
111  enum E_Choice {
112  e_not_set = 0, ///< No variant selected
113  e_Std, ///< full citations
114  e_Ml, ///< MEDLINE, semi-structured
115  e_Str ///< free for all
116  };
117  /// Maximum+1 value of the choice variant enumerator.
119  e_MaxChoice = 4 ///< == e_Str+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
170  typedef list< CRef< CAuthor > > TStd;
171  typedef list< string > TMl;
172  typedef list< string > TStr;
173 
174  // getters
175  // setters
176 
177 
178  /// Check if variant Std is selected.
179  ///
180  /// Std type is defined as 'typedef list< CRef< CAuthor > > TStd'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsStd(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TStd& GetStd(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TStd& SetStd(void);
197 
198 
199  /// Check if variant Ml is selected.
200  ///
201  /// Ml type is defined as 'typedef list< string > TMl'.
202  /// @return
203  /// - true, if the variant is selected.
204  /// - false, otherwise.
205  bool IsMl(void) const;
206 
207  /// Get the variant data.
208  ///
209  /// @return
210  /// Reference to the data.
211  const TMl& GetMl(void) const;
212 
213  /// Select the variant.
214  ///
215  /// @return
216  /// Reference to the variant data.
217  TMl& SetMl(void);
218 
219 
220  /// Check if variant Str is selected.
221  ///
222  /// Str type is defined as 'typedef list< string > TStr'.
223  /// @return
224  /// - true, if the variant is selected.
225  /// - false, otherwise.
226  bool IsStr(void) const;
227 
228  /// Get the variant data.
229  ///
230  /// @return
231  /// Reference to the data.
232  const TStr& GetStr(void) const;
233 
234  /// Select the variant.
235  ///
236  /// @return
237  /// Reference to the variant data.
238  TStr& SetStr(void);
239 
240 
241  private:
242  // copy constructor and assignment operator
243  C_Names(const C_Names& );
245  // choice state
247  // helper methods
248  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
249 
250  static const char* const sm_SelectionNames[];
251  // data
252  union {
253  NCBI_NS_NCBI::CUnionBuffer<TStd> m_Std;
254  NCBI_NS_NCBI::CUnionBuffer<TMl> m_Ml;
255  NCBI_NS_NCBI::CUnionBuffer<TStr> m_Str;
257  };
258  };
259  // types
260  typedef C_Names TNames;
261  typedef CAffil TAffil;
262 
263  // member index
264  enum class E_memberIndex {
265  e__allMandatory = 0,
266  e_names,
267  e_affil
268  };
270 
271  // getters
272  // setters
273 
274  /// Check if a value has been assigned to Names data member.
275  ///
276  /// Data member Names is mandatory;
277  /// its type is defined as 'typedef C_Names TNames'
278  /// @return
279  /// - true, if a value has been assigned.
280  /// - false, otherwise.
281  bool IsSetNames(void) const;
282 
283  /// Check if it is safe to call GetNames method.
284  ///
285  /// @return
286  /// - true, if the data member is getatable.
287  /// - false, otherwise.
288  bool CanGetNames(void) const;
289 
290  /// Reset Names data member.
291  void ResetNames(void);
292 
293  /// Get the Names member data.
294  ///
295  /// @return
296  /// Reference to the member data.
297  const TNames& GetNames(void) const;
298 
299  /// Assign a value to Names data member.
300  ///
301  /// @param value
302  /// Reference to value.
303  void SetNames(TNames& value);
304 
305  /// Assign a value to Names data member.
306  ///
307  /// @return
308  /// Reference to the data value.
309  TNames& SetNames(void);
310 
311  /// author affiliation
312  /// Check if a value has been assigned to Affil data member.
313  ///
314  /// Data member Affil is optional;
315  /// its type is defined as 'typedef CAffil TAffil'
316  /// @return
317  /// - true, if a value has been assigned.
318  /// - false, otherwise.
319  bool IsSetAffil(void) const;
320 
321  /// Check if it is safe to call GetAffil method.
322  ///
323  /// @return
324  /// - true, if the data member is getatable.
325  /// - false, otherwise.
326  bool CanGetAffil(void) const;
327 
328  /// Reset Affil data member.
329  void ResetAffil(void);
330 
331  /// Get the Affil member data.
332  ///
333  /// @return
334  /// Reference to the member data.
335  const TAffil& GetAffil(void) const;
336 
337  /// Assign a value to Affil data member.
338  ///
339  /// @param value
340  /// Reference to value.
341  void SetAffil(TAffil& value);
342 
343  /// Assign a value to Affil data member.
344  ///
345  /// @return
346  /// Reference to the data value.
347  TAffil& SetAffil(void);
348 
349  /// Reset the whole object
350  virtual void Reset(void);
351 
352 
353 private:
354  // Prohibit copy constructor and assignment operator
357 
358  // data
359  Uint4 m_set_State[1];
360  mutable NCBI_NS_NCBI::CDelayBuffer m_delay_Names;
363 };
364 
365 /* @} */
366 
367 
368 
369 
370 
371 ///////////////////////////////////////////////////////////
372 ///////////////////// inline methods //////////////////////
373 ///////////////////////////////////////////////////////////
374 inline
376 {
377  return m_choice;
378 }
379 
380 inline
382 {
383  if ( m_choice != index )
384  ThrowInvalidSelection(index);
385 }
386 
387 inline
388 void CAuth_list_Base::C_Names::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
389 {
390  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
391  if ( m_choice != e_not_set )
392  ResetSelection();
393  DoSelect(index, pool);
394  }
395 }
396 
397 inline
399 {
400  Select(index, reset, 0);
401 }
402 
403 inline
405 {
406  return m_choice == e_Std;
407 }
408 
409 inline
411 {
412  CheckSelected(e_Std);
413  return *m_Std;
414 }
415 
416 inline
418 {
419  Select(e_Std, NCBI_NS_NCBI::eDoNotResetVariant);
420  return *m_Std;
421 }
422 
423 inline
425 {
426  return m_choice == e_Ml;
427 }
428 
429 inline
431 {
432  CheckSelected(e_Ml);
433  return *m_Ml;
434 }
435 
436 inline
438 {
439  Select(e_Ml, NCBI_NS_NCBI::eDoNotResetVariant);
440  return *m_Ml;
441 }
442 
443 inline
445 {
446  return m_choice == e_Str;
447 }
448 
449 inline
451 {
452  CheckSelected(e_Str);
453  return *m_Str;
454 }
455 
456 inline
458 {
459  Select(e_Str, NCBI_NS_NCBI::eDoNotResetVariant);
460  return *m_Str;
461 }
462 
463 inline
465 {
466  if ( m_delay_Names )
467  return true;
468  return m_Names.NotEmpty();
469 }
470 
471 inline
473 {
474  return true;
475 }
476 
477 inline
479 {
480  m_delay_Names.Update();
481  if ( !m_Names ) {
482  const_cast<CAuth_list_Base*>(this)->ResetNames();
483  }
484  return (*m_Names);
485 }
486 
487 inline
489 {
490  m_delay_Names.Update();
491  if ( !m_Names ) {
492  ResetNames();
493  }
494  return (*m_Names);
495 }
496 
497 inline
499 {
500  return m_Affil.NotEmpty();
501 }
502 
503 inline
505 {
506  return IsSetAffil();
507 }
508 
509 inline
511 {
512  if (!CanGetAffil()) {
513  ThrowUnassigned(1);
514  }
515  return (*m_Affil);
516 }
517 
518 ///////////////////////////////////////////////////////////
519 ////////////////// end of inline methods //////////////////
520 ///////////////////////////////////////////////////////////
521 
522 
523 
524 
525 
526 END_objects_SCOPE // namespace ncbi::objects::
527 
529 
530 
531 #endif // OBJECTS_BIBLIO_AUTH_LIST_BASE_HPP
@Affil.hpp User-defined methods of the data storage class.
Definition: Affil.hpp:56
Authorship Group.
Definition: Auth_list_.hpp:81
CAuthor –.
Definition: Author.hpp:59
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
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
C_Names & operator=(const C_Names &)
bool CanGetAffil(void) const
Check if it is safe to call GetAffil method.
Definition: Auth_list_.hpp:504
TStd & SetStd(void)
Select the variant.
Definition: Auth_list_.hpp:417
TMl & SetMl(void)
Select the variant.
Definition: Auth_list_.hpp:437
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool IsSetAffil(void) const
author affiliation Check if a value has been assigned to Affil data member.
Definition: Auth_list_.hpp:498
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
C_Names(const C_Names &)
TNames & SetNames(void)
Assign a value to Names data member.
Definition: Auth_list_.hpp:488
CRef< TAffil > m_Affil
Definition: Auth_list_.hpp:362
const TAffil & GetAffil(void) const
Get the Affil member data.
Definition: Auth_list_.hpp:510
void ResetNames(void)
Reset Names data member.
Definition: Auth_list_.cpp:139
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
Definition: Auth_list_.hpp:269
NCBI_NS_NCBI::CUnionBuffer< TStr > m_Str
Definition: Auth_list_.hpp:255
CAuth_list_Base(const CAuth_list_Base &)
CRef< TNames > m_Names
Definition: Auth_list_.hpp:361
NCBI_NS_NCBI::CDelayBuffer m_delay_Names
Definition: Auth_list_.hpp:360
list< CRef< CAuthor > > TStd
Definition: Auth_list_.hpp:170
bool IsSetNames(void) const
Check if a value has been assigned to Names data member.
Definition: Auth_list_.hpp:464
bool CanGetNames(void) const
Check if it is safe to call GetNames method.
Definition: Auth_list_.hpp:472
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Auth_list_.hpp:118
CAuth_list_Base & operator=(const CAuth_list_Base &)
const TStr & GetStr(void) const
Get the variant data.
Definition: Auth_list_.hpp:450
bool IsStr(void) const
Check if variant Str is selected.
Definition: Auth_list_.hpp:444
CSerialObject Tparent
Definition: Auth_list_.hpp:82
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Auth_list_.hpp:381
const TNames & GetNames(void) const
Get the Names member data.
Definition: Auth_list_.hpp:478
NCBI_NS_NCBI::CUnionBuffer< TMl > m_Ml
Definition: Auth_list_.hpp:254
bool IsMl(void) const
Check if variant Ml is selected.
Definition: Auth_list_.hpp:424
const TStd & GetStd(void) const
Get the variant data.
Definition: Auth_list_.hpp:410
const TMl & GetMl(void) const
Get the variant data.
Definition: Auth_list_.hpp:430
NCBI_NS_NCBI::CUnionBuffer< TStd > m_Std
Definition: Auth_list_.hpp:253
E_Choice Which(void) const
Which variant is currently selected.
Definition: Auth_list_.hpp:375
E_Choice
Choice variants.
Definition: Auth_list_.hpp:111
TStr & SetStr(void)
Select the variant.
Definition: Auth_list_.hpp:457
bool IsStd(void) const
Check if variant Std is selected.
Definition: Auth_list_.hpp:404
@ e_Ml
MEDLINE, semi-structured.
Definition: Auth_list_.hpp:114
@ e_Std
full citations
Definition: Auth_list_.hpp:113
@ e_not_set
Modified on Thu Mar 28 17:07:43 2024 by modify_doxy.py rev. 669887