NCBI C++ ToolKit
Int_fuzz_.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 Int_fuzz_.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/general/general.asn">general.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/general/general.def">general.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_GENERAL_INT_FUZZ_BASE_HPP
42 #define OBJECTS_GENERAL_INT_FUZZ_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
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 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_General
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///**** Int-fuzz **********************************************
69 ///*
70 ///* uncertainties in integer values
71 ///
72 /// CInt_fuzz_Base --
73 ///
74 
76 {
78 public:
79  // constructor
80  CInt_fuzz_Base(void);
81  // destructor
82  virtual ~CInt_fuzz_Base(void);
83 
84  // type info
86 
87  /////////////////////////////////////////////////////////////////////////////
88  /// max to min
89  ///
90  /// C_Range --
91  ///
92 
94  {
96  public:
97  // constructor
98  C_Range(void);
99  // destructor
100  ~C_Range(void);
101 
102  // type info
104 
105  // types
106  typedef TSeqPos TMax;
107  typedef TSeqPos TMin;
108 
109  // member index
110  enum class E_memberIndex {
111  e__allMandatory = 0,
112  e_max,
113  e_min
114  };
116 
117  // getters
118  // setters
119 
120  /// Check if a value has been assigned to Max data member.
121  ///
122  /// Data member Max is mandatory;
123  /// its type is defined as 'typedef TSeqPos TMax'
124  /// @return
125  /// - true, if a value has been assigned.
126  /// - false, otherwise.
127  bool IsSetMax(void) const;
128 
129  /// Check if it is safe to call GetMax method.
130  ///
131  /// @return
132  /// - true, if the data member is getatable.
133  /// - false, otherwise.
134  bool CanGetMax(void) const;
135 
136  /// Reset Max data member.
137  void ResetMax(void);
138 
139  /// Get the Max member data.
140  ///
141  /// @return
142  /// Copy of the member data.
143  TMax GetMax(void) const;
144 
145  /// Assign a value to Max data member.
146  ///
147  /// @param value
148  /// Value to assign
149  void SetMax(TMax value);
150 
151  /// Assign a value to Max data member.
152  ///
153  /// @return
154  /// Reference to the data value.
155  TMax& SetMax(void);
156 
157  /// Check if a value has been assigned to Min data member.
158  ///
159  /// Data member Min is mandatory;
160  /// its type is defined as 'typedef TSeqPos TMin'
161  /// @return
162  /// - true, if a value has been assigned.
163  /// - false, otherwise.
164  bool IsSetMin(void) const;
165 
166  /// Check if it is safe to call GetMin method.
167  ///
168  /// @return
169  /// - true, if the data member is getatable.
170  /// - false, otherwise.
171  bool CanGetMin(void) const;
172 
173  /// Reset Min data member.
174  void ResetMin(void);
175 
176  /// Get the Min member data.
177  ///
178  /// @return
179  /// Copy of the member data.
180  TMin GetMin(void) const;
181 
182  /// Assign a value to Min data member.
183  ///
184  /// @param value
185  /// Value to assign
186  void SetMin(TMin value);
187 
188  /// Assign a value to Min data member.
189  ///
190  /// @return
191  /// Reference to the data value.
192  TMin& SetMin(void);
193 
194  /// Reset the whole object
195  void Reset(void);
196 
197 
198  private:
199  // Prohibit copy constructor and assignment operator
200  C_Range(const C_Range&);
202 
203  // data
204  Uint4 m_set_State[1];
207  };
208  /// some limit value
209  enum ELim {
210  eLim_unk = 0, ///< unknown
211  eLim_gt = 1, ///< greater than
212  eLim_lt = 2, ///< less than
213  eLim_tr = 3, ///< space to right of position
214  eLim_tl = 4, ///< space to left of position
215  eLim_circle = 5, ///< artificial break at origin of circle
216  eLim_other = 255 ///< something else
217  };
218 
219  /// Access to ELim's attributes (values, names) as defined in spec
220  static const NCBI_NS_NCBI::CEnumeratedTypeValues* ENUM_METHOD_NAME(ELim)(void);
221 
222 
223  /// Choice variants.
224  enum E_Choice {
225  e_not_set = 0, ///< No variant selected
226  e_P_m, ///< plus or minus fixed amount
228  e_Pct, ///< % plus or minus (x10) 0-1000
230  e_Alt ///< set of alternatives for the integer
231  };
232  /// Maximum+1 value of the choice variant enumerator.
234  e_MaxChoice = 6 ///< == e_Alt+1
235  };
236 
237  /// Reset the whole object
238  virtual void Reset(void);
239 
240  /// Reset the selection (set it to e_not_set).
241  virtual void ResetSelection(void);
242 
243  /// Which variant is currently selected.
244  ///
245  /// @return
246  /// Choice state enumerator.
247  E_Choice Which(void) const;
248 
249  /// Verify selection, throw exception if it differs from the expected.
250  ///
251  /// @param index
252  /// Expected selection.
253  void CheckSelected(E_Choice index) const;
254 
255  /// Throw 'InvalidSelection' exception.
256  ///
257  /// @param index
258  /// Expected selection.
259  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
260 
261  /// Retrieve selection name (for diagnostic purposes).
262  ///
263  /// @param index
264  /// One of possible selection states.
265  /// @return
266  /// Name string.
267  static string SelectionName(E_Choice index);
268 
269  /// Select the requested variant if needed.
270  ///
271  /// @param index
272  /// New selection state.
273  /// @param reset
274  /// Flag that defines the resetting of the variant data. The data will
275  /// be reset if either the current selection differs from the new one,
276  /// or the flag is set to eDoResetVariant.
278  /// Select the requested variant if needed,
279  /// allocating CObject variants from memory pool.
280  void Select(E_Choice index,
281  EResetVariant reset,
282  CObjectMemoryPool* pool);
283 
284  // types
285  typedef TSeqPos TP_m;
286  typedef C_Range TRange;
287  typedef int TPct;
288  typedef ELim TLim;
289  typedef list< TSeqPos > TAlt;
290 
291  // getters
292  // setters
293 
294 
295  /// Check if variant P_m is selected.
296  ///
297  /// P_m type is defined as 'typedef TSeqPos TP_m'.
298  /// @return
299  /// - true, if the variant is selected.
300  /// - false, otherwise.
301  bool IsP_m(void) const;
302 
303  /// Get the variant data.
304  ///
305  /// @return
306  /// Copy of the variant data.
307  TP_m GetP_m(void) const;
308 
309  /// Select the variant.
310  ///
311  /// @return
312  /// Reference to the variant data.
313  TP_m& SetP_m(void);
314 
315  /// Select the variant and set its data.
316  ///
317  /// @param value
318  /// Variant data.
319  void SetP_m(TP_m value);
320 
321 
322  /// Check if variant Range is selected.
323  ///
324  /// Range type is defined as 'typedef C_Range TRange'.
325  /// @return
326  /// - true, if the variant is selected.
327  /// - false, otherwise.
328  bool IsRange(void) const;
329 
330  /// Get the variant data.
331  ///
332  /// @return
333  /// Reference to the data.
334  const TRange& GetRange(void) const;
335 
336  /// Select the variant.
337  ///
338  /// @return
339  /// Reference to the variant data.
340  TRange& SetRange(void);
341  /// Select the variant and set its data.
342  ///
343  /// @param value
344  /// Reference to the data.
345  void SetRange(TRange& value);
346 
347 
348  /// Check if variant Pct is selected.
349  ///
350  /// Pct type is defined as 'typedef int TPct'.
351  /// @return
352  /// - true, if the variant is selected.
353  /// - false, otherwise.
354  bool IsPct(void) const;
355 
356  /// Get the variant data.
357  ///
358  /// @return
359  /// Copy of the variant data.
360  TPct GetPct(void) const;
361 
362  /// Select the variant.
363  ///
364  /// @return
365  /// Reference to the variant data.
366  TPct& SetPct(void);
367 
368  /// Select the variant and set its data.
369  ///
370  /// @param value
371  /// Variant data.
372  void SetPct(TPct value);
373 
374 
375  /// Check if variant Lim is selected.
376  ///
377  /// Lim type is defined as 'typedef ELim TLim'.
378  /// @return
379  /// - true, if the variant is selected.
380  /// - false, otherwise.
381  bool IsLim(void) const;
382 
383  /// Get the variant data.
384  ///
385  /// @return
386  /// Copy of the variant data.
387  TLim GetLim(void) const;
388 
389  /// Select the variant.
390  ///
391  /// @return
392  /// Reference to the variant data.
393  TLim& SetLim(void);
394 
395  /// Select the variant and set its data.
396  ///
397  /// @param value
398  /// Variant data.
399  void SetLim(TLim value);
400 
401 
402  /// Check if variant Alt is selected.
403  ///
404  /// Alt type is defined as 'typedef list< TSeqPos > TAlt'.
405  /// @return
406  /// - true, if the variant is selected.
407  /// - false, otherwise.
408  bool IsAlt(void) const;
409 
410  /// Get the variant data.
411  ///
412  /// @return
413  /// Reference to the data.
414  const TAlt& GetAlt(void) const;
415 
416  /// Select the variant.
417  ///
418  /// @return
419  /// Reference to the variant data.
420  TAlt& SetAlt(void);
421 
422 
423 private:
424  // copy constructor and assignment operator
427  // choice state
429  // helper methods
430  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
431 
432  static const char* const sm_SelectionNames[];
433  // data
434  union {
438  NCBI_NS_NCBI::CUnionBuffer<TAlt> m_Alt;
439  NCBI_NS_NCBI::CSerialObject *m_object;
440  };
441 };
442 
443 /* @} */
444 
445 
446 
447 
448 
449 ///////////////////////////////////////////////////////////
450 ///////////////////// inline methods //////////////////////
451 ///////////////////////////////////////////////////////////
452 inline
454 {
455  return ((m_set_State[0] & 0x3) != 0);
456 }
457 
458 inline
460 {
461  return IsSetMax();
462 }
463 
464 inline
466 {
467  m_Max = 0;
468  m_set_State[0] &= ~0x3;
469 }
470 
471 inline
473 {
474  if (!CanGetMax()) {
475  ThrowUnassigned(0);
476  }
477  return m_Max;
478 }
479 
480 inline
482 {
483  m_Max = value;
484  m_set_State[0] |= 0x3;
485 }
486 
487 inline
489 {
490 #ifdef _DEBUG
491  if (!IsSetMax()) {
492  memset(&m_Max,UnassignedByte(),sizeof(m_Max));
493  }
494 #endif
495  m_set_State[0] |= 0x1;
496  return m_Max;
497 }
498 
499 inline
501 {
502  return ((m_set_State[0] & 0xc) != 0);
503 }
504 
505 inline
507 {
508  return IsSetMin();
509 }
510 
511 inline
513 {
514  m_Min = 0;
515  m_set_State[0] &= ~0xc;
516 }
517 
518 inline
520 {
521  if (!CanGetMin()) {
522  ThrowUnassigned(1);
523  }
524  return m_Min;
525 }
526 
527 inline
529 {
530  m_Min = value;
531  m_set_State[0] |= 0xc;
532 }
533 
534 inline
536 {
537 #ifdef _DEBUG
538  if (!IsSetMin()) {
539  memset(&m_Min,UnassignedByte(),sizeof(m_Min));
540  }
541 #endif
542  m_set_State[0] |= 0x4;
543  return m_Min;
544 }
545 
546 inline
548 {
549  return m_choice;
550 }
551 
552 inline
554 {
555  if ( m_choice != index )
556  ThrowInvalidSelection(index);
557 }
558 
559 inline
560 void CInt_fuzz_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
561 {
562  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
563  if ( m_choice != e_not_set )
564  ResetSelection();
565  DoSelect(index, pool);
566  }
567 }
568 
569 inline
571 {
572  Select(index, reset, 0);
573 }
574 
575 inline
576 bool CInt_fuzz_Base::IsP_m(void) const
577 {
578  return m_choice == e_P_m;
579 }
580 
581 inline
583 {
585  return m_P_m;
586 }
587 
588 inline
590 {
592  return m_P_m;
593 }
594 
595 inline
597 {
599  m_P_m = value;
600 }
601 
602 inline
603 bool CInt_fuzz_Base::IsRange(void) const
604 {
605  return m_choice == e_Range;
606 }
607 
608 inline
609 bool CInt_fuzz_Base::IsPct(void) const
610 {
611  return m_choice == e_Pct;
612 }
613 
614 inline
616 {
618  return m_Pct;
619 }
620 
621 inline
623 {
625  return m_Pct;
626 }
627 
628 inline
630 {
632  m_Pct = value;
633 }
634 
635 inline
636 bool CInt_fuzz_Base::IsLim(void) const
637 {
638  return m_choice == e_Lim;
639 }
640 
641 inline
643 {
645  return m_Lim;
646 }
647 
648 inline
650 {
652  return m_Lim;
653 }
654 
655 inline
657 {
659  m_Lim = value;
660 }
661 
662 inline
663 bool CInt_fuzz_Base::IsAlt(void) const
664 {
665  return m_choice == e_Alt;
666 }
667 
668 inline
670 {
672  return *m_Alt;
673 }
674 
675 inline
677 {
679  return *m_Alt;
680 }
681 
682 ///////////////////////////////////////////////////////////
683 ////////////////// end of inline methods //////////////////
684 ///////////////////////////////////////////////////////////
685 
686 
687 
688 
689 
690 END_objects_SCOPE // namespace ncbi::objects::
691 
693 
694 
695 #endif // OBJECTS_GENERAL_INT_FUZZ_BASE_HPP
**** Int-fuzz ********************************************** * * uncertainties in integer values
Definition: Int_fuzz_.hpp:76
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
static char UnassignedByte(void)
Definition: serialbase.hpp:181
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
@ 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
#define NCBI_GENERAL_EXPORT
Definition: ncbi_export.h:512
bool IsPct(void) const
Check if variant Pct is selected.
Definition: Int_fuzz_.hpp:609
TMin & SetMin(void)
Assign a value to Min data member.
Definition: Int_fuzz_.hpp:535
bool IsP_m(void) const
Check if variant P_m is selected.
Definition: Int_fuzz_.hpp:576
C_Range(const C_Range &)
bool IsLim(void) const
Check if variant Lim is selected.
Definition: Int_fuzz_.hpp:636
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Int_fuzz_.hpp:233
void ResetMin(void)
Reset Min data member.
Definition: Int_fuzz_.hpp:512
C_Range & operator=(const C_Range &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
CInt_fuzz_Base(const CInt_fuzz_Base &)
TAlt & SetAlt(void)
Select the variant.
Definition: Int_fuzz_.hpp:676
TPct GetPct(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:615
DECLARE_INTERNAL_TYPE_INFO()
bool IsSetMax(void) const
Check if a value has been assigned to Max data member.
Definition: Int_fuzz_.hpp:453
E_Choice m_choice
Definition: Int_fuzz_.hpp:428
CSerialObject Tparent
Definition: Int_fuzz_.hpp:77
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Int_fuzz_.hpp:553
TLim GetLim(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:642
TP_m & SetP_m(void)
Select the variant.
Definition: Int_fuzz_.hpp:589
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Int_fuzz_.cpp:101
TMax & SetMax(void)
Assign a value to Max data member.
Definition: Int_fuzz_.hpp:488
ELim
some limit value
Definition: Int_fuzz_.hpp:209
TMin GetMin(void) const
Get the Min member data.
Definition: Int_fuzz_.hpp:519
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Int_fuzz_.cpp:116
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
Definition: Int_fuzz_.hpp:115
E_Choice
Choice variants.
Definition: Int_fuzz_.hpp:224
NCBI_NS_NCBI::CUnionBuffer< TAlt > m_Alt
Definition: Int_fuzz_.hpp:438
CSerialObject Tparent
Definition: Int_fuzz_.hpp:95
list< TSeqPos > TAlt
Definition: Int_fuzz_.hpp:289
E_Choice Which(void) const
Which variant is currently selected.
Definition: Int_fuzz_.hpp:547
TLim & SetLim(void)
Select the variant.
Definition: Int_fuzz_.hpp:649
const TAlt & GetAlt(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:669
bool IsRange(void) const
Check if variant Range is selected.
Definition: Int_fuzz_.hpp:603
TPct & SetPct(void)
Select the variant.
Definition: Int_fuzz_.hpp:622
TMax GetMax(void) const
Get the Max member data.
Definition: Int_fuzz_.hpp:472
TP_m GetP_m(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:582
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Int_fuzz_.hpp:439
NCBI_NS_NCBI::CUnionBuffer< TAlt > m_Alt
Definition: Int_fuzz_.hpp:438
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Int_fuzz_.cpp:154
void ResetMax(void)
Reset Max data member.
Definition: Int_fuzz_.hpp:465
bool CanGetMax(void) const
Check if it is safe to call GetMax method.
Definition: Int_fuzz_.hpp:459
CInt_fuzz_Base & operator=(const CInt_fuzz_Base &)
bool CanGetMin(void) const
Check if it is safe to call GetMin method.
Definition: Int_fuzz_.hpp:506
bool IsSetMin(void) const
Check if a value has been assigned to Min data member.
Definition: Int_fuzz_.hpp:500
bool IsAlt(void) const
Check if variant Alt is selected.
Definition: Int_fuzz_.hpp:663
C_Range TRange
Definition: Int_fuzz_.hpp:286
@ e_not_set
No variant selected.
Definition: Int_fuzz_.hpp:225
@ e_Pct
% plus or minus (x10) 0-1000
Definition: Int_fuzz_.hpp:228
@ e_Alt
set of alternatives for the integer
Definition: Int_fuzz_.hpp:230
@ e_P_m
plus or minus fixed amount
Definition: Int_fuzz_.hpp:226
@ e_not_set
Modified on Wed Mar 27 11:18:01 2024 by modify_doxy.py rev. 669887