NCBI C++ ToolKit
PrintForm_.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  * 'objprt.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_Use_template:
65  m_Use_template.Destruct();
66  break;
67  case e_Block:
68  case e_Boolean:
69  case e_Enum:
70  case e_Text:
71  case e_User:
72  m_object->RemoveReference();
73  break;
74  default:
75  break;
76  }
78 }
79 
80 void CPrintForm_Base::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
81 {
82  switch ( index ) {
83  case e_Block:
84  (m_object = new(pool) ncbi::objects::CPrintFormBlock())->AddReference();
85  break;
86  case e_Boolean:
87  (m_object = new(pool) ncbi::objects::CPrintFormBoolean())->AddReference();
88  break;
89  case e_Enum:
90  (m_object = new(pool) ncbi::objects::CPrintFormEnum())->AddReference();
91  break;
92  case e_Text:
93  (m_object = new(pool) ncbi::objects::CPrintFormText())->AddReference();
94  break;
95  case e_Use_template:
96  m_Use_template.Construct();
97  break;
98  case e_User:
99  (m_object = new(pool) ncbi::objects::CUserFormat())->AddReference();
100  break;
101  default:
102  break;
103  }
104  m_choice = index;
105 }
106 
107 const char* const CPrintForm_Base::sm_SelectionNames[] = {
108  "not set",
109  "block",
110  "boolean",
111  "enum",
112  "text",
113  "use-template",
114  "user",
115  "null"
116 };
117 
119 {
120  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
121 }
122 
124 {
125  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
126 }
127 
129 {
131  return *static_cast<const TBlock*>(m_object);
132 }
133 
135 {
137  return *static_cast<TBlock*>(m_object);
138 }
139 
141 {
142  TBlock* ptr = &value;
143  if ( m_choice != e_Block || m_object != ptr ) {
144  ResetSelection();
145  (m_object = ptr)->AddReference();
146  m_choice = e_Block;
147  }
148 }
149 
151 {
153  return *static_cast<const TBoolean*>(m_object);
154 }
155 
157 {
159  return *static_cast<TBoolean*>(m_object);
160 }
161 
163 {
164  TBoolean* ptr = &value;
165  if ( m_choice != e_Boolean || m_object != ptr ) {
166  ResetSelection();
167  (m_object = ptr)->AddReference();
169  }
170 }
171 
173 {
175  return *static_cast<const TEnum*>(m_object);
176 }
177 
179 {
181  return *static_cast<TEnum*>(m_object);
182 }
183 
185 {
186  TEnum* ptr = &value;
187  if ( m_choice != e_Enum || m_object != ptr ) {
188  ResetSelection();
189  (m_object = ptr)->AddReference();
190  m_choice = e_Enum;
191  }
192 }
193 
195 {
197  return *static_cast<const TText*>(m_object);
198 }
199 
201 {
203  return *static_cast<TText*>(m_object);
204 }
205 
207 {
208  TText* ptr = &value;
209  if ( m_choice != e_Text || m_object != ptr ) {
210  ResetSelection();
211  (m_object = ptr)->AddReference();
212  m_choice = e_Text;
213  }
214 }
215 
217 {
220 }
221 
223 {
225  return *static_cast<const TUser*>(m_object);
226 }
227 
229 {
231  return *static_cast<TUser*>(m_object);
232 }
233 
235 {
236  TUser* ptr = &value;
237  if ( m_choice != e_User || m_object != ptr ) {
238  ResetSelection();
239  (m_object = ptr)->AddReference();
240  m_choice = e_User;
241  }
242 }
243 
244 // helper methods
245 
246 // type info
248 {
249  SET_CHOICE_MODULE("NCBI-ObjPrt");
250  ADD_NAMED_REF_CHOICE_VARIANT("block", m_object, CPrintFormBlock);
251  ADD_NAMED_REF_CHOICE_VARIANT("boolean", m_object, CPrintFormBoolean);
252  ADD_NAMED_REF_CHOICE_VARIANT("enum", m_object, CPrintFormEnum);
253  ADD_NAMED_REF_CHOICE_VARIANT("text", m_object, CPrintFormText);
254  ADD_NAMED_BUF_CHOICE_VARIANT("use-template", m_Use_template, CLASS, (CTemplateName));
255  ADD_NAMED_REF_CHOICE_VARIANT("user", m_object, CUserFormat);
256  ADD_NAMED_NULL_CHOICE_VARIANT("null", null, ());
257  info->CodeVersion(22301);
258  info->DataSpec(ncbi::EDataSpec::eASN);
259 }
261 
262 // constructor
264  : m_choice(e_not_set)
265 {
266 }
267 
268 // destructor
270 {
271  Reset();
272 }
273 
274 
275 
276 END_objects_SCOPE // namespace ncbi::objects::
277 
279 
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.
BEGIN_NAMED_BASE_CHOICE_INFO("PrintForm", CPrintForm)
Definition: PrintForm_.cpp:247
User-defined methods of the data storage class.
CPrintFormBlock –.
CPrintFormBoolean –.
CPrintFormEnum –.
CPrintFormText –.
CPrintForm –.
Definition: PrintForm.hpp:66
CTemplateName –.
CUserFormat –.
Definition: UserFormat.hpp:66
char value[7]
Definition: config.c:431
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
#define ADD_NAMED_NULL_CHOICE_VARIANT(MemberAlias, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:379
#define ADD_NAMED_BUF_CHOICE_VARIANT(MemberAlias, MemberName, TypeMacro, TypeMacroArgs)
Definition: serialimpl.hpp:385
@ 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
TEnum & SetEnum(void)
Select the variant.
Definition: PrintForm_.cpp:178
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: PrintForm_.cpp:123
static const char *const sm_SelectionNames[]
Definition: PrintForm_.hpp:346
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: PrintForm_.hpp:370
NCBI_NS_NCBI::CSerialObject * m_object
Definition: PrintForm_.hpp:350
TBlock & SetBlock(void)
Select the variant.
Definition: PrintForm_.cpp:134
virtual ~CPrintForm_Base(void)
Definition: PrintForm_.cpp:269
TBoolean & SetBoolean(void)
Select the variant.
Definition: PrintForm_.cpp:156
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: PrintForm_.cpp:118
TUser & SetUser(void)
Select the variant.
Definition: PrintForm_.cpp:228
TUse_template & SetUse_template(void)
Select the variant.
Definition: PrintForm_.hpp:430
E_Choice m_choice
Definition: PrintForm_.hpp:342
const TBoolean & GetBoolean(void) const
Get the variant data.
Definition: PrintForm_.cpp:150
NCBI_NS_NCBI::CUnionBuffer< TUse_template > m_Use_template
Definition: PrintForm_.hpp:349
const TUser & GetUser(void) const
Get the variant data.
Definition: PrintForm_.cpp:222
const TBlock & GetBlock(void) const
Get the variant data.
Definition: PrintForm_.cpp:128
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: PrintForm_.cpp:61
virtual void Reset(void)
Reset the whole object.
Definition: PrintForm_.cpp:55
E_Choice
Choice variants.
Definition: PrintForm_.hpp:95
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: PrintForm_.cpp:80
const TText & GetText(void) const
Get the variant data.
Definition: PrintForm_.cpp:194
TText & SetText(void)
Select the variant.
Definition: PrintForm_.cpp:200
const TEnum & GetEnum(void) const
Get the variant data.
Definition: PrintForm_.cpp:172
@ e_not_set
No variant selected.
Definition: PrintForm_.hpp:96
@ e_not_set
static MDB_envinfo info
Definition: mdb_load.c:37
Modified on Sat Dec 02 09:23:47 2023 by modify_doxy.py rev. 669887