NCBI C++ ToolKit
Delta_item_.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 Delta_item_.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/seqfeat/seqfeat.asn">seqfeat.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqfeat/seqfeat.def">seqfeat.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_SEQFEAT_DELTA_ITEM_BASE_HPP
42 #define OBJECTS_SEQFEAT_DELTA_ITEM_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 CInt_fuzz;
57 class CSeq_literal;
58 class CSeq_loc;
59 
60 
61 // generated classes
62 
63 
64 /** @addtogroup dataspec_NCBI_Variation
65  *
66  * @{
67  */
68 
69 /////////////////////////////////////////////////////////////////////////////
70 ///
71 /// CDelta_item_Base --
72 ///
73 
75 {
77 public:
78  // constructor
79  CDelta_item_Base(void);
80  // destructor
81  virtual ~CDelta_item_Base(void);
82 
83  // type info
85 
86  /////////////////////////////////////////////////////////////////////////////
87  ///
88  /// C_Seq --
89  ///
90 
92  {
94  public:
95  // constructor
96  C_Seq(void);
97  // destructor
98  ~C_Seq(void);
99 
100  // type info
102 
103 
104  /// Choice variants.
105  enum E_Choice {
106  e_not_set = 0, ///< No variant selected
109  e_This ///<same location as variation-ref itself
110  };
111  /// Maximum+1 value of the choice variant enumerator.
113  e_MaxChoice = 4 ///< == e_This+1
114  };
115 
116  /// Reset the whole object
117  void Reset(void);
118 
119  /// Reset the selection (set it to e_not_set).
120  void ResetSelection(void);
121 
122  /// Which variant is currently selected.
123  ///
124  /// @return
125  /// Choice state enumerator.
126  E_Choice Which(void) const;
127 
128  /// Verify selection, throw exception if it differs from the expected.
129  ///
130  /// @param index
131  /// Expected selection.
132  void CheckSelected(E_Choice index) const;
133 
134  /// Throw 'InvalidSelection' exception.
135  ///
136  /// @param index
137  /// Expected selection.
138  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
139 
140  /// Retrieve selection name (for diagnostic purposes).
141  ///
142  /// @param index
143  /// One of possible selection states.
144  /// @return
145  /// Name string.
146  static string SelectionName(E_Choice index);
147 
148  /// Select the requested variant if needed.
149  ///
150  /// @param index
151  /// New selection state.
152  /// @param reset
153  /// Flag that defines the resetting of the variant data. The data will
154  /// be reset if either the current selection differs from the new one,
155  /// or the flag is set to eDoResetVariant.
157  /// Select the requested variant if needed,
158  /// allocating CObject variants from memory pool.
159  void Select(E_Choice index,
160  EResetVariant reset,
161  CObjectMemoryPool* pool);
162 
163  // types
165  typedef CSeq_loc TLoc;
166 
167  // getters
168  // setters
169 
170 
171  /// Check if variant Literal is selected.
172  ///
173  /// Literal type is defined as 'typedef CSeq_literal TLiteral'.
174  /// @return
175  /// - true, if the variant is selected.
176  /// - false, otherwise.
177  bool IsLiteral(void) const;
178 
179  /// Get the variant data.
180  ///
181  /// @return
182  /// Reference to the data.
183  const TLiteral& GetLiteral(void) const;
184 
185  /// Select the variant.
186  ///
187  /// @return
188  /// Reference to the variant data.
189  TLiteral& SetLiteral(void);
190  /// Select the variant and set its data.
191  ///
192  /// @param value
193  /// Reference to the data.
194  void SetLiteral(TLiteral& value);
195 
196 
197  /// Check if variant Loc is selected.
198  ///
199  /// Loc type is defined as 'typedef CSeq_loc TLoc'.
200  /// @return
201  /// - true, if the variant is selected.
202  /// - false, otherwise.
203  bool IsLoc(void) const;
204 
205  /// Get the variant data.
206  ///
207  /// @return
208  /// Reference to the data.
209  const TLoc& GetLoc(void) const;
210 
211  /// Select the variant.
212  ///
213  /// @return
214  /// Reference to the variant data.
215  TLoc& SetLoc(void);
216  /// Select the variant and set its data.
217  ///
218  /// @param value
219  /// Reference to the data.
220  void SetLoc(TLoc& value);
221 
222 
223  /// Check if variant This is selected.
224  ///
225  /// @return
226  /// - true, if the variant is selected.
227  /// - false, otherwise.
228  bool IsThis(void) const;
229 
230  /// Select the variant.
231  void SetThis(void);
232 
233 
234  private:
235  // copy constructor and assignment operator
236  C_Seq(const C_Seq& );
237  C_Seq& operator=(const C_Seq& );
238  // choice state
240  // helper methods
241  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
242 
243  static const char* const sm_SelectionNames[];
244  // data
245  union {
246  NCBI_NS_NCBI::CSerialObject *m_object;
247  };
248  };
249  enum EAction {
250  eAction_morph = 0, ///< replace len(seq) positions starting with location.start with seq
251  eAction_offset = 1, ///< go downstream by distance specified by multiplier (upstream if < 0), in genomic context.
252  eAction_del_at = 2, ///< excise sequence at location if multiplier is specified, delete len(location)*multiplier positions downstream
253  eAction_ins_before = 3 ///< insert seq before the location.start
254  };
255 
256  /// Access to EAction's attributes (values, names) as defined in spec
257  static const NCBI_NS_NCBI::CEnumeratedTypeValues* ENUM_METHOD_NAME(EAction)(void);
258 
259  // types
260  typedef C_Seq TSeq;
261  typedef int TMultiplier;
263  typedef int TAction;
264 
265  // member index
266  enum class E_memberIndex {
267  e__allMandatory = 0,
268  e_seq,
269  e_multiplier,
270  e_multiplier_fuzz,
271  e_action
272  };
274 
275  // getters
276  // setters
277 
278  /// Check if a value has been assigned to Seq data member.
279  ///
280  /// Data member Seq is optional;
281  /// its type is defined as 'typedef C_Seq TSeq'
282  /// @return
283  /// - true, if a value has been assigned.
284  /// - false, otherwise.
285  bool IsSetSeq(void) const;
286 
287  /// Check if it is safe to call GetSeq method.
288  ///
289  /// @return
290  /// - true, if the data member is getatable.
291  /// - false, otherwise.
292  bool CanGetSeq(void) const;
293 
294  /// Reset Seq data member.
295  void ResetSeq(void);
296 
297  /// Get the Seq member data.
298  ///
299  /// @return
300  /// Reference to the member data.
301  const TSeq& GetSeq(void) const;
302 
303  /// Assign a value to Seq data member.
304  ///
305  /// @param value
306  /// Reference to value.
307  void SetSeq(TSeq& value);
308 
309  /// Assign a value to Seq data member.
310  ///
311  /// @return
312  /// Reference to the data value.
313  TSeq& SetSeq(void);
314 
315  /// Multiplier allows representing a tandem, e.g. ATATAT as AT*3
316  /// This allows describing CNV/SSR where delta=self with a
317  /// multiplier which specifies the count of the repeat unit.
318  ///assumed 1 if not specified.
319  /// Check if a value has been assigned to Multiplier data member.
320  ///
321  /// Data member Multiplier is optional;
322  /// its type is defined as 'typedef int TMultiplier'
323  /// @return
324  /// - true, if a value has been assigned.
325  /// - false, otherwise.
326  bool IsSetMultiplier(void) const;
327 
328  /// Check if it is safe to call GetMultiplier method.
329  ///
330  /// @return
331  /// - true, if the data member is getatable.
332  /// - false, otherwise.
333  bool CanGetMultiplier(void) const;
334 
335  /// Reset Multiplier data member.
336  void ResetMultiplier(void);
337 
338  /// Get the Multiplier member data.
339  ///
340  /// @return
341  /// Copy of the member data.
342  TMultiplier GetMultiplier(void) const;
343 
344  /// Assign a value to Multiplier data member.
345  ///
346  /// @param value
347  /// Value to assign
348  void SetMultiplier(TMultiplier value);
349 
350  /// Assign a value to Multiplier data member.
351  ///
352  /// @return
353  /// Reference to the data value.
354  TMultiplier& SetMultiplier(void);
355 
356  /// Check if a value has been assigned to Multiplier_fuzz data member.
357  ///
358  /// Data member Multiplier_fuzz is optional;
359  /// its type is defined as 'typedef CInt_fuzz TMultiplier_fuzz'
360  /// @return
361  /// - true, if a value has been assigned.
362  /// - false, otherwise.
363  bool IsSetMultiplier_fuzz(void) const;
364 
365  /// Check if it is safe to call GetMultiplier_fuzz method.
366  ///
367  /// @return
368  /// - true, if the data member is getatable.
369  /// - false, otherwise.
370  bool CanGetMultiplier_fuzz(void) const;
371 
372  /// Reset Multiplier_fuzz data member.
373  void ResetMultiplier_fuzz(void);
374 
375  /// Get the Multiplier_fuzz member data.
376  ///
377  /// @return
378  /// Reference to the member data.
379  const TMultiplier_fuzz& GetMultiplier_fuzz(void) const;
380 
381  /// Assign a value to Multiplier_fuzz data member.
382  ///
383  /// @param value
384  /// Reference to value.
385  void SetMultiplier_fuzz(TMultiplier_fuzz& value);
386 
387  /// Assign a value to Multiplier_fuzz data member.
388  ///
389  /// @return
390  /// Reference to the data value.
391  TMultiplier_fuzz& SetMultiplier_fuzz(void);
392 
393  /// Check if a value has been assigned to Action data member.
394  ///
395  /// Data member Action is optional with default eAction_morph;
396  /// its type is defined as 'typedef int TAction'
397  /// @return
398  /// - true, if a value has been assigned.
399  /// - false, otherwise.
400  bool IsSetAction(void) const;
401 
402  /// Check if it is safe to call GetAction method.
403  ///
404  /// @return
405  /// - true, if the data member is getatable.
406  /// - false, otherwise.
407  bool CanGetAction(void) const;
408 
409  /// Reset Action data member.
410  void ResetAction(void);
411 
412  /// Assign default value to Action data member.
413  void SetDefaultAction(void);
414 
415  /// Get the Action member data.
416  ///
417  /// @return
418  /// Copy of the member data.
419  TAction GetAction(void) const;
420 
421  /// Assign a value to Action data member.
422  ///
423  /// @param value
424  /// Value to assign
425  void SetAction(TAction value);
426 
427  /// Assign a value to Action data member.
428  ///
429  /// @return
430  /// Reference to the data value.
431  TAction& SetAction(void);
432 
433  /// Reset the whole object
434  virtual void Reset(void);
435 
436 
437 private:
438  // Prohibit copy constructor and assignment operator
441 
442  // data
443  Uint4 m_set_State[1];
447  int m_Action;
448 };
449 
450 /* @} */
451 
452 
453 
454 
455 
456 ///////////////////////////////////////////////////////////
457 ///////////////////// inline methods //////////////////////
458 ///////////////////////////////////////////////////////////
459 inline
461 {
462  return m_choice;
463 }
464 
465 inline
467 {
468  if ( m_choice != index )
469  ThrowInvalidSelection(index);
470 }
471 
472 inline
473 void CDelta_item_Base::C_Seq::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
474 {
475  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
476  if ( m_choice != e_not_set )
477  ResetSelection();
478  DoSelect(index, pool);
479  }
480 }
481 
482 inline
484 {
485  Select(index, reset, 0);
486 }
487 
488 inline
490 {
491  return m_choice == e_Literal;
492 }
493 
494 inline
496 {
497  return m_choice == e_Loc;
498 }
499 
500 inline
502 {
503  return m_choice == e_This;
504 }
505 
506 inline
508 {
509  Select(e_This, NCBI_NS_NCBI::eDoNotResetVariant);
510 }
511 
512 inline
514 {
515  return m_Seq.NotEmpty();
516 }
517 
518 inline
520 {
521  return IsSetSeq();
522 }
523 
524 inline
526 {
527  if (!CanGetSeq()) {
528  ThrowUnassigned(0);
529  }
530  return (*m_Seq);
531 }
532 
533 inline
535 {
536  return ((m_set_State[0] & 0xc) != 0);
537 }
538 
539 inline
541 {
542  return IsSetMultiplier();
543 }
544 
545 inline
547 {
548  m_Multiplier = 0;
549  m_set_State[0] &= ~0xc;
550 }
551 
552 inline
554 {
555  if (!CanGetMultiplier()) {
556  ThrowUnassigned(1);
557  }
558  return m_Multiplier;
559 }
560 
561 inline
563 {
565  m_set_State[0] |= 0xc;
566 }
567 
568 inline
570 {
571 #ifdef _DEBUG
572  if (!IsSetMultiplier()) {
573  memset(&m_Multiplier,UnassignedByte(),sizeof(m_Multiplier));
574  }
575 #endif
576  m_set_State[0] |= 0x4;
577  return m_Multiplier;
578 }
579 
580 inline
582 {
583  return m_Multiplier_fuzz.NotEmpty();
584 }
585 
586 inline
588 {
589  return IsSetMultiplier_fuzz();
590 }
591 
592 inline
594 {
595  if (!CanGetMultiplier_fuzz()) {
596  ThrowUnassigned(2);
597  }
598  return (*m_Multiplier_fuzz);
599 }
600 
601 inline
603 {
604  return ((m_set_State[0] & 0xc0) != 0);
605 }
606 
607 inline
609 {
610  return true;
611 }
612 
613 inline
615 {
617  m_set_State[0] &= ~0xc0;
618 }
619 
620 inline
622 {
623  ResetAction();
624 }
625 
626 inline
628 {
629  return m_Action;
630 }
631 
632 inline
634 {
635  m_Action = value;
636  m_set_State[0] |= 0xc0;
637 }
638 
639 inline
641 {
642 #ifdef _DEBUG
643  if (!IsSetAction()) {
644  memset(&m_Action,UnassignedByte(),sizeof(m_Action));
645  }
646 #endif
647  m_set_State[0] |= 0x40;
648  return m_Action;
649 }
650 
651 ///////////////////////////////////////////////////////////
652 ////////////////// end of inline methods //////////////////
653 ///////////////////////////////////////////////////////////
654 
655 
656 
657 
658 
659 END_objects_SCOPE // namespace ncbi::objects::
660 
662 
663 
664 #endif // OBJECTS_SEQFEAT_DELTA_ITEM_BASE_HPP
CDelta_item_Base –.
Definition: Delta_item_.hpp:75
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
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_SEQFEAT_EXPORT
Definition: ncbi_export.h:768
NCBI_NS_NCBI::CSerialObject * m_object
TAction GetAction(void) const
Get the Action member data.
bool CanGetMultiplier(void) const
Check if it is safe to call GetMultiplier method.
E_Choice Which(void) const
Which variant is currently selected.
CRef< TSeq > m_Seq
const TMultiplier_fuzz & GetMultiplier_fuzz(void) const
Get the Multiplier_fuzz member data.
CDelta_item_Base(const CDelta_item_Base &)
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsSetSeq(void) const
Check if a value has been assigned to Seq data member.
bool IsSetAction(void) const
Check if a value has been assigned to Action data member.
TAction & SetAction(void)
Assign a value to Action data member.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TSeq & GetSeq(void) const
Get the Seq member data.
C_Seq(const C_Seq &)
void SetThis(void)
Select the variant.
CSerialObject Tparent
Definition: Delta_item_.hpp:76
void ResetAction(void)
Reset Action data member.
CDelta_item_Base & operator=(const CDelta_item_Base &)
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
CInt_fuzz TMultiplier_fuzz
TMultiplier GetMultiplier(void) const
Get the Multiplier member data.
bool IsSetMultiplier_fuzz(void) const
Check if a value has been assigned to Multiplier_fuzz data member.
bool CanGetAction(void) const
Check if it is safe to call GetAction method.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
Tparent::CMemberIndex< E_memberIndex, 5 > TmemberIndex
bool IsLiteral(void) const
Check if variant Literal is selected.
TMultiplier & SetMultiplier(void)
Assign a value to Multiplier data member.
Uint4 m_set_State[1]
bool IsSetMultiplier(void) const
Multiplier allows representing a tandem, e.g.
E_Choice
Choice variants.
void ResetMultiplier(void)
Reset Multiplier data member.
void SetDefaultAction(void)
Assign default value to Action data member.
bool CanGetMultiplier_fuzz(void) const
Check if it is safe to call GetMultiplier_fuzz method.
bool IsThis(void) const
Check if variant This is selected.
bool IsLoc(void) const
Check if variant Loc is selected.
CRef< TMultiplier_fuzz > m_Multiplier_fuzz
bool CanGetSeq(void) const
Check if it is safe to call GetSeq method.
C_Seq & operator=(const C_Seq &)
@ eAction_morph
replace len(seq) positions starting with location.start with seq
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int GetLoc(const string &acc, const string &pat, CSeq_loc &loc, CScope &scope)
Modified on Thu Jul 11 17:53:47 2024 by modify_doxy.py rev. 669887