NCBI C++ ToolKit
Score_.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 Score_.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/seqalign/seqalign.asn">seqalign.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqalign/seqalign.def">seqalign.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_SEQALIGN_SCORE_BASE_HPP
42 #define OBJECTS_SEQALIGN_SCORE_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
47 
48 #ifndef BEGIN_objects_SCOPE
49 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
50 # define END_objects_SCOPE END_SCOPE(objects)
51 #endif
52 BEGIN_objects_SCOPE // namespace ncbi::objects::
53 
54 
55 // forward declarations
56 class CObject_id;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Seqalign
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 /// use of Score is discouraged for external ASN.1 specifications
69 ///
70 /// CScore_Base --
71 ///
72 
74 {
76 public:
77  // constructor
78  CScore_Base(void);
79  // destructor
80  virtual ~CScore_Base(void);
81 
82  // type info
84 
85  /////////////////////////////////////////////////////////////////////////////
86  ///
87  /// C_Value --
88  ///
89 
91  {
93  public:
94  // constructor
95  C_Value(void);
96  // destructor
97  ~C_Value(void);
98 
99  // type info
101 
102 
103  /// Choice variants.
104  enum E_Choice {
105  e_not_set = 0, ///< No variant selected
107  e_Int
108  };
109  /// Maximum+1 value of the choice variant enumerator.
111  e_MaxChoice = 3 ///< == e_Int+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.
144  static string SelectionName(E_Choice index);
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,
158  EResetVariant reset,
159  CObjectMemoryPool* pool);
160 
161  // types
162  typedef double TReal;
163  typedef int TInt;
164 
165  // getters
166  // setters
167 
168 
169  /// Check if variant Real is selected.
170  ///
171  /// Real type is defined as 'typedef double TReal'.
172  /// @return
173  /// - true, if the variant is selected.
174  /// - false, otherwise.
175  bool IsReal(void) const;
176 
177  /// Get the variant data.
178  ///
179  /// @return
180  /// Copy of the variant data.
181  TReal GetReal(void) const;
182 
183  /// Select the variant.
184  ///
185  /// @return
186  /// Reference to the variant data.
187  TReal& SetReal(void);
188 
189  /// Select the variant and set its data.
190  ///
191  /// @param value
192  /// Variant data.
193  void SetReal(TReal value);
194 
195 
196  /// Check if variant Int is selected.
197  ///
198  /// Int type is defined as 'typedef int TInt'.
199  /// @return
200  /// - true, if the variant is selected.
201  /// - false, otherwise.
202  bool IsInt(void) const;
203 
204  /// Get the variant data.
205  ///
206  /// @return
207  /// Copy of the variant data.
208  TInt GetInt(void) const;
209 
210  /// Select the variant.
211  ///
212  /// @return
213  /// Reference to the variant data.
214  TInt& SetInt(void);
215 
216  /// Select the variant and set its data.
217  ///
218  /// @param value
219  /// Variant data.
220  void SetInt(TInt value);
221 
222 
223  private:
224  // copy constructor and assignment operator
225  C_Value(const C_Value& );
227  // choice state
229  // helper methods
230  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
231 
232  static const char* const sm_SelectionNames[];
233  // data
234  union {
237  };
238  };
239  // types
240  typedef CObject_id TId;
241  typedef C_Value TValue;
242 
243  // member index
244  enum class E_memberIndex {
245  e__allMandatory = 0,
246  e_id,
247  e_value
248  };
250 
251  // getters
252  // setters
253 
254  /// Check if a value has been assigned to Id data member.
255  ///
256  /// Data member Id is optional;
257  /// its type is defined as 'typedef CObject_id TId'
258  /// @return
259  /// - true, if a value has been assigned.
260  /// - false, otherwise.
261  bool IsSetId(void) const;
262 
263  /// Check if it is safe to call GetId method.
264  ///
265  /// @return
266  /// - true, if the data member is getatable.
267  /// - false, otherwise.
268  bool CanGetId(void) const;
269 
270  /// Reset Id data member.
271  void ResetId(void);
272 
273  /// Get the Id member data.
274  ///
275  /// @return
276  /// Reference to the member data.
277  const TId& GetId(void) const;
278 
279  /// Assign a value to Id data member.
280  ///
281  /// @param value
282  /// Reference to value.
283  void SetId(TId& value);
284 
285  /// Assign a value to Id data member.
286  ///
287  /// @return
288  /// Reference to the data value.
289  TId& SetId(void);
290 
291  /// Check if a value has been assigned to Value data member.
292  ///
293  /// Data member Value is mandatory;
294  /// its type is defined as 'typedef C_Value TValue'
295  /// @return
296  /// - true, if a value has been assigned.
297  /// - false, otherwise.
298  bool IsSetValue(void) const;
299 
300  /// Check if it is safe to call GetValue method.
301  ///
302  /// @return
303  /// - true, if the data member is getatable.
304  /// - false, otherwise.
305  bool CanGetValue(void) const;
306 
307  /// Reset Value data member.
308  void ResetValue(void);
309 
310  /// Get the Value member data.
311  ///
312  /// @return
313  /// Reference to the member data.
314  const TValue& GetValue(void) const;
315 
316  /// Assign a value to Value data member.
317  ///
318  /// @return
319  /// Reference to the data value.
320  TValue& SetValue(void);
321 
322  /// Reset the whole object
323  virtual void Reset(void);
324 
325  virtual void DoNotDeleteThisObject(void);
326 
327 
328 private:
329  // Prohibit copy constructor and assignment operator
332 
333  // data
334  Uint4 m_set_State[1];
337 };
338 
339 /* @} */
340 
341 
342 
343 
344 
345 ///////////////////////////////////////////////////////////
346 ///////////////////// inline methods //////////////////////
347 ///////////////////////////////////////////////////////////
348 inline
350 {
351  return m_choice;
352 }
353 
354 inline
356 {
357  if ( m_choice != index )
358  ThrowInvalidSelection(index);
359 }
360 
361 inline
362 void CScore_Base::C_Value::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
363 {
364  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
365  if ( m_choice != e_not_set )
366  ResetSelection();
367  DoSelect(index, pool);
368  }
369 }
370 
371 inline
373 {
374  Select(index, reset, 0);
375 }
376 
377 inline
379 {
380  return m_choice == e_Real;
381 }
382 
383 inline
385 {
386  CheckSelected(e_Real);
387  return m_Real;
388 }
389 
390 inline
392 {
393  Select(e_Real, NCBI_NS_NCBI::eDoNotResetVariant);
394  return m_Real;
395 }
396 
397 inline
399 {
400  Select(e_Real, NCBI_NS_NCBI::eDoNotResetVariant);
401  m_Real = value;
402 }
403 
404 inline
406 {
407  return m_choice == e_Int;
408 }
409 
410 inline
412 {
413  CheckSelected(e_Int);
414  return m_Int;
415 }
416 
417 inline
419 {
420  Select(e_Int, NCBI_NS_NCBI::eDoNotResetVariant);
421  return m_Int;
422 }
423 
424 inline
426 {
427  Select(e_Int, NCBI_NS_NCBI::eDoNotResetVariant);
428  m_Int = value;
429 }
430 
431 inline
432 bool CScore_Base::IsSetId(void) const
433 {
434  return m_Id.NotEmpty();
435 }
436 
437 inline
438 bool CScore_Base::CanGetId(void) const
439 {
440  return IsSetId();
441 }
442 
443 inline
445 {
446  if (!CanGetId()) {
447  ThrowUnassigned(0);
448  }
449  return (*m_Id);
450 }
451 
452 inline
453 bool CScore_Base::IsSetValue(void) const
454 {
455  return ((m_set_State[0] & 0xc) != 0);
456 }
457 
458 inline
459 bool CScore_Base::CanGetValue(void) const
460 {
461  return IsSetValue();
462 }
463 
464 inline
466 {
467  if (!CanGetValue()) {
468  ThrowUnassigned(1);
469  }
470  return m_Value;
471 }
472 
473 inline
475 {
476  m_set_State[0] |= 0x4;
477  return m_Value;
478 }
479 
480 ///////////////////////////////////////////////////////////
481 ////////////////// end of inline methods //////////////////
482 ///////////////////////////////////////////////////////////
483 
484 
485 
486 
487 
488 END_objects_SCOPE // namespace ncbi::objects::
489 
491 
492 
493 #endif // OBJECTS_SEQALIGN_SCORE_BASE_HPP
CRef –.
Definition: ncbiobj.hpp:618
C_Value –.
Definition: Score_.hpp:91
use of Score is discouraged for external ASN.1 specifications
Definition: Score_.hpp:74
Base class for all serializable objects.
Definition: serialbase.hpp:150
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
virtual void DoNotDeleteThisObject(void)
Mark this object as not allocated in heap – do not delete this object.
Definition: ncbiobj.cpp:884
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_SEQALIGN_EXPORT
Definition: ncbi_export.h:744
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Score_.hpp:432
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Score_.hpp:355
E_Choice
Choice variants.
Definition: Score_.hpp:104
E_Choice Which(void) const
Which variant is currently selected.
Definition: Score_.hpp:349
TInt & SetInt(void)
Select the variant.
Definition: Score_.hpp:418
C_Value & operator=(const C_Value &)
TValue & SetValue(void)
Assign a value to Value data member.
Definition: Score_.hpp:474
bool IsReal(void) const
Check if variant Real is selected.
Definition: Score_.hpp:378
CSerialObject Tparent
Definition: Score_.hpp:92
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Score_.hpp:110
TReal & SetReal(void)
Select the variant.
Definition: Score_.hpp:391
bool CanGetValue(void) const
Check if it is safe to call GetValue method.
Definition: Score_.hpp:459
Uint4 m_set_State[1]
Definition: Score_.hpp:334
CScore_Base & operator=(const CScore_Base &)
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CObject_id TId
Definition: Score_.hpp:240
CScore_Base(const CScore_Base &)
TInt GetInt(void) const
Get the variant data.
Definition: Score_.hpp:411
bool IsInt(void) const
Check if variant Int is selected.
Definition: Score_.hpp:405
DECLARE_INTERNAL_TYPE_INFO()
C_Value TValue
Definition: Score_.hpp:241
const TValue & GetValue(void) const
Get the Value member data.
Definition: Score_.hpp:465
bool CanGetId(void) const
Check if it is safe to call GetId method.
Definition: Score_.hpp:438
bool IsSetValue(void) const
Check if a value has been assigned to Value data member.
Definition: Score_.hpp:453
CSerialObject Tparent
Definition: Score_.hpp:75
C_Value m_Value
Definition: Score_.hpp:336
C_Value(const C_Value &)
CRef< TId > m_Id
Definition: Score_.hpp:335
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
Definition: Score_.hpp:249
TReal GetReal(void) const
Get the variant data.
Definition: Score_.hpp:384
const TId & GetId(void) const
Get the Id member data.
Definition: Score_.hpp:444
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Jun 19 17:03:43 2024 by modify_doxy.py rev. 669887