NCBI C++ ToolKit
Action_choice_.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
52 
53 BEGIN_objects_SCOPE // namespace ncbi::objects::
54 
55 
56 // generated classes
57 
59 {
60  if ( m_choice != e_not_set )
62 }
63 
65 {
66  switch ( m_choice ) {
67  case e_Apply:
68  case e_Edit:
69  case e_Convert:
70  case e_Copy:
71  case e_Swap:
72  case e_Remove:
73  case e_Parse:
74  case e_Remove_outside:
75  m_object->RemoveReference();
76  break;
77  default:
78  break;
79  }
81 }
82 
83 void CAction_choice_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
84 {
85  switch ( index ) {
86  case e_Apply:
87  (m_object = new(pool) ncbi::objects::CApply_action())->AddReference();
88  break;
89  case e_Edit:
90  (m_object = new(pool) ncbi::objects::CEdit_action())->AddReference();
91  break;
92  case e_Convert:
93  (m_object = new(pool) ncbi::objects::CConvert_action())->AddReference();
94  break;
95  case e_Copy:
96  (m_object = new(pool) ncbi::objects::CCopy_action())->AddReference();
97  break;
98  case e_Swap:
99  (m_object = new(pool) ncbi::objects::CSwap_action())->AddReference();
100  break;
101  case e_Remove:
102  (m_object = new(pool) ncbi::objects::CRemove_action())->AddReference();
103  break;
104  case e_Parse:
105  (m_object = new(pool) ncbi::objects::CAECRParse_action())->AddReference();
106  break;
107  case e_Remove_outside:
108  (m_object = new(pool) ncbi::objects::CRemove_outside_action())->AddReference();
109  break;
110  default:
111  break;
112  }
113  m_choice = index;
114 }
115 
116 const char* const CAction_choice_Base::sm_SelectionNames[] = {
117  "not set",
118  "apply",
119  "edit",
120  "convert",
121  "copy",
122  "swap",
123  "remove",
124  "parse",
125  "remove-outside"
126 };
127 
129 {
130  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
131 }
132 
134 {
135  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
136 }
137 
139 {
141  return *static_cast<const TApply*>(m_object);
142 }
143 
145 {
147  return *static_cast<TApply*>(m_object);
148 }
149 
151 {
152  TApply* ptr = &value;
153  if ( m_choice != e_Apply || m_object != ptr ) {
154  ResetSelection();
155  (m_object = ptr)->AddReference();
156  m_choice = e_Apply;
157  }
158 }
159 
161 {
163  return *static_cast<const TEdit*>(m_object);
164 }
165 
167 {
169  return *static_cast<TEdit*>(m_object);
170 }
171 
173 {
174  TEdit* ptr = &value;
175  if ( m_choice != e_Edit || m_object != ptr ) {
176  ResetSelection();
177  (m_object = ptr)->AddReference();
178  m_choice = e_Edit;
179  }
180 }
181 
183 {
185  return *static_cast<const TConvert*>(m_object);
186 }
187 
189 {
191  return *static_cast<TConvert*>(m_object);
192 }
193 
195 {
196  TConvert* ptr = &value;
197  if ( m_choice != e_Convert || m_object != ptr ) {
198  ResetSelection();
199  (m_object = ptr)->AddReference();
201  }
202 }
203 
205 {
207  return *static_cast<const TCopy*>(m_object);
208 }
209 
211 {
213  return *static_cast<TCopy*>(m_object);
214 }
215 
217 {
218  TCopy* ptr = &value;
219  if ( m_choice != e_Copy || m_object != ptr ) {
220  ResetSelection();
221  (m_object = ptr)->AddReference();
222  m_choice = e_Copy;
223  }
224 }
225 
227 {
229  return *static_cast<const TSwap*>(m_object);
230 }
231 
233 {
235  return *static_cast<TSwap*>(m_object);
236 }
237 
239 {
240  TSwap* ptr = &value;
241  if ( m_choice != e_Swap || m_object != ptr ) {
242  ResetSelection();
243  (m_object = ptr)->AddReference();
244  m_choice = e_Swap;
245  }
246 }
247 
249 {
251  return *static_cast<const TRemove*>(m_object);
252 }
253 
255 {
257  return *static_cast<TRemove*>(m_object);
258 }
259 
261 {
262  TRemove* ptr = &value;
263  if ( m_choice != e_Remove || m_object != ptr ) {
264  ResetSelection();
265  (m_object = ptr)->AddReference();
266  m_choice = e_Remove;
267  }
268 }
269 
271 {
273  return *static_cast<const TParse*>(m_object);
274 }
275 
277 {
279  return *static_cast<TParse*>(m_object);
280 }
281 
283 {
284  TParse* ptr = &value;
285  if ( m_choice != e_Parse || m_object != ptr ) {
286  ResetSelection();
287  (m_object = ptr)->AddReference();
288  m_choice = e_Parse;
289  }
290 }
291 
293 {
295  return *static_cast<const TRemove_outside*>(m_object);
296 }
297 
299 {
301  return *static_cast<TRemove_outside*>(m_object);
302 }
303 
305 {
306  TRemove_outside* ptr = &value;
307  if ( m_choice != e_Remove_outside || m_object != ptr ) {
308  ResetSelection();
309  (m_object = ptr)->AddReference();
311  }
312 }
313 
314 // helper methods
315 
316 // type info
318 {
319  SET_CHOICE_MODULE("NCBI-Macro");
320  ADD_NAMED_REF_CHOICE_VARIANT("apply", m_object, CApply_action);
321  ADD_NAMED_REF_CHOICE_VARIANT("edit", m_object, CEdit_action);
322  ADD_NAMED_REF_CHOICE_VARIANT("convert", m_object, CConvert_action);
323  ADD_NAMED_REF_CHOICE_VARIANT("copy", m_object, CCopy_action);
324  ADD_NAMED_REF_CHOICE_VARIANT("swap", m_object, CSwap_action);
325  ADD_NAMED_REF_CHOICE_VARIANT("remove", m_object, CRemove_action);
327  ADD_NAMED_REF_CHOICE_VARIANT("remove-outside", m_object, CRemove_outside_action);
328  info->CodeVersion(22400);
329  info->DataSpec(ncbi::EDataSpec::eASN);
330 }
332 
333 // constructor
335  : m_choice(e_not_set)
336 {
337 }
338 
339 // destructor
341 {
342  Reset();
343 }
344 
345 
346 
347 END_objects_SCOPE // namespace ncbi::objects::
348 
350 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
BEGIN_NAMED_BASE_CHOICE_INFO("Action-choice", CAction_choice)
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.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CAECRParse_action –.
CAction_choice –.
CApply_action –.
CConvert_action –.
CCopy_action –.
Definition: Copy_action.hpp:66
CEdit_action –.
Definition: Edit_action.hpp:66
CRemove_action –.
CRemove_outside_action –.
CSwap_action –.
Definition: Swap_action.hpp:66
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 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
TParse & SetParse(void)
Select the variant.
TEdit & SetEdit(void)
Select the variant.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TConvert & GetConvert(void) const
Get the variant data.
const TRemove & GetRemove(void) const
Get the variant data.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
virtual ~CAction_choice_Base(void)
TRemove & SetRemove(void)
Select the variant.
TApply & SetApply(void)
Select the variant.
virtual void Reset(void)
Reset the whole object.
static const char *const sm_SelectionNames[]
TConvert & SetConvert(void)
Select the variant.
NCBI_NS_NCBI::CSerialObject * m_object
const TParse & GetParse(void) const
Get the variant data.
TCopy & SetCopy(void)
Select the variant.
const TCopy & GetCopy(void) const
Get the variant data.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TSwap & SetSwap(void)
Select the variant.
const TRemove_outside & GetRemove_outside(void) const
Get the variant data.
const TEdit & GetEdit(void) const
Get the variant data.
TRemove_outside & SetRemove_outside(void)
Select the variant.
E_Choice
Choice variants.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
const TSwap & GetSwap(void) const
Get the variant data.
const TApply & GetApply(void) const
Get the variant data.
@ e_not_set
No variant selected.
@ 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 Sep 04 15:04:50 2024 by modify_doxy.py rev. 669887