NCBI C++ ToolKit
Field_type_.cpp
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  * File Description:
27  * This code was generated by application DATATOOL
28  * using the following specifications:
29  * 'macro.asn'.
30  *
31  * ATTENTION:
32  * Don't edit or commit this file into CVS as this file will
33  * be overridden (by DATATOOL) without warning!
34  * ===========================================================================
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 #include <serial/serialimpl.hpp>
40 
41 // generated includes
49 
50 BEGIN_objects_SCOPE // namespace ncbi::objects::
51 
52 
53 // generated classes
54 
56 {
57  if ( m_choice != e_not_set )
59 }
60 
62 {
63  switch ( m_choice ) {
64  case e_Source_qual:
65  case e_Feature_field:
66  case e_Rna_field:
67  case e_Molinfo_field:
69  m_object->RemoveReference();
70  break;
71  default:
72  break;
73  }
75 }
76 
77 void CField_type_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
78 {
79  switch ( index ) {
80  case e_Source_qual:
81  (m_object = new(pool) ncbi::objects::CSource_qual_choice())->AddReference();
82  break;
83  case e_Feature_field:
84  (m_object = new(pool) ncbi::objects::CFeature_field())->AddReference();
85  break;
86  case e_Rna_field:
87  (m_object = new(pool) ncbi::objects::CRna_qual())->AddReference();
88  break;
89  case e_Cds_gene_prot:
91  break;
92  case e_Molinfo_field:
93  (m_object = new(pool) ncbi::objects::CMolinfo_field())->AddReference();
94  break;
95  case e_Pub:
97  break;
99  (m_object = new(pool) ncbi::objects::CStructured_comment_field())->AddReference();
100  break;
101  case e_Misc:
103  break;
104  case e_Dblink:
106  break;
107  default:
108  break;
109  }
110  m_choice = index;
111 }
112 
113 const char* const CField_type_Base::sm_SelectionNames[] = {
114  "not set",
115  "source-qual",
116  "feature-field",
117  "rna-field",
118  "cds-gene-prot",
119  "molinfo-field",
120  "pub",
121  "struc-comment-field",
122  "misc",
123  "dblink"
124 };
125 
127 {
128  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
129 }
130 
132 {
133  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
134 }
135 
137 {
139  return *static_cast<const TSource_qual*>(m_object);
140 }
141 
143 {
145  return *static_cast<TSource_qual*>(m_object);
146 }
147 
149 {
150  TSource_qual* ptr = &value;
151  if ( m_choice != e_Source_qual || m_object != ptr ) {
152  ResetSelection();
153  (m_object = ptr)->AddReference();
155  }
156 }
157 
159 {
161  return *static_cast<const TFeature_field*>(m_object);
162 }
163 
165 {
167  return *static_cast<TFeature_field*>(m_object);
168 }
169 
171 {
172  TFeature_field* ptr = &value;
173  if ( m_choice != e_Feature_field || m_object != ptr ) {
174  ResetSelection();
175  (m_object = ptr)->AddReference();
177  }
178 }
179 
181 {
183  return *static_cast<const TRna_field*>(m_object);
184 }
185 
187 {
189  return *static_cast<TRna_field*>(m_object);
190 }
191 
193 {
194  TRna_field* ptr = &value;
195  if ( m_choice != e_Rna_field || m_object != ptr ) {
196  ResetSelection();
197  (m_object = ptr)->AddReference();
199  }
200 }
201 
203 {
205  return *static_cast<const TMolinfo_field*>(m_object);
206 }
207 
209 {
211  return *static_cast<TMolinfo_field*>(m_object);
212 }
213 
215 {
216  TMolinfo_field* ptr = &value;
217  if ( m_choice != e_Molinfo_field || m_object != ptr ) {
218  ResetSelection();
219  (m_object = ptr)->AddReference();
221  }
222 }
223 
225 {
227  return *static_cast<const TStruc_comment_field*>(m_object);
228 }
229 
231 {
233  return *static_cast<TStruc_comment_field*>(m_object);
234 }
235 
237 {
238  TStruc_comment_field* ptr = &value;
239  if ( m_choice != e_Struc_comment_field || m_object != ptr ) {
240  ResetSelection();
241  (m_object = ptr)->AddReference();
243  }
244 }
245 
246 // helper methods
247 
248 // type info
250 {
251  SET_CHOICE_MODULE("NCBI-Macro");
252  ADD_NAMED_REF_CHOICE_VARIANT("source-qual", m_object, CSource_qual_choice);
253  ADD_NAMED_REF_CHOICE_VARIANT("feature-field", m_object, CFeature_field);
254  ADD_NAMED_REF_CHOICE_VARIANT("rna-field", m_object, CRna_qual);
255  ADD_NAMED_ENUM_CHOICE_VARIANT("cds-gene-prot", m_Cds_gene_prot, ECDSGeneProt_field);
256  ADD_NAMED_REF_CHOICE_VARIANT("molinfo-field", m_object, CMolinfo_field);
258  ADD_NAMED_REF_CHOICE_VARIANT("struc-comment-field", m_object, CStructured_comment_field);
261  info->CodeVersion(22400);
262  info->DataSpec(ncbi::EDataSpec::eASN);
263 }
265 
266 // constructor
268  : m_choice(e_not_set)
269 {
270 }
271 
272 // destructor
274 {
275  Reset();
276 }
277 
278 
279 
280 END_objects_SCOPE // namespace ncbi::objects::
281 
283 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
BEGIN_NAMED_BASE_CHOICE_INFO("Field-type", CField_type)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CStructured_comment_field –.
string
Definition: cgiapp.hpp:687
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
#define ADD_NAMED_REF_CHOICE_VARIANT(MemberAlias, MemberName, ClassName)
Definition: serialimpl.hpp:400
#define ADD_NAMED_ENUM_CHOICE_VARIANT(MemberAlias, MemberName, EnumName)
Definition: serialimpl.hpp:391
#define END_CHOICE_INFO
Definition: serialimpl.hpp:506
#define SET_CHOICE_MODULE(ModuleName)
Definition: serialimpl.hpp:500
@ eDoNotResetVariant
Definition: serialbase.hpp:78
void AddReference(void) const
Add reference to object.
Definition: ncbiobj.hpp:489
#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.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
TRna_field & SetRna_field(void)
Select the variant.
E_Choice
Choice variants.
Definition: Field_type_.hpp:97
EPublication_field
publication fields
const TMolinfo_field & GetMolinfo_field(void) const
Get the variant data.
const TSource_qual & GetSource_qual(void) const
Get the variant data.
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.
NCBI_NS_NCBI::CSerialObject * m_object
const TRna_field & GetRna_field(void) const
Get the variant data.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Field_type_.cpp:61
TMolinfo_field & SetMolinfo_field(void)
Select the variant.
ECDSGeneProt_field
Access to ECDSGeneProt_field's attributes (values, names) as defined in spec.
TCds_gene_prot m_Cds_gene_prot
virtual void Reset(void)
Reset the whole object.
Definition: Field_type_.cpp:55
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Field_type_.cpp:77
static const char *const sm_SelectionNames[]
TSource_qual & SetSource_qual(void)
Select the variant.
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
@ e_not_set
No variant selected.
Definition: Field_type_.hpp:98
@ e_not_set
static MDB_envinfo info
Definition: mdb_load.c:37
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Apr 17 13:09:37 2024 by modify_doxy.py rev. 669887