NCBI C++ ToolKit
TMgr_AssemblySpec_.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 TMgr_AssemblySpec_.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/trackmgr/trackmgr.asn">trackmgr.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/trackmgr/trackmgr.def">trackmgr.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_TRACKMGR_TMGR_ASSEMBLYSPEC_BASE_HPP
42 #define OBJECTS_TRACKMGR_TMGR_ASSEMBLYSPEC_BASE_HPP
43 
44 // extra headers
46 
47 // standard includes
48 #include <serial/serialbase.hpp>
49 
50 // generated includes
51 #include <string>
52 
54 
55 #ifndef BEGIN_objects_SCOPE
56 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
57 # define END_objects_SCOPE END_SCOPE(objects)
58 #endif
59 BEGIN_objects_SCOPE // namespace ncbi::objects::
60 
61 
62 // generated classes
63 
64 
65 /** @addtogroup dataspec_NCBI_TrackManager
66  *
67  * @{
68  */
69 
70 /////////////////////////////////////////////////////////////////////////////
71 ///
72 /// CTMgr_AssemblySpec_Base --
73 ///
74 
76 {
78 public:
79  // constructor
81  // destructor
82  virtual ~CTMgr_AssemblySpec_Base(void);
83 
84  // type info
86 
87  /////////////////////////////////////////////////////////////////////////////
88  ///
89  /// C_Name --
90  ///
91 
93  {
95  public:
96  // constructor
97  C_Name(void);
98  // destructor
99  ~C_Name(void);
100 
101  // type info
103 
104  // types
105  typedef int TTax_id;
106  typedef string TName;
107 
108  // member index
109  enum class E_memberIndex {
110  e__allMandatory = 0,
111  e_tax_id,
112  e_name
113  };
115 
116  // getters
117  // setters
118 
119  /// Check if a value has been assigned to Tax_id data member.
120  ///
121  /// Data member Tax_id is mandatory;
122  /// its type is defined as 'typedef int TTax_id'
123  /// @return
124  /// - true, if a value has been assigned.
125  /// - false, otherwise.
126  bool IsSetTax_id(void) const;
127 
128  /// Check if it is safe to call GetTax_id method.
129  ///
130  /// @return
131  /// - true, if the data member is getatable.
132  /// - false, otherwise.
133  bool CanGetTax_id(void) const;
134 
135  /// Reset Tax_id data member.
136  void ResetTax_id(void);
137 
138  /// Get the Tax_id member data.
139  ///
140  /// @return
141  /// Copy of the member data.
142  TTax_id GetTax_id(void) const;
143 
144  /// Assign a value to Tax_id data member.
145  ///
146  /// @param value
147  /// Value to assign
148  void SetTax_id(TTax_id value);
149 
150  /// Assign a value to Tax_id data member.
151  ///
152  /// @return
153  /// Reference to the data value.
154  TTax_id& SetTax_id(void);
155 
156  /// Check if a value has been assigned to Name data member.
157  ///
158  /// Data member Name is mandatory;
159  /// its type is defined as 'typedef string TName'
160  /// @return
161  /// - true, if a value has been assigned.
162  /// - false, otherwise.
163  bool IsSetName(void) const;
164 
165  /// Check if it is safe to call GetName method.
166  ///
167  /// @return
168  /// - true, if the data member is getatable.
169  /// - false, otherwise.
170  bool CanGetName(void) const;
171 
172  /// Reset Name data member.
173  void ResetName(void);
174 
175  /// Get the Name member data.
176  ///
177  /// @return
178  /// Reference to the member data.
179  const TName& GetName(void) const;
180 
181  /// Assign a value to Name data member.
182  ///
183  /// @param value
184  /// Value to assign
185  void SetName(const TName& value);
186  void SetName(TName&& value);
187 
188  /// Assign a value to Name data member.
189  ///
190  /// @return
191  /// Reference to the data value.
192  TName& SetName(void);
193 
194  /// Reset the whole object
195  void Reset(void);
196 
197 
198  private:
199  // Prohibit copy constructor and assignment operator
200  C_Name(const C_Name&);
202 
203  // data
204  Uint4 m_set_State[1];
205  int m_Tax_id;
206  string m_Name;
207  };
208 
209  /// Choice variants.
210  enum E_Choice {
211  e_not_set = 0, ///< No variant selected
214  e_All_assemblies
215  };
216  /// Maximum+1 value of the choice variant enumerator.
218  e_MaxChoice = 4 ///< == e_All_assemblies+1
219  };
220 
221  /// Reset the whole object
222  virtual void Reset(void);
223 
224  /// Reset the selection (set it to e_not_set).
225  virtual void ResetSelection(void);
226 
227  /// Which variant is currently selected.
228  ///
229  /// @return
230  /// Choice state enumerator.
231  E_Choice Which(void) const;
232 
233  /// Verify selection, throw exception if it differs from the expected.
234  ///
235  /// @param index
236  /// Expected selection.
237  void CheckSelected(E_Choice index) const;
238 
239  /// Throw 'InvalidSelection' exception.
240  ///
241  /// @param index
242  /// Expected selection.
243  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
244 
245  /// Retrieve selection name (for diagnostic purposes).
246  ///
247  /// @param index
248  /// One of possible selection states.
249  /// @return
250  /// Name string.
251  static string SelectionName(E_Choice index);
252 
253  /// Select the requested variant if needed.
254  ///
255  /// @param index
256  /// New selection state.
257  /// @param reset
258  /// Flag that defines the resetting of the variant data. The data will
259  /// be reset if either the current selection differs from the new one,
260  /// or the flag is set to eDoResetVariant.
262  /// Select the requested variant if needed,
263  /// allocating CObject variants from memory pool.
264  void Select(E_Choice index,
265  EResetVariant reset,
266  CObjectMemoryPool* pool);
267 
268  // types
269  typedef C_Name TName;
270  typedef string TAccession;
271 
272  // getters
273  // setters
274 
275 
276  /// Check if variant Name is selected.
277  ///
278  /// Name type is defined as 'typedef C_Name TName'.
279  /// @return
280  /// - true, if the variant is selected.
281  /// - false, otherwise.
282  bool IsName(void) const;
283 
284  /// Get the variant data.
285  ///
286  /// @return
287  /// Reference to the data.
288  const TName& GetName(void) const;
289 
290  /// Select the variant.
291  ///
292  /// @return
293  /// Reference to the variant data.
294  TName& SetName(void);
295  /// Select the variant and set its data.
296  ///
297  /// @param value
298  /// Reference to the data.
299  void SetName(TName& value);
300 
301 
302  /// Check if variant Accession is selected.
303  ///
304  /// Accession type is defined as 'typedef string TAccession'.
305  /// @return
306  /// - true, if the variant is selected.
307  /// - false, otherwise.
308  bool IsAccession(void) const;
309 
310  /// Get the variant data.
311  ///
312  /// @return
313  /// Reference to the data.
314  const TAccession& GetAccession(void) const;
315 
316  /// Select the variant.
317  ///
318  /// @return
319  /// Reference to the variant data.
320  TAccession& SetAccession(void);
321 
322  /// Select the variant and set its data.
323  ///
324  /// @param value
325  /// Variant data.
326  void SetAccession(const TAccession& value);
327 
328 
329  /// Check if variant All_assemblies is selected.
330  ///
331  /// @return
332  /// - true, if the variant is selected.
333  /// - false, otherwise.
334  bool IsAll_assemblies(void) const;
335 
336  /// Select the variant.
337  void SetAll_assemblies(void);
338 
339 
340 private:
341  // copy constructor and assignment operator
344  // choice state
346  // helper methods
347  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
348 
349  static const char* const sm_SelectionNames[];
350  // data
351  union {
352  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
353  NCBI_NS_NCBI::CSerialObject *m_object;
354  };
355 };
356 
357 /* @} */
358 
359 
360 
361 
362 
363 ///////////////////////////////////////////////////////////
364 ///////////////////// inline methods //////////////////////
365 ///////////////////////////////////////////////////////////
366 inline
368 {
369  return ((m_set_State[0] & 0x3) != 0);
370 }
371 
372 inline
374 {
375  return IsSetTax_id();
376 }
377 
378 inline
380 {
381  m_Tax_id = 0;
382  m_set_State[0] &= ~0x3;
383 }
384 
385 inline
387 {
388  if (!CanGetTax_id()) {
389  ThrowUnassigned(0);
390  }
391  return m_Tax_id;
392 }
393 
394 inline
396 {
397  m_Tax_id = value;
398  m_set_State[0] |= 0x3;
399 }
400 
401 inline
403 {
404 #ifdef _DEBUG
405  if (!IsSetTax_id()) {
406  memset(&m_Tax_id,UnassignedByte(),sizeof(m_Tax_id));
407  }
408 #endif
409  m_set_State[0] |= 0x1;
410  return m_Tax_id;
411 }
412 
413 inline
415 {
416  return ((m_set_State[0] & 0xc) != 0);
417 }
418 
419 inline
421 {
422  return IsSetName();
423 }
424 
425 inline
427 {
428  if (!CanGetName()) {
429  ThrowUnassigned(1);
430  }
431  return m_Name;
432 }
433 
434 inline
436 {
437  m_Name = value;
438  m_set_State[0] |= 0xc;
439 }
440 
441 inline
443 {
444  m_Name = std::forward<CTMgr_AssemblySpec_Base::C_Name::TName>(value);
445  m_set_State[0] |= 0xc;
446 }
447 
448 inline
450 {
451 #ifdef _DEBUG
452  if (!IsSetName()) {
453  m_Name = UnassignedString();
454  }
455 #endif
456  m_set_State[0] |= 0x4;
457  return m_Name;
458 }
459 
460 inline
462 {
463  return m_choice;
464 }
465 
466 inline
468 {
469  if ( m_choice != index )
470  ThrowInvalidSelection(index);
471 }
472 
473 inline
474 void CTMgr_AssemblySpec_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
475 {
476  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
477  if ( m_choice != e_not_set )
478  ResetSelection();
479  DoSelect(index, pool);
480  }
481 }
482 
483 inline
485 {
486  Select(index, reset, 0);
487 }
488 
489 inline
491 {
492  return m_choice == e_Name;
493 }
494 
495 inline
497 {
498  return m_choice == e_Accession;
499 }
500 
501 inline
503 {
505  return *m_string;
506 }
507 
508 inline
510 {
512  return *m_string;
513 }
514 
515 inline
517 {
518  return m_choice == e_All_assemblies;
519 }
520 
521 inline
523 {
525 }
526 
527 ///////////////////////////////////////////////////////////
528 ////////////////// end of inline methods //////////////////
529 ///////////////////////////////////////////////////////////
530 
531 
532 
533 
534 
535 END_objects_SCOPE // namespace ncbi::objects::
536 
538 
539 
540 #endif // OBJECTS_TRACKMGR_TMGR_ASSEMBLYSPEC_BASE_HPP
Base class for all serializable objects.
Definition: serialbase.hpp:150
CTMgr_AssemblySpec_Base –.
static char UnassignedByte(void)
Definition: serialbase.hpp:181
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
static string UnassignedString(void)
Definition: serialbase.hpp:175
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
CTMgr_AssemblySpec_Base(const CTMgr_AssemblySpec_Base &)
C_Name & operator=(const C_Name &)
bool IsAccession(void) const
Check if variant Accession is selected.
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
bool CanGetName(void) const
Check if it is safe to call GetName method.
const TName & GetName(void) const
Get the Name member data.
TName & SetName(void)
Assign a value to Name data member.
TTax_id & SetTax_id(void)
Assign a value to Tax_id data member.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
bool IsAll_assemblies(void) const
Check if variant All_assemblies is selected.
bool IsName(void) const
Check if variant Name is selected.
bool IsSetTax_id(void) const
Check if a value has been assigned to Tax_id data member.
void SetAll_assemblies(void)
Select the variant.
const TAccession & GetAccession(void) const
Get the variant data.
TAccession & SetAccession(void)
Select the variant.
void ResetTax_id(void)
Reset Tax_id data member.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
NCBI_NS_NCBI::CSerialObject * m_object
E_Choice Which(void) const
Which variant is currently selected.
bool CanGetTax_id(void) const
Check if it is safe to call GetTax_id method.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
CTMgr_AssemblySpec_Base & operator=(const CTMgr_AssemblySpec_Base &)
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
TTax_id GetTax_id(void) const
Get the Tax_id member data.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
@ e_not_set
No variant selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const CConstRef< CSeq_id > GetAccession(const CSeq_id_Handle &id_handle)
bool IsAccession(const CSeq_id &id)
Definition: utilities.cpp:918
Defines to provide correct exporting from DLLs in Windows.
#define NCBI_TRACKMGR_EXPORT
Modified on Fri Sep 20 14:57:03 2024 by modify_doxy.py rev. 669887