NCBI C++ ToolKit
Suffix_.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 Suffix_.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/objtools/eutils/efetch/efetch.xsd">efetch.xsd</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objtools/eutils/efetch/efetch.def">efetch.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 eutils__OBJTOOLS_EUTILS_EFETCH_SUFFIX_BASE_HPP
42 #define eutils__OBJTOOLS_EUTILS_EFETCH_SUFFIX_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
49 #include <string>
51 
52 #ifndef BEGIN_eutils_SCOPE
53 # define BEGIN_eutils_SCOPE BEGIN_SCOPE(eutils)
54 # define END_eutils_SCOPE END_SCOPE(eutils)
55 #endif
56 BEGIN_eutils_SCOPE // namespace eutils::
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_efetch
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CSuffix_Base --
70 ///
71 
72 class CSuffix_Base : public NCBI_NS_NCBI::CSerialObject
73 {
74  typedef NCBI_NS_NCBI::CSerialObject Tparent;
75 public:
76  // constructor
77  CSuffix_Base(void);
78  // destructor
79  virtual ~CSuffix_Base(void);
80 
81  // type info
83 
84  /////////////////////////////////////////////////////////////////////////////
85  ///
86  /// C_E --
87  ///
88 
89  class C_E : public NCBI_NS_NCBI::CSerialObject
90  {
91  typedef NCBI_NS_NCBI::CSerialObject Tparent;
92  public:
93  // constructor
94  C_E(void);
95  // destructor
96  ~C_E(void);
97 
98  // type info
100 
101  typedef CText C_Text;
102 
103  /// Choice variants.
104  enum E_Choice {
105  e_not_set = 0, ///< No variant selected
107  e_Text
108  };
109  /// Maximum+1 value of the choice variant enumerator.
111  e_MaxChoice = 3 ///< == e_Text+1
112  };
113 
114  /// Reset the whole object
115  void Reset(void);
116 
117  /// Reset the selection (set it to e_not_set).
118  void ResetSelection(void);
119 
120  /// Which variant is currently selected.
121  ///
122  /// @return
123  /// Choice state enumerator.
124  E_Choice Which(void) const;
125 
126  /// Verify selection, throw exception if it differs from the expected.
127  ///
128  /// @param index
129  /// Expected selection.
130  void CheckSelected(E_Choice index) const;
131 
132  /// Throw 'InvalidSelection' exception.
133  ///
134  /// @param index
135  /// Expected selection.
136  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
137 
138  /// Retrieve selection name (for diagnostic purposes).
139  ///
140  /// @param index
141  /// One of possible selection states.
142  /// @return
143  /// Name string.
145 
146  /// Select the requested variant if needed.
147  ///
148  /// @param index
149  /// New selection state.
150  /// @param reset
151  /// Flag that defines the resetting of the variant data. The data will
152  /// be reset if either the current selection differs from the new one,
153  /// or the flag is set to eDoResetVariant.
155  /// Select the requested variant if needed,
156  /// allocating CObject variants from memory pool.
157  void Select(E_Choice index,
159  NCBI_NS_NCBI::CObjectMemoryPool* pool);
160 
161  // types
163  typedef C_Text TText;
164 
165  // getters
166  // setters
167 
168 
169  /// Check if variant _CharData is selected.
170  ///
171  /// _CharData type is defined as 'typedef NCBI_NS_STD::string T_CharData'.
172  /// @return
173  /// - true, if the variant is selected.
174  /// - false, otherwise.
175  bool Is_CharData(void) const;
176 
177  /// Get the variant data.
178  ///
179  /// @return
180  /// Reference to the data.
181  const T_CharData& Get_CharData(void) const;
182 
183  /// Select the variant.
184  ///
185  /// @return
186  /// Reference to the variant data.
187  T_CharData& Set_CharData(void);
188 
189  /// Select the variant and set its data.
190  ///
191  /// @param value
192  /// Variant data.
193  void Set_CharData(const T_CharData& value);
194 
195 
196  /// Check if variant Text is selected.
197  ///
198  /// Text type is defined as 'typedef C_Text TText'.
199  /// @return
200  /// - true, if the variant is selected.
201  /// - false, otherwise.
202  bool IsText(void) const;
203 
204  /// Get the variant data.
205  ///
206  /// @return
207  /// Reference to the data.
208  const TText& GetText(void) const;
209 
210  /// Select the variant.
211  ///
212  /// @return
213  /// Reference to the variant data.
214  TText& SetText(void);
215  /// Select the variant and set its data.
216  ///
217  /// @param value
218  /// Reference to the data.
219  void SetText(TText& value);
220 
221 
222  private:
223  // copy constructor and assignment operator
224  C_E(const C_E& );
225  C_E& operator=(const C_E& );
226  // choice state
228  // helper methods
229  void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool = 0);
230 
231  static const char* const sm_SelectionNames[];
232  // data
233  union {
234  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
235  NCBI_NS_NCBI::CSerialObject *m_object;
236  };
237  };
238  // types
239  typedef NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_E > > Tdata;
240 
241  // getters
242  // setters
243 
244  /// Check if a value has been assigned to data member.
245  ///
246  /// Data member is mandatory;
247  /// its type is defined as 'typedef NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_E > > Tdata'
248  /// @return
249  /// - true, if a value has been assigned.
250  /// - false, otherwise.
251  bool IsSet(void) const;
252 
253  /// Check if it is safe to call Get method.
254  ///
255  /// @return
256  /// - true, if the data member is getatable.
257  /// - false, otherwise.
258  bool CanGet(void) const;
259 
260  /// Reset data member.
261  void Reset(void);
262 
263  /// Get the member data.
264  ///
265  /// @return
266  /// Reference to the member data.
267  const Tdata& Get(void) const;
268 
269  /// Assign a value to data member.
270  ///
271  /// @return
272  /// Reference to the data value.
273  Tdata& Set(void);
274 
275  /// Conversion operator to 'const Tdata' type.
276  operator const Tdata& (void) const;
277  /// Conversion operator to 'Tdata' type.
278  operator Tdata& (void);
279 
280 
281 
282 private:
283  // Prohibit copy constructor and assignment operator
286 
287  // data
289  NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_E > > m_data;
290 };
291 
292 /* @} */
293 
294 
295 
296 
297 
298 ///////////////////////////////////////////////////////////
299 ///////////////////// inline methods //////////////////////
300 ///////////////////////////////////////////////////////////
301 inline
303 {
304  return m_choice;
305 }
306 
307 inline
309 {
310  if ( m_choice != index )
311  ThrowInvalidSelection(index);
312 }
313 
314 inline
315 void CSuffix_Base::C_E::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
316 {
317  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
318  if ( m_choice != e_not_set )
319  ResetSelection();
320  DoSelect(index, pool);
321  }
322 }
323 
324 inline
326 {
327  Select(index, reset, 0);
328 }
329 
330 inline
332 {
333  return m_choice == e__CharData;
334 }
335 
336 inline
338 {
339  CheckSelected(e__CharData);
340  return *m_string;
341 }
342 
343 inline
345 {
346  Select(e__CharData, NCBI_NS_NCBI::eDoNotResetVariant);
347  return *m_string;
348 }
349 
350 inline
352 {
353  return m_choice == e_Text;
354 }
355 
356 inline
357 bool CSuffix_Base::IsSet(void) const
358 {
359  return ((m_set_State[0] & 0x3) != 0);
360 }
361 
362 inline
363 bool CSuffix_Base::CanGet(void) const
364 {
365  return true;
366 }
367 
368 inline
370 {
371  return m_data;
372 }
373 
374 inline
376 {
377  m_set_State[0] |= 0x1;
378  return m_data;
379 }
380 
381 inline
382 CSuffix_Base::operator const CSuffix_Base::Tdata& (void) const
383 {
384  return m_data;
385 }
386 
387 inline
388 CSuffix_Base::operator CSuffix_Base::Tdata& (void)
389 {
390  m_set_State[0] |= 0x1;
391  return m_data;
392 }
393 
394 ///////////////////////////////////////////////////////////
395 ////////////////// end of inline methods //////////////////
396 ///////////////////////////////////////////////////////////
397 
398 
399 
400 
401 
402 END_eutils_SCOPE // namespace eutils::
403 
404 
405 #endif // eutils__OBJTOOLS_EUTILS_EFETCH_SUFFIX_BASE_HPP
#define BEGIN_eutils_SCOPE
Definition: Suffix_.hpp:53
#define END_eutils_SCOPE
Definition: Suffix_.hpp:54
User-defined methods of the data storage class.
CSuffix_Base –.
Definition: Suffix_.hpp:73
CText –.
Definition: Text.hpp:64
string
Definition: cgiapp.hpp:687
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
bool IsSet(void) const
Check if a value has been assigned to data member.
Definition: Suffix_.hpp:357
void Reset(void)
Reset data member.
Definition: Suffix_.cpp:156
E_Choice m_choice
Definition: Suffix_.hpp:227
Uint4 m_set_State[1]
Definition: Suffix_.hpp:288
Tdata & Set(void)
Assign a value to data member.
Definition: Suffix_.hpp:375
TText & SetText(void)
Select the variant.
Definition: Suffix_.cpp:112
C_E(const C_E &)
NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_E > > Tdata
Definition: Suffix_.hpp:239
void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Suffix_.cpp:54
CSuffix_Base(void)
Definition: Suffix_.cpp:174
const T_CharData & Get_CharData(void) const
Get the variant data.
Definition: Suffix_.hpp:337
C_E & operator=(const C_E &)
void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool *pool=0)
Definition: Suffix_.cpp:69
bool IsText(void) const
Check if variant Text is selected.
Definition: Suffix_.hpp:351
CSuffix_Base & operator=(const CSuffix_Base &)
DECLARE_INTERNAL_TYPE_INFO()
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Suffix_.cpp:95
E_Choice
Choice variants.
Definition: Suffix_.hpp:104
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Suffix_.hpp:308
virtual ~CSuffix_Base(void)
Definition: Suffix_.cpp:180
const TText & GetText(void) const
Get the variant data.
Definition: Suffix_.cpp:106
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Suffix_.hpp:110
E_Choice Which(void) const
Which variant is currently selected.
Definition: Suffix_.hpp:302
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Suffix_.hpp:235
static const char *const sm_SelectionNames[]
Definition: Suffix_.hpp:231
CSuffix_Base(const CSuffix_Base &)
NCBI_NS_NCBI::CSerialObject Tparent
Definition: Suffix_.hpp:74
void Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset=NCBI_NS_NCBI::eDoResetVariant)
Select the requested variant if needed.
Definition: Suffix_.hpp:325
NCBI_NS_STD::list< NCBI_NS_NCBI::CRef< C_E > > m_data
Definition: Suffix_.hpp:289
NCBI_NS_STD::string T_CharData
Definition: Suffix_.hpp:162
bool CanGet(void) const
Check if it is safe to call Get method.
Definition: Suffix_.hpp:363
T_CharData & Set_CharData(void)
Select the variant.
Definition: Suffix_.hpp:344
bool Is_CharData(void) const
Check if variant _CharData is selected.
Definition: Suffix_.hpp:331
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Suffix_.hpp:234
NCBI_NS_NCBI::CSerialObject Tparent
Definition: Suffix_.hpp:91
void Reset(void)
Reset the whole object.
Definition: Suffix_.cpp:48
static NCBI_NS_STD::string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Suffix_.cpp:90
const Tdata & Get(void) const
Get the member data.
Definition: Suffix_.hpp:369
@ e_not_set
No variant selected.
Definition: Suffix_.hpp:105
@ e_MaxChoice
== e_Text+1
Definition: Suffix_.hpp:111
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sat Jul 20 11:12:24 2024 by modify_doxy.py rev. 669887