NCBI C++ ToolKit
PC_InfoData_.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  * 'pcsubstance.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
43 #include <objects/general/Date.hpp>
46 
47 BEGIN_objects_SCOPE // namespace ncbi::objects::
48 
49 
50 // generated classes
51 
53 {
54  if ( m_choice != e_not_set )
56 }
57 
59 {
60  switch ( m_choice ) {
61  case e_Bvec:
62  m_Bvec.Destruct();
63  break;
64  case e_Ivec:
65  m_Ivec.Destruct();
66  break;
67  case e_Fvec:
68  m_Fvec.Destruct();
69  break;
70  case e_Slist:
71  m_Slist.Destruct();
72  break;
73  case e_Binary:
74  m_Binary.Destruct();
75  break;
76  case e_Bitlist:
77  m_Bitlist.Destruct();
78  break;
79  case e_Sval:
80  m_string.Destruct();
81  break;
82  case e_Date:
83  m_object->RemoveReference();
84  break;
85  default:
86  break;
87  }
88  m_choice = e_not_set;
89 }
90 
91 void CPC_InfoData_Base::C_Value::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool)
92 {
93  switch ( index ) {
94  case e_Bval:
95  m_Bval = 0;
96  break;
97  case e_Bvec:
98  m_Bvec.Construct();
99  break;
100  case e_Ival:
101  m_Ival = 0;
102  break;
103  case e_Ivec:
104  m_Ivec.Construct();
105  break;
106  case e_Fval:
107  m_Fval = 0;
108  break;
109  case e_Fvec:
110  m_Fvec.Construct();
111  break;
112  case e_Slist:
113  m_Slist.Construct();
114  break;
115  case e_Date:
116  (m_object = new(pool) ncbi::objects::CDate())->AddReference();
117  break;
118  case e_Binary:
119  m_Binary.Construct();
120  break;
121  case e_Bitlist:
122  m_Bitlist.Construct();
123  break;
124  case e_Sval:
125  m_string.Construct();
126  break;
127  default:
128  break;
129  }
130  m_choice = index;
131 }
132 
133 const char* const CPC_InfoData_Base::C_Value::sm_SelectionNames[] = {
134  "not set",
135  "bval",
136  "bvec",
137  "ival",
138  "ivec",
139  "fval",
140  "fvec",
141  "sval",
142  "slist",
143  "date",
144  "binary",
145  "bitlist"
146 };
147 
149 {
150  return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
151 }
152 
154 {
155  throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0]));
156 }
157 
159 {
160  Select(e_Sval, NCBI_NS_NCBI::eDoNotResetVariant);
161  *m_string = value;
162 }
163 
165 {
166  CheckSelected(e_Date);
167  return *static_cast<const TDate*>(m_object);
168 }
169 
171 {
172  Select(e_Date, NCBI_NS_NCBI::eDoNotResetVariant);
173  return *static_cast<TDate*>(m_object);
174 }
175 
177 {
178  TDate* ptr = &value;
179  if ( m_choice != e_Date || m_object != ptr ) {
180  ResetSelection();
181  (m_object = ptr)->AddReference();
182  m_choice = e_Date;
183  }
184 }
185 
186 // helper methods
187 
188 // type info
190 {
191  SET_INTERNAL_NAME("PC-InfoData", "value");
192  SET_CHOICE_MODULE("NCBI-PCSubstance");
193  ADD_NAMED_STD_CHOICE_VARIANT("bval", m_Bval);
194  ADD_NAMED_BUF_CHOICE_VARIANT("bvec", m_Bvec, STL_vector, (STD, (char)));
195  ADD_NAMED_STD_CHOICE_VARIANT("ival", m_Ival);
196  ADD_NAMED_BUF_CHOICE_VARIANT("ivec", m_Ivec, STL_vector, (STD, (int)));
197  ADD_NAMED_STD_CHOICE_VARIANT("fval", m_Fval);
198  ADD_NAMED_BUF_CHOICE_VARIANT("fvec", m_Fvec, STL_vector, (STD, (double)));
199  ADD_NAMED_BUF_CHOICE_VARIANT("sval", m_string, STD, (string));
200  ADD_NAMED_BUF_CHOICE_VARIANT("slist", m_Slist, STL_list, (STD, (string)));
201  ADD_NAMED_REF_CHOICE_VARIANT("date", m_object, CDate);
202  ADD_NAMED_BUF_CHOICE_VARIANT("binary", m_Binary, STL_CHAR_vector, (char));
203  ADD_NAMED_BUF_CHOICE_VARIANT("bitlist", m_Bitlist, STD, (CBitString));
204  info->CodeVersion(22400);
205  info->DataSpec(ncbi::EDataSpec::eASN);
206 }
208 
209 // constructor
211  : m_choice(e_not_set)
212 {
213 }
214 
215 // destructor
217 {
218  Reset();
219 }
220 
221 
223 {
224  if ( !m_Urn ) {
225  m_Urn.Reset(new TUrn());
226  return;
227  }
228  (*m_Urn).Reset();
229 }
230 
232 {
233  m_Urn.Reset(&value);
234 }
235 
237 {
238  if ( !m_Value ) {
239  m_Value.Reset(new TValue());
240  return;
241  }
242  (*m_Value).Reset();
243 }
244 
246 {
247  m_Value.Reset(&value);
248 }
249 
251 {
252  ResetUrn();
253  ResetValue();
254 }
255 
257 {
258  SET_CLASS_MODULE("NCBI-PCSubstance");
260  ADD_NAMED_REF_MEMBER("value", m_Value, C_Value);
261  info->RandomOrder();
262  info->CodeVersion(22400);
263  info->DataSpec(ncbi::EDataSpec::eASN);
264 }
266 
267 // constructor
269 {
270  memset(m_set_State,0,sizeof(m_set_State));
271  if ( !IsAllocatedInPool() ) {
272  ResetUrn();
273  ResetValue();
274  }
275 }
276 
277 // destructor
279 {
280 }
281 
282 
283 
284 END_objects_SCOPE // namespace ncbi::objects::
285 
287 
User-defined methods of the data storage class.
BEGIN_NAMED_CHOICE_INFO("", CPC_InfoData_Base::C_Value)
BEGIN_NAMED_BASE_CLASS_INFO("PC-InfoData", CPC_InfoData)
User-defined methods of the data storage class.
Definition: Date.hpp:53
CPC_InfoData –.
Definition: PC_InfoData.hpp:66
CPC_Urn –.
Definition: PC_Urn.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_MEMBER(MemberAlias, MemberName, ClassName)
Definition: serialimpl.hpp:357
#define END_CLASS_INFO
Definition: serialimpl.hpp:456
#define ADD_NAMED_REF_CHOICE_VARIANT(MemberAlias, MemberName, ClassName)
Definition: serialimpl.hpp:400
#define SET_CLASS_MODULE(ModuleName)
Definition: serialimpl.hpp:444
#define ADD_NAMED_STD_CHOICE_VARIANT(MemberAlias, MemberName)
Definition: serialimpl.hpp:388
#define END_CHOICE_INFO
Definition: serialimpl.hpp:506
#define SET_INTERNAL_NAME(OwnerName, MemberName)
Definition: serialimpl.hpp:447
#define SET_CHOICE_MODULE(ModuleName)
Definition: serialimpl.hpp:500
#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
bool IsAllocatedInPool(void) const THROWS_NONE
Check if object is allocated in memory pool (not system heap)
Definition: ncbiobj.hpp:461
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
virtual ~CPC_InfoData_Base(void)
void ResetValue(void)
Reset Value data member.
static const char *const sm_SelectionNames[]
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
TSval & SetSval(void)
Select the variant.
CRef< TUrn > m_Urn
void Reset(void)
Reset the whole object.
TUrn & SetUrn(void)
Assign a value to Urn data member.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
TDate & SetDate(void)
Select the variant.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TValue & SetValue(void)
Assign a value to Value data member.
virtual void Reset(void)
Reset the whole object.
void ResetSelection(void)
Reset the selection (set it to e_not_set).
CRef< TValue > m_Value
const TDate & GetDate(void) const
Get the variant data.
void ResetUrn(void)
Reset Urn data member.
@ 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 Fri May 24 14:50:54 2024 by modify_doxy.py rev. 669887