NCBI C++ ToolKit
Field_type_.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 Field_type_.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/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.def">macro.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_MACRO_FIELD_TYPE_BASE_HPP
42 #define OBJECTS_MACRO_FIELD_TYPE_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
52 
54 
55 #ifndef BEGIN_objects_SCOPE
56 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
57 # define END_objects_SCOPE END_SCOPE(objects)
58 #endif
59 BEGIN_objects_SCOPE // namespace ncbi::objects::
60 
61 
62 // forward declarations
63 class CFeature_field;
64 class CMolinfo_field;
65 class CRna_qual;
68 
69 
70 // generated classes
71 
72 
73 /** @addtogroup dataspec_NCBI_Macro
74  *
75  * @{
76  */
77 
78 /////////////////////////////////////////////////////////////////////////////
79 ///
80 /// CField_type_Base --
81 ///
82 
84 {
86 public:
87  // constructor
88  CField_type_Base(void);
89  // destructor
90  virtual ~CField_type_Base(void);
91 
92  // type info
94 
95 
96  /// Choice variants.
97  enum E_Choice {
98  e_not_set = 0, ///< No variant selected
107  e_Dblink
108  };
109  /// Maximum+1 value of the choice variant enumerator.
111  e_MaxChoice = 10 ///< == e_Dblink+1
112  };
113 
114  /// Reset the whole object
115  virtual void Reset(void);
116 
117  /// Reset the selection (set it to e_not_set).
118  virtual void ResetSelection(void);
119 
120  /// Which variant is currently selected.
121  ///
122  /// @return
123  /// Choice state enumerator.
124  E_Choice Which(void) const;
125 
126  /// Verify selection, throw exception if it differs from the expected.
127  ///
128  /// @param index
129  /// Expected selection.
130  void CheckSelected(E_Choice index) const;
131 
132  /// Throw 'InvalidSelection' exception.
133  ///
134  /// @param index
135  /// Expected selection.
136  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
137 
138  /// Retrieve selection name (for diagnostic purposes).
139  ///
140  /// @param index
141  /// One of possible selection states.
142  /// @return
143  /// Name string.
144  static string SelectionName(E_Choice index);
145 
146  /// Select the requested variant if needed.
147  ///
148  /// @param index
149  /// New selection state.
150  /// @param reset
151  /// Flag that defines the resetting of the variant data. The data will
152  /// be reset if either the current selection differs from the new one,
153  /// or the flag is set to eDoResetVariant.
155  /// Select the requested variant if needed,
156  /// allocating CObject variants from memory pool.
157  void Select(E_Choice index,
158  EResetVariant reset,
159  CObjectMemoryPool* pool);
160 
161  // types
171 
172  // getters
173  // setters
174 
175 
176  /// Check if variant Source_qual is selected.
177  ///
178  /// Source_qual type is defined as 'typedef CSource_qual_choice TSource_qual'.
179  /// @return
180  /// - true, if the variant is selected.
181  /// - false, otherwise.
182  bool IsSource_qual(void) const;
183 
184  /// Get the variant data.
185  ///
186  /// @return
187  /// Reference to the data.
188  const TSource_qual& GetSource_qual(void) const;
189 
190  /// Select the variant.
191  ///
192  /// @return
193  /// Reference to the variant data.
195  /// Select the variant and set its data.
196  ///
197  /// @param value
198  /// Reference to the data.
200 
201 
202  /// Check if variant Feature_field is selected.
203  ///
204  /// Feature_field type is defined as 'typedef CFeature_field TFeature_field'.
205  /// @return
206  /// - true, if the variant is selected.
207  /// - false, otherwise.
208  bool IsFeature_field(void) const;
209 
210  /// Get the variant data.
211  ///
212  /// @return
213  /// Reference to the data.
214  const TFeature_field& GetFeature_field(void) const;
215 
216  /// Select the variant.
217  ///
218  /// @return
219  /// Reference to the variant data.
221  /// Select the variant and set its data.
222  ///
223  /// @param value
224  /// Reference to the data.
226 
227 
228  /// Check if variant Rna_field is selected.
229  ///
230  /// Rna_field type is defined as 'typedef CRna_qual TRna_field'.
231  /// @return
232  /// - true, if the variant is selected.
233  /// - false, otherwise.
234  bool IsRna_field(void) const;
235 
236  /// Get the variant data.
237  ///
238  /// @return
239  /// Reference to the data.
240  const TRna_field& GetRna_field(void) const;
241 
242  /// Select the variant.
243  ///
244  /// @return
245  /// Reference to the variant data.
246  TRna_field& SetRna_field(void);
247  /// Select the variant and set its data.
248  ///
249  /// @param value
250  /// Reference to the data.
252 
253 
254  /// Check if variant Cds_gene_prot is selected.
255  ///
256  /// Cds_gene_prot type is defined as 'typedef ECDSGeneProt_field TCds_gene_prot'.
257  /// @return
258  /// - true, if the variant is selected.
259  /// - false, otherwise.
260  bool IsCds_gene_prot(void) const;
261 
262  /// Get the variant data.
263  ///
264  /// @return
265  /// Copy of the variant data.
266  TCds_gene_prot GetCds_gene_prot(void) const;
267 
268  /// Select the variant.
269  ///
270  /// @return
271  /// Reference to the variant data.
273 
274  /// Select the variant and set its data.
275  ///
276  /// @param value
277  /// Variant data.
279 
280 
281  /// Check if variant Molinfo_field is selected.
282  ///
283  /// Molinfo_field type is defined as 'typedef CMolinfo_field TMolinfo_field'.
284  /// @return
285  /// - true, if the variant is selected.
286  /// - false, otherwise.
287  bool IsMolinfo_field(void) const;
288 
289  /// Get the variant data.
290  ///
291  /// @return
292  /// Reference to the data.
293  const TMolinfo_field& GetMolinfo_field(void) const;
294 
295  /// Select the variant.
296  ///
297  /// @return
298  /// Reference to the variant data.
300  /// Select the variant and set its data.
301  ///
302  /// @param value
303  /// Reference to the data.
305 
306 
307  /// Check if variant Pub is selected.
308  ///
309  /// Pub type is defined as 'typedef EPublication_field TPub'.
310  /// @return
311  /// - true, if the variant is selected.
312  /// - false, otherwise.
313  bool IsPub(void) const;
314 
315  /// Get the variant data.
316  ///
317  /// @return
318  /// Copy of the variant data.
319  TPub GetPub(void) const;
320 
321  /// Select the variant.
322  ///
323  /// @return
324  /// Reference to the variant data.
325  TPub& SetPub(void);
326 
327  /// Select the variant and set its data.
328  ///
329  /// @param value
330  /// Variant data.
331  void SetPub(TPub value);
332 
333 
334  /// Check if variant Struc_comment_field is selected.
335  ///
336  /// Struc_comment_field type is defined as 'typedef CStructured_comment_field TStruc_comment_field'.
337  /// @return
338  /// - true, if the variant is selected.
339  /// - false, otherwise.
340  bool IsStruc_comment_field(void) const;
341 
342  /// Get the variant data.
343  ///
344  /// @return
345  /// Reference to the data.
346  const TStruc_comment_field& GetStruc_comment_field(void) const;
347 
348  /// Select the variant.
349  ///
350  /// @return
351  /// Reference to the variant data.
353  /// Select the variant and set its data.
354  ///
355  /// @param value
356  /// Reference to the data.
358 
359 
360  /// Check if variant Misc is selected.
361  ///
362  /// Misc type is defined as 'typedef EMisc_field TMisc'.
363  /// @return
364  /// - true, if the variant is selected.
365  /// - false, otherwise.
366  bool IsMisc(void) const;
367 
368  /// Get the variant data.
369  ///
370  /// @return
371  /// Copy of the variant data.
372  TMisc GetMisc(void) const;
373 
374  /// Select the variant.
375  ///
376  /// @return
377  /// Reference to the variant data.
378  TMisc& SetMisc(void);
379 
380  /// Select the variant and set its data.
381  ///
382  /// @param value
383  /// Variant data.
384  void SetMisc(TMisc value);
385 
386 
387  /// Check if variant Dblink is selected.
388  ///
389  /// Dblink type is defined as 'typedef EDBLink_field_type TDblink'.
390  /// @return
391  /// - true, if the variant is selected.
392  /// - false, otherwise.
393  bool IsDblink(void) const;
394 
395  /// Get the variant data.
396  ///
397  /// @return
398  /// Copy of the variant data.
399  TDblink GetDblink(void) const;
400 
401  /// Select the variant.
402  ///
403  /// @return
404  /// Reference to the variant data.
405  TDblink& SetDblink(void);
406 
407  /// Select the variant and set its data.
408  ///
409  /// @param value
410  /// Variant data.
411  void SetDblink(TDblink value);
412 
413 
414 private:
415  // copy constructor and assignment operator
418  // choice state
420  // helper methods
421  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
422 
423  static const char* const sm_SelectionNames[];
424  // data
425  union {
430  NCBI_NS_NCBI::CSerialObject *m_object;
431  };
432 };
433 
434 /* @} */
435 
436 
437 
438 
439 
440 ///////////////////////////////////////////////////////////
441 ///////////////////// inline methods //////////////////////
442 ///////////////////////////////////////////////////////////
443 inline
445 {
446  return m_choice;
447 }
448 
449 inline
451 {
452  if ( m_choice != index )
453  ThrowInvalidSelection(index);
454 }
455 
456 inline
457 void CField_type_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
458 {
459  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
460  if ( m_choice != e_not_set )
461  ResetSelection();
462  DoSelect(index, pool);
463  }
464 }
465 
466 inline
467 void CField_type_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
468 {
469  Select(index, reset, 0);
470 }
471 
472 inline
474 {
475  return m_choice == e_Source_qual;
476 }
477 
478 inline
480 {
481  return m_choice == e_Feature_field;
482 }
483 
484 inline
486 {
487  return m_choice == e_Rna_field;
488 }
489 
490 inline
492 {
493  return m_choice == e_Cds_gene_prot;
494 }
495 
496 inline
498 {
500  return m_Cds_gene_prot;
501 }
502 
503 inline
505 {
507  return m_Cds_gene_prot;
508 }
509 
510 inline
512 {
515 }
516 
517 inline
519 {
520  return m_choice == e_Molinfo_field;
521 }
522 
523 inline
524 bool CField_type_Base::IsPub(void) const
525 {
526  return m_choice == e_Pub;
527 }
528 
529 inline
531 {
533  return m_Pub;
534 }
535 
536 inline
538 {
540  return m_Pub;
541 }
542 
543 inline
545 {
547  m_Pub = value;
548 }
549 
550 inline
552 {
554 }
555 
556 inline
557 bool CField_type_Base::IsMisc(void) const
558 {
559  return m_choice == e_Misc;
560 }
561 
562 inline
564 {
566  return m_Misc;
567 }
568 
569 inline
571 {
573  return m_Misc;
574 }
575 
576 inline
578 {
580  m_Misc = value;
581 }
582 
583 inline
585 {
586  return m_choice == e_Dblink;
587 }
588 
589 inline
591 {
593  return m_Dblink;
594 }
595 
596 inline
598 {
600  return m_Dblink;
601 }
602 
603 inline
605 {
607  m_Dblink = value;
608 }
609 
610 ///////////////////////////////////////////////////////////
611 ////////////////// end of inline methods //////////////////
612 ///////////////////////////////////////////////////////////
613 
614 
615 
616 
617 
618 END_objects_SCOPE // namespace ncbi::objects::
619 
621 
622 
623 #endif // OBJECTS_MACRO_FIELD_TYPE_BASE_HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CField_type_Base –.
Definition: Field_type_.hpp:84
Base class for all serializable objects.
Definition: serialbase.hpp:150
CStructured_comment_field –.
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
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TFeature_field & SetFeature_field(void)
Select the variant.
bool IsPub(void) const
Check if variant Pub is selected.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsCds_gene_prot(void) const
Check if variant Cds_gene_prot is selected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
CFeature_field TFeature_field
bool IsStruc_comment_field(void) const
Check if variant Struc_comment_field is selected.
bool IsDblink(void) const
Check if variant Dblink is selected.
TCds_gene_prot GetCds_gene_prot(void) const
Get the variant data.
CRna_qual TRna_field
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
EDBLink_field_type TDblink
TRna_field & SetRna_field(void)
Select the variant.
bool IsMisc(void) const
Check if variant Misc is selected.
E_Choice Which(void) const
Which variant is currently selected.
CStructured_comment_field TStruc_comment_field
ECDSGeneProt_field TCds_gene_prot
CMolinfo_field TMolinfo_field
E_Choice
Choice variants.
Definition: Field_type_.hpp:97
EPublication_field TPub
CSource_qual_choice TSource_qual
EPublication_field
publication fields
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
const TMolinfo_field & GetMolinfo_field(void) const
Get the variant data.
const TSource_qual & GetSource_qual(void) const
Get the variant data.
TPub & SetPub(void)
Select the variant.
CSerialObject Tparent
Definition: Field_type_.hpp:85
const TStruc_comment_field & GetStruc_comment_field(void) const
Get the variant data.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TStruc_comment_field & SetStruc_comment_field(void)
Select the variant.
const TFeature_field & GetFeature_field(void) const
Get the variant data.
bool IsFeature_field(void) const
Check if variant Feature_field is selected.
CField_type_Base & operator=(const CField_type_Base &)
bool IsSource_qual(void) const
Check if variant Source_qual is selected.
const TRna_field & GetRna_field(void) const
Get the variant data.
TDblink & SetDblink(void)
Select the variant.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Field_type_.cpp:61
TCds_gene_prot & SetCds_gene_prot(void)
Select the variant.
TMolinfo_field & SetMolinfo_field(void)
Select the variant.
ECDSGeneProt_field
Access to ECDSGeneProt_field's attributes (values, names) as defined in spec.
bool IsRna_field(void) const
Check if variant Rna_field is selected.
CField_type_Base(const CField_type_Base &)
TMisc & SetMisc(void)
Select the variant.
NCBI_NS_NCBI::CSerialObject * m_object
TCds_gene_prot m_Cds_gene_prot
virtual void Reset(void)
Reset the whole object.
Definition: Field_type_.cpp:55
bool IsMolinfo_field(void) const
Check if variant Molinfo_field is selected.
EMisc_field TMisc
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Field_type_.cpp:77
TPub GetPub(void) const
Get the variant data.
static const char *const sm_SelectionNames[]
TSource_qual & SetSource_qual(void)
Select the variant.
TMisc GetMisc(void) const
Get the variant data.
TCds_gene_prot m_Cds_gene_prot
EMisc_field
misc fields these would not appear in pairs
Definition: Misc_field_.hpp:65
virtual ~CField_type_Base(void)
EDBLink_field_type
dblink fields
TDblink GetDblink(void) const
Get the variant data.
@ e_MaxChoice
== e_Dblink+1
@ e_not_set
No variant selected.
Definition: Field_type_.hpp:98
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sun May 05 05:19:26 2024 by modify_doxy.py rev. 669887