NCBI C++ ToolKit
Parse_src_.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 Parse_src_.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/objects/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.def">macro.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 OBJECTS_MACRO_PARSE_SRC_BASE_HPP
42 #define OBJECTS_MACRO_PARSE_SRC_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
49 
51 
52 #ifndef BEGIN_objects_SCOPE
53 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
54 # define END_objects_SCOPE END_SCOPE(objects)
55 #endif
56 BEGIN_objects_SCOPE // namespace ncbi::objects::
57 
58 
59 // forward declarations
61 class CParse_src_org;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_Macro
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///
74 /// CParse_src_Base --
75 ///
76 
78 {
80 public:
81  // constructor
82  CParse_src_Base(void);
83  // destructor
84  virtual ~CParse_src_Base(void);
85 
86  // type info
88 
89 
90  /// Choice variants.
91  enum E_Choice {
92  e_not_set = 0, ///< No variant selected
102  };
103  /// Maximum+1 value of the choice variant enumerator.
105  e_MaxChoice = 10 ///< == e_General_id+1
106  };
107 
108  /// Reset the whole object
109  virtual void Reset(void);
110 
111  /// Reset the selection (set it to e_not_set).
112  virtual void ResetSelection(void);
113 
114  /// Which variant is currently selected.
115  ///
116  /// @return
117  /// Choice state enumerator.
118  E_Choice Which(void) const;
119 
120  /// Verify selection, throw exception if it differs from the expected.
121  ///
122  /// @param index
123  /// Expected selection.
124  void CheckSelected(E_Choice index) const;
125 
126  /// Throw 'InvalidSelection' exception.
127  ///
128  /// @param index
129  /// Expected selection.
130  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
131 
132  /// Retrieve selection name (for diagnostic purposes).
133  ///
134  /// @param index
135  /// One of possible selection states.
136  /// @return
137  /// Name string.
138  static string SelectionName(E_Choice index);
139 
140  /// Select the requested variant if needed.
141  ///
142  /// @param index
143  /// New selection state.
144  /// @param reset
145  /// Flag that defines the resetting of the variant data. The data will
146  /// be reset if either the current selection differs from the new one,
147  /// or the flag is set to eDoResetVariant.
149  /// Select the requested variant if needed,
150  /// allocating CObject variants from memory pool.
151  void Select(E_Choice index,
152  EResetVariant reset,
153  CObjectMemoryPool* pool);
154 
155  // types
157  typedef string TStructured_comment;
159 
160  // getters
161  // setters
162 
163 
164  /// Check if variant Defline is selected.
165  ///
166  /// @return
167  /// - true, if the variant is selected.
168  /// - false, otherwise.
169  bool IsDefline(void) const;
170 
171  /// Select the variant.
172  void SetDefline(void);
173 
174 
175  /// Check if variant Flatfile is selected.
176  ///
177  /// @return
178  /// - true, if the variant is selected.
179  /// - false, otherwise.
180  bool IsFlatfile(void) const;
181 
182  /// Select the variant.
183  void SetFlatfile(void);
184 
185 
186  /// Check if variant Local_id is selected.
187  ///
188  /// @return
189  /// - true, if the variant is selected.
190  /// - false, otherwise.
191  bool IsLocal_id(void) const;
192 
193  /// Select the variant.
194  void SetLocal_id(void);
195 
196 
197  /// Check if variant Org is selected.
198  ///
199  /// Org type is defined as 'typedef CParse_src_org TOrg'.
200  /// @return
201  /// - true, if the variant is selected.
202  /// - false, otherwise.
203  bool IsOrg(void) const;
204 
205  /// Get the variant data.
206  ///
207  /// @return
208  /// Reference to the data.
209  const TOrg& GetOrg(void) const;
210 
211  /// Select the variant.
212  ///
213  /// @return
214  /// Reference to the variant data.
215  TOrg& SetOrg(void);
216  /// Select the variant and set its data.
217  ///
218  /// @param value
219  /// Reference to the data.
220  void SetOrg(TOrg& value);
221 
222 
223  /// Check if variant Comment is selected.
224  ///
225  /// @return
226  /// - true, if the variant is selected.
227  /// - false, otherwise.
228  bool IsComment(void) const;
229 
230  /// Select the variant.
231  void SetComment(void);
232 
233 
234  /// Check if variant Bankit_comment is selected.
235  ///
236  /// @return
237  /// - true, if the variant is selected.
238  /// - false, otherwise.
239  bool IsBankit_comment(void) const;
240 
241  /// Select the variant.
242  void SetBankit_comment(void);
243 
244 
245  /// Check if variant Structured_comment is selected.
246  ///
247  /// Structured_comment type is defined as 'typedef string TStructured_comment'.
248  /// @return
249  /// - true, if the variant is selected.
250  /// - false, otherwise.
251  bool IsStructured_comment(void) const;
252 
253  /// Get the variant data.
254  ///
255  /// @return
256  /// Reference to the data.
257  const TStructured_comment& GetStructured_comment(void) const;
258 
259  /// Select the variant.
260  ///
261  /// @return
262  /// Reference to the variant data.
264 
265  /// Select the variant and set its data.
266  ///
267  /// @param value
268  /// Variant data.
270 
271 
272  /// Check if variant File_id is selected.
273  ///
274  /// @return
275  /// - true, if the variant is selected.
276  /// - false, otherwise.
277  bool IsFile_id(void) const;
278 
279  /// Select the variant.
280  void SetFile_id(void);
281 
282 
283  /// Check if variant General_id is selected.
284  ///
285  /// General_id type is defined as 'typedef CParse_src_general_id TGeneral_id'.
286  /// @return
287  /// - true, if the variant is selected.
288  /// - false, otherwise.
289  bool IsGeneral_id(void) const;
290 
291  /// Get the variant data.
292  ///
293  /// @return
294  /// Reference to the data.
295  const TGeneral_id& GetGeneral_id(void) const;
296 
297  /// Select the variant.
298  ///
299  /// @return
300  /// Reference to the variant data.
301  TGeneral_id& SetGeneral_id(void);
302  /// Select the variant and set its data.
303  ///
304  /// @param value
305  /// Reference to the data.
307 
308 
309 private:
310  // copy constructor and assignment operator
313  // choice state
315  // helper methods
316  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
317 
318  static const char* const sm_SelectionNames[];
319  // data
320  union {
321  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
322  NCBI_NS_NCBI::CSerialObject *m_object;
323  };
324 };
325 
326 /* @} */
327 
328 
329 
330 
331 
332 ///////////////////////////////////////////////////////////
333 ///////////////////// inline methods //////////////////////
334 ///////////////////////////////////////////////////////////
335 inline
337 {
338  return m_choice;
339 }
340 
341 inline
343 {
344  if ( m_choice != index )
345  ThrowInvalidSelection(index);
346 }
347 
348 inline
349 void CParse_src_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
350 {
351  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
352  if ( m_choice != e_not_set )
353  ResetSelection();
354  DoSelect(index, pool);
355  }
356 }
357 
358 inline
359 void CParse_src_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
360 {
361  Select(index, reset, 0);
362 }
363 
364 inline
366 {
367  return m_choice == e_Defline;
368 }
369 
370 inline
372 {
374 }
375 
376 inline
378 {
379  return m_choice == e_Flatfile;
380 }
381 
382 inline
384 {
386 }
387 
388 inline
390 {
391  return m_choice == e_Local_id;
392 }
393 
394 inline
396 {
398 }
399 
400 inline
401 bool CParse_src_Base::IsOrg(void) const
402 {
403  return m_choice == e_Org;
404 }
405 
406 inline
408 {
409  return m_choice == e_Comment;
410 }
411 
412 inline
414 {
416 }
417 
418 inline
420 {
421  return m_choice == e_Bankit_comment;
422 }
423 
424 inline
426 {
428 }
429 
430 inline
432 {
433  return m_choice == e_Structured_comment;
434 }
435 
436 inline
438 {
440  return *m_string;
441 }
442 
443 inline
445 {
447  return *m_string;
448 }
449 
450 inline
452 {
453  return m_choice == e_File_id;
454 }
455 
456 inline
458 {
460 }
461 
462 inline
464 {
465  return m_choice == e_General_id;
466 }
467 
468 ///////////////////////////////////////////////////////////
469 ////////////////// end of inline methods //////////////////
470 ///////////////////////////////////////////////////////////
471 
472 
473 
474 
475 
476 END_objects_SCOPE // namespace ncbi::objects::
477 
479 
480 
481 #endif // OBJECTS_MACRO_PARSE_SRC_BASE_HPP
CParse_src_Base –.
Definition: Parse_src_.hpp:78
CParse_src_general_id –.
CParse_src_org –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
#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 void Reset(void)
Reset the whole object.
Definition: Parse_src_.cpp:52
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Parse_src_.cpp:110
void SetComment(void)
Select the variant.
Definition: Parse_src_.hpp:413
static const char *const sm_SelectionNames[]
Definition: Parse_src_.hpp:318
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Parse_src_.hpp:321
E_Choice m_choice
Definition: Parse_src_.hpp:314
void SetFlatfile(void)
Select the variant.
Definition: Parse_src_.hpp:383
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Parse_src_.hpp:322
bool IsStructured_comment(void) const
Check if variant Structured_comment is selected.
Definition: Parse_src_.hpp:431
void SetLocal_id(void)
Select the variant.
Definition: Parse_src_.hpp:395
CSerialObject Tparent
Definition: Parse_src_.hpp:79
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Parse_src_.hpp:321
CParse_src_org TOrg
Definition: Parse_src_.hpp:156
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Parse_src_.cpp:58
bool IsGeneral_id(void) const
Check if variant General_id is selected.
Definition: Parse_src_.hpp:463
TStructured_comment & SetStructured_comment(void)
Select the variant.
Definition: Parse_src_.hpp:444
bool IsFlatfile(void) const
Check if variant Flatfile is selected.
Definition: Parse_src_.hpp:377
bool IsComment(void) const
Check if variant Comment is selected.
Definition: Parse_src_.hpp:407
TOrg & SetOrg(void)
Select the variant.
Definition: Parse_src_.cpp:121
void SetBankit_comment(void)
Select the variant.
Definition: Parse_src_.hpp:425
bool IsOrg(void) const
Check if variant Org is selected.
Definition: Parse_src_.hpp:401
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Parse_src_.cpp:105
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Parse_src_.hpp:342
void SetFile_id(void)
Select the variant.
Definition: Parse_src_.hpp:457
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Parse_src_.cpp:74
CParse_src_general_id TGeneral_id
Definition: Parse_src_.hpp:158
virtual ~CParse_src_Base(void)
Definition: Parse_src_.cpp:192
const TStructured_comment & GetStructured_comment(void) const
Get the variant data.
Definition: Parse_src_.hpp:437
const TGeneral_id & GetGeneral_id(void) const
Get the variant data.
Definition: Parse_src_.cpp:143
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TOrg & GetOrg(void) const
Get the variant data.
Definition: Parse_src_.cpp:115
bool IsDefline(void) const
Check if variant Defline is selected.
Definition: Parse_src_.hpp:365
void SetDefline(void)
Select the variant.
Definition: Parse_src_.hpp:371
E_Choice
Choice variants.
Definition: Parse_src_.hpp:91
string TStructured_comment
Definition: Parse_src_.hpp:157
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Parse_src_.hpp:104
CParse_src_Base & operator=(const CParse_src_Base &)
bool IsLocal_id(void) const
Check if variant Local_id is selected.
Definition: Parse_src_.hpp:389
TGeneral_id & SetGeneral_id(void)
Select the variant.
Definition: Parse_src_.cpp:149
E_Choice Which(void) const
Which variant is currently selected.
Definition: Parse_src_.hpp:336
bool IsFile_id(void) const
Check if variant File_id is selected.
Definition: Parse_src_.hpp:451
bool IsBankit_comment(void) const
Check if variant Bankit_comment is selected.
Definition: Parse_src_.hpp:419
CParse_src_Base(const CParse_src_Base &)
@ e_not_set
No variant selected.
Definition: Parse_src_.hpp:92
@ e_MaxChoice
== e_General_id+1
Definition: Parse_src_.hpp:105
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:31 2024 by modify_doxy.py rev. 669887