NCBI C++ ToolKit
Field_pair_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_pair_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_PAIR_TYPE_BASE_HPP
42 #define OBJECTS_MACRO_FIELD_PAIR_TYPE_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
57 class CDBLink_field_pair;
60 class CRna_qual_pair;
61 class CSource_qual_pair;
63 
64 
65 // generated classes
66 
67 
68 /** @addtogroup dataspec_NCBI_Macro
69  *
70  * @{
71  */
72 
73 /////////////////////////////////////////////////////////////////////////////
74 ///
75 /// CField_pair_type_Base --
76 ///
77 
79 {
81 public:
82  // constructor
84  // destructor
85  virtual ~CField_pair_type_Base(void);
86 
87  // type info
89 
90 
91  /// Choice variants.
92  enum E_Choice {
93  e_not_set = 0, ///< No variant selected
100  e_Dblink
101  };
102  /// Maximum+1 value of the choice variant enumerator.
104  e_MaxChoice = 8 ///< == e_Dblink+1
105  };
106 
107  /// Reset the whole object
108  virtual void Reset(void);
109 
110  /// Reset the selection (set it to e_not_set).
111  virtual void ResetSelection(void);
112 
113  /// Which variant is currently selected.
114  ///
115  /// @return
116  /// Choice state enumerator.
117  E_Choice Which(void) const;
118 
119  /// Verify selection, throw exception if it differs from the expected.
120  ///
121  /// @param index
122  /// Expected selection.
123  void CheckSelected(E_Choice index) const;
124 
125  /// Throw 'InvalidSelection' exception.
126  ///
127  /// @param index
128  /// Expected selection.
129  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
130 
131  /// Retrieve selection name (for diagnostic purposes).
132  ///
133  /// @param index
134  /// One of possible selection states.
135  /// @return
136  /// Name string.
137  static string SelectionName(E_Choice index);
138 
139  /// Select the requested variant if needed.
140  ///
141  /// @param index
142  /// New selection state.
143  /// @param reset
144  /// Flag that defines the resetting of the variant data. The data will
145  /// be reset if either the current selection differs from the new one,
146  /// or the flag is set to eDoResetVariant.
148  /// Select the requested variant if needed,
149  /// allocating CObject variants from memory pool.
150  void Select(E_Choice index,
151  EResetVariant reset,
152  CObjectMemoryPool* pool);
153 
154  // types
162 
163  // getters
164  // setters
165 
166 
167  /// Check if variant Source_qual is selected.
168  ///
169  /// Source_qual type is defined as 'typedef CSource_qual_pair TSource_qual'.
170  /// @return
171  /// - true, if the variant is selected.
172  /// - false, otherwise.
173  bool IsSource_qual(void) const;
174 
175  /// Get the variant data.
176  ///
177  /// @return
178  /// Reference to the data.
179  const TSource_qual& GetSource_qual(void) const;
180 
181  /// Select the variant.
182  ///
183  /// @return
184  /// Reference to the variant data.
186  /// Select the variant and set its data.
187  ///
188  /// @param value
189  /// Reference to the data.
191 
192 
193  /// Check if variant Feature_field is selected.
194  ///
195  /// Feature_field type is defined as 'typedef CFeature_field_pair TFeature_field'.
196  /// @return
197  /// - true, if the variant is selected.
198  /// - false, otherwise.
199  bool IsFeature_field(void) const;
200 
201  /// Get the variant data.
202  ///
203  /// @return
204  /// Reference to the data.
205  const TFeature_field& GetFeature_field(void) const;
206 
207  /// Select the variant.
208  ///
209  /// @return
210  /// Reference to the variant data.
212  /// Select the variant and set its data.
213  ///
214  /// @param value
215  /// Reference to the data.
217 
218 
219  /// Check if variant Rna_field is selected.
220  ///
221  /// Rna_field type is defined as 'typedef CRna_qual_pair TRna_field'.
222  /// @return
223  /// - true, if the variant is selected.
224  /// - false, otherwise.
225  bool IsRna_field(void) const;
226 
227  /// Get the variant data.
228  ///
229  /// @return
230  /// Reference to the data.
231  const TRna_field& GetRna_field(void) const;
232 
233  /// Select the variant.
234  ///
235  /// @return
236  /// Reference to the variant data.
237  TRna_field& SetRna_field(void);
238  /// Select the variant and set its data.
239  ///
240  /// @param value
241  /// Reference to the data.
243 
244 
245  /// Check if variant Cds_gene_prot is selected.
246  ///
247  /// Cds_gene_prot type is defined as 'typedef CCDSGeneProt_field_pair TCds_gene_prot'.
248  /// @return
249  /// - true, if the variant is selected.
250  /// - false, otherwise.
251  bool IsCds_gene_prot(void) const;
252 
253  /// Get the variant data.
254  ///
255  /// @return
256  /// Reference to the data.
257  const TCds_gene_prot& GetCds_gene_prot(void) const;
258 
259  /// Select the variant.
260  ///
261  /// @return
262  /// Reference to the variant data.
264  /// Select the variant and set its data.
265  ///
266  /// @param value
267  /// Reference to the data.
269 
270 
271  /// Check if variant Molinfo_field is selected.
272  ///
273  /// Molinfo_field type is defined as 'typedef CMolinfo_field_pair TMolinfo_field'.
274  /// @return
275  /// - true, if the variant is selected.
276  /// - false, otherwise.
277  bool IsMolinfo_field(void) const;
278 
279  /// Get the variant data.
280  ///
281  /// @return
282  /// Reference to the data.
283  const TMolinfo_field& GetMolinfo_field(void) const;
284 
285  /// Select the variant.
286  ///
287  /// @return
288  /// Reference to the variant data.
290  /// Select the variant and set its data.
291  ///
292  /// @param value
293  /// Reference to the data.
295 
296 
297  /// Check if variant Struc_comment_field is selected.
298  ///
299  /// Struc_comment_field type is defined as 'typedef CStructured_comment_field_pair TStruc_comment_field'.
300  /// @return
301  /// - true, if the variant is selected.
302  /// - false, otherwise.
303  bool IsStruc_comment_field(void) const;
304 
305  /// Get the variant data.
306  ///
307  /// @return
308  /// Reference to the data.
309  const TStruc_comment_field& GetStruc_comment_field(void) const;
310 
311  /// Select the variant.
312  ///
313  /// @return
314  /// Reference to the variant data.
316  /// Select the variant and set its data.
317  ///
318  /// @param value
319  /// Reference to the data.
321 
322 
323  /// Check if variant Dblink is selected.
324  ///
325  /// Dblink type is defined as 'typedef CDBLink_field_pair TDblink'.
326  /// @return
327  /// - true, if the variant is selected.
328  /// - false, otherwise.
329  bool IsDblink(void) const;
330 
331  /// Get the variant data.
332  ///
333  /// @return
334  /// Reference to the data.
335  const TDblink& GetDblink(void) const;
336 
337  /// Select the variant.
338  ///
339  /// @return
340  /// Reference to the variant data.
341  TDblink& SetDblink(void);
342  /// Select the variant and set its data.
343  ///
344  /// @param value
345  /// Reference to the data.
346  void SetDblink(TDblink& value);
347 
348 
349 private:
350  // copy constructor and assignment operator
353  // choice state
355  // helper methods
356  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
357 
358  static const char* const sm_SelectionNames[];
359  // data
360  NCBI_NS_NCBI::CSerialObject *m_object;
361 };
362 
363 /* @} */
364 
365 
366 
367 
368 
369 ///////////////////////////////////////////////////////////
370 ///////////////////// inline methods //////////////////////
371 ///////////////////////////////////////////////////////////
372 inline
374 {
375  return m_choice;
376 }
377 
378 inline
380 {
381  if ( m_choice != index )
382  ThrowInvalidSelection(index);
383 }
384 
385 inline
386 void CField_pair_type_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
387 {
388  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
389  if ( m_choice != e_not_set )
390  ResetSelection();
391  DoSelect(index, pool);
392  }
393 }
394 
395 inline
397 {
398  Select(index, reset, 0);
399 }
400 
401 inline
403 {
404  return m_choice == e_Source_qual;
405 }
406 
407 inline
409 {
410  return m_choice == e_Feature_field;
411 }
412 
413 inline
415 {
416  return m_choice == e_Rna_field;
417 }
418 
419 inline
421 {
422  return m_choice == e_Cds_gene_prot;
423 }
424 
425 inline
427 {
428  return m_choice == e_Molinfo_field;
429 }
430 
431 inline
433 {
435 }
436 
437 inline
439 {
440  return m_choice == e_Dblink;
441 }
442 
443 ///////////////////////////////////////////////////////////
444 ////////////////// end of inline methods //////////////////
445 ///////////////////////////////////////////////////////////
446 
447 
448 
449 
450 
451 END_objects_SCOPE // namespace ncbi::objects::
452 
454 
455 
456 #endif // OBJECTS_MACRO_FIELD_PAIR_TYPE_BASE_HPP
CCDSGeneProt_field_pair –.
CFeature_field_pair –.
CField_pair_type_Base –.
CMolinfo_field_pair –.
CRna_qual_pair –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSource_qual_pair –.
CStructured_comment_field_pair –.
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CDBLink_field_pair TDblink
bool IsSource_qual(void) const
Check if variant Source_qual is selected.
CMolinfo_field_pair TMolinfo_field
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
TMolinfo_field & SetMolinfo_field(void)
Select the variant.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
CFeature_field_pair TFeature_field
bool IsDblink(void) const
Check if variant Dblink is selected.
E_Choice Which(void) const
Which variant is currently selected.
bool IsFeature_field(void) const
Check if variant Feature_field is selected.
TStruc_comment_field & SetStruc_comment_field(void)
Select the variant.
CCDSGeneProt_field_pair TCds_gene_prot
static const char *const sm_SelectionNames[]
const TFeature_field & GetFeature_field(void) const
Get the variant data.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
const TStruc_comment_field & GetStruc_comment_field(void) const
Get the variant data.
virtual void Reset(void)
Reset the whole object.
NCBI_NS_NCBI::CSerialObject * m_object
bool IsMolinfo_field(void) const
Check if variant Molinfo_field is selected.
CField_pair_type_Base & operator=(const CField_pair_type_Base &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TDblink & GetDblink(void) const
Get the variant data.
bool IsRna_field(void) const
Check if variant Rna_field is selected.
virtual ~CField_pair_type_Base(void)
const TMolinfo_field & GetMolinfo_field(void) const
Get the variant data.
const TSource_qual & GetSource_qual(void) const
Get the variant data.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CSource_qual_pair TSource_qual
TDblink & SetDblink(void)
Select the variant.
bool IsStruc_comment_field(void) const
Check if variant Struc_comment_field is selected.
TSource_qual & SetSource_qual(void)
Select the variant.
TRna_field & SetRna_field(void)
Select the variant.
bool IsCds_gene_prot(void) const
Check if variant Cds_gene_prot is selected.
const TRna_field & GetRna_field(void) const
Get the variant data.
TFeature_field & SetFeature_field(void)
Select the variant.
E_Choice
Choice variants.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
const TCds_gene_prot & GetCds_gene_prot(void) const
Get the variant data.
TCds_gene_prot & SetCds_gene_prot(void)
Select the variant.
CStructured_comment_field_pair TStruc_comment_field
CField_pair_type_Base(const CField_pair_type_Base &)
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Apr 24 14:19:57 2024 by modify_doxy.py rev. 669887