NCBI C++ ToolKit
Seq_hist_.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 Seq_hist_.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/seq/seq.asn">seq.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seq/seq.def">seq.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_SEQ_SEQ_HIST_BASE_HPP
42 #define OBJECTS_SEQ_SEQ_HIST_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 // forward declarations
60 class CDate;
61 class CSeq_align;
62 class CSeq_hist_rec;
63 
64 
65 // generated classes
66 
67 
68 /** @addtogroup dataspec_NCBI_Sequence
69  *
70  * @{
71  */
72 
73 /////////////////////////////////////////////////////////////////////////////
74 ///*** Sequence History Record ***********************************
75 ///** assembly = records how seq was assembled from others
76 ///** replaces = records sequences made obsolete by this one
77 ///** replaced-by = this seq is made obsolete by another(s)
78 ///
79 /// CSeq_hist_Base --
80 ///
81 
83 {
85 public:
86  // constructor
87  CSeq_hist_Base(void);
88  // destructor
89  virtual ~CSeq_hist_Base(void);
90 
91  // type info
93 
94  /////////////////////////////////////////////////////////////////////////////
95  ///
96  /// C_Deleted --
97  ///
98 
100  {
102  public:
103  // constructor
104  C_Deleted(void);
105  // destructor
106  ~C_Deleted(void);
107 
108  // type info
110 
111 
112  /// Choice variants.
113  enum E_Choice {
114  e_not_set = 0, ///< No variant selected
116  e_Date
117  };
118  /// Maximum+1 value of the choice variant enumerator.
120  e_MaxChoice = 3 ///< == e_Date+1
121  };
122 
123  /// Reset the whole object
124  void Reset(void);
125 
126  /// Reset the selection (set it to e_not_set).
127  void ResetSelection(void);
128 
129  /// Which variant is currently selected.
130  ///
131  /// @return
132  /// Choice state enumerator.
133  E_Choice Which(void) const;
134 
135  /// Verify selection, throw exception if it differs from the expected.
136  ///
137  /// @param index
138  /// Expected selection.
139  void CheckSelected(E_Choice index) const;
140 
141  /// Throw 'InvalidSelection' exception.
142  ///
143  /// @param index
144  /// Expected selection.
145  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
146 
147  /// Retrieve selection name (for diagnostic purposes).
148  ///
149  /// @param index
150  /// One of possible selection states.
151  /// @return
152  /// Name string.
153  static string SelectionName(E_Choice index);
154 
155  /// Select the requested variant if needed.
156  ///
157  /// @param index
158  /// New selection state.
159  /// @param reset
160  /// Flag that defines the resetting of the variant data. The data will
161  /// be reset if either the current selection differs from the new one,
162  /// or the flag is set to eDoResetVariant.
164  /// Select the requested variant if needed,
165  /// allocating CObject variants from memory pool.
166  void Select(E_Choice index,
167  EResetVariant reset,
168  CObjectMemoryPool* pool);
169 
170  // types
171  typedef bool TBool;
172  typedef CDate TDate;
173 
174  // getters
175  // setters
176 
177 
178  /// Check if variant Bool is selected.
179  ///
180  /// Bool type is defined as 'typedef bool TBool'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsBool(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Copy of the variant data.
190  TBool GetBool(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TBool& SetBool(void);
197 
198  /// Select the variant and set its data.
199  ///
200  /// @param value
201  /// Variant data.
202  void SetBool(TBool value);
203 
204 
205  /// Check if variant Date is selected.
206  ///
207  /// Date type is defined as 'typedef CDate TDate'.
208  /// @return
209  /// - true, if the variant is selected.
210  /// - false, otherwise.
211  bool IsDate(void) const;
212 
213  /// Get the variant data.
214  ///
215  /// @return
216  /// Reference to the data.
217  const TDate& GetDate(void) const;
218 
219  /// Select the variant.
220  ///
221  /// @return
222  /// Reference to the variant data.
223  TDate& SetDate(void);
224  /// Select the variant and set its data.
225  ///
226  /// @param value
227  /// Reference to the data.
228  void SetDate(TDate& value);
229 
230 
231  private:
232  // copy constructor and assignment operator
235  // choice state
237  // helper methods
238  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
239 
240  static const char* const sm_SelectionNames[];
241  // data
242  union {
244  NCBI_NS_NCBI::CSerialObject *m_object;
245  };
246  };
247  // types
248  typedef list< CRef< CSeq_align > > TAssembly;
252 
253  // member index
254  enum class E_memberIndex {
255  e__allMandatory = 0,
256  e_assembly,
257  e_replaces,
258  e_replaced_by,
259  e_deleted
260  };
262 
263  // getters
264  // setters
265 
266  /// how was this assembled?
267  /// Check if a value has been assigned to Assembly data member.
268  ///
269  /// Data member Assembly is optional;
270  /// its type is defined as 'typedef list< CRef< CSeq_align > > TAssembly'
271  /// @return
272  /// - true, if a value has been assigned.
273  /// - false, otherwise.
274  bool IsSetAssembly(void) const;
275 
276  /// Check if it is safe to call GetAssembly method.
277  ///
278  /// @return
279  /// - true, if the data member is getatable.
280  /// - false, otherwise.
281  bool CanGetAssembly(void) const;
282 
283  /// Reset Assembly data member.
284  void ResetAssembly(void);
285 
286  /// Get the Assembly member data.
287  ///
288  /// @return
289  /// Reference to the member data.
290  const TAssembly& GetAssembly(void) const;
291 
292  /// Assign a value to Assembly data member.
293  ///
294  /// @return
295  /// Reference to the data value.
296  TAssembly& SetAssembly(void);
297 
298  /// seq makes these seqs obsolete
299  /// Check if a value has been assigned to Replaces data member.
300  ///
301  /// Data member Replaces is optional;
302  /// its type is defined as 'typedef CSeq_hist_rec TReplaces'
303  /// @return
304  /// - true, if a value has been assigned.
305  /// - false, otherwise.
306  bool IsSetReplaces(void) const;
307 
308  /// Check if it is safe to call GetReplaces method.
309  ///
310  /// @return
311  /// - true, if the data member is getatable.
312  /// - false, otherwise.
313  bool CanGetReplaces(void) const;
314 
315  /// Reset Replaces data member.
316  void ResetReplaces(void);
317 
318  /// Get the Replaces member data.
319  ///
320  /// @return
321  /// Reference to the member data.
322  const TReplaces& GetReplaces(void) const;
323 
324  /// Assign a value to Replaces data member.
325  ///
326  /// @param value
327  /// Reference to value.
328  void SetReplaces(TReplaces& value);
329 
330  /// Assign a value to Replaces data member.
331  ///
332  /// @return
333  /// Reference to the data value.
334  TReplaces& SetReplaces(void);
335 
336  /// these seqs make this one obsolete
337  /// Check if a value has been assigned to Replaced_by data member.
338  ///
339  /// Data member Replaced_by is optional;
340  /// its type is defined as 'typedef CSeq_hist_rec TReplaced_by'
341  /// @return
342  /// - true, if a value has been assigned.
343  /// - false, otherwise.
344  bool IsSetReplaced_by(void) const;
345 
346  /// Check if it is safe to call GetReplaced_by method.
347  ///
348  /// @return
349  /// - true, if the data member is getatable.
350  /// - false, otherwise.
351  bool CanGetReplaced_by(void) const;
352 
353  /// Reset Replaced_by data member.
354  void ResetReplaced_by(void);
355 
356  /// Get the Replaced_by member data.
357  ///
358  /// @return
359  /// Reference to the member data.
360  const TReplaced_by& GetReplaced_by(void) const;
361 
362  /// Assign a value to Replaced_by data member.
363  ///
364  /// @param value
365  /// Reference to value.
366  void SetReplaced_by(TReplaced_by& value);
367 
368  /// Assign a value to Replaced_by data member.
369  ///
370  /// @return
371  /// Reference to the data value.
372  TReplaced_by& SetReplaced_by(void);
373 
374  /// Check if a value has been assigned to Deleted data member.
375  ///
376  /// Data member Deleted is optional;
377  /// its type is defined as 'typedef C_Deleted TDeleted'
378  /// @return
379  /// - true, if a value has been assigned.
380  /// - false, otherwise.
381  bool IsSetDeleted(void) const;
382 
383  /// Check if it is safe to call GetDeleted method.
384  ///
385  /// @return
386  /// - true, if the data member is getatable.
387  /// - false, otherwise.
388  bool CanGetDeleted(void) const;
389 
390  /// Reset Deleted data member.
391  void ResetDeleted(void);
392 
393  /// Get the Deleted member data.
394  ///
395  /// @return
396  /// Reference to the member data.
397  const TDeleted& GetDeleted(void) const;
398 
399  /// Assign a value to Deleted data member.
400  ///
401  /// @param value
402  /// Reference to value.
403  void SetDeleted(TDeleted& value);
404 
405  /// Assign a value to Deleted data member.
406  ///
407  /// @return
408  /// Reference to the data value.
409  TDeleted& SetDeleted(void);
410 
411  /// Reset the whole object
412  virtual void Reset(void);
413 
414 
415 private:
416  // Prohibit copy constructor and assignment operator
419 
420  // data
421  Uint4 m_set_State[1];
422  list< CRef< CSeq_align > > m_Assembly;
426 };
427 
428 /* @} */
429 
430 
431 
432 
433 
434 ///////////////////////////////////////////////////////////
435 ///////////////////// inline methods //////////////////////
436 ///////////////////////////////////////////////////////////
437 inline
439 {
440  return m_choice;
441 }
442 
443 inline
445 {
446  if ( m_choice != index )
447  ThrowInvalidSelection(index);
448 }
449 
450 inline
451 void CSeq_hist_Base::C_Deleted::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
452 {
453  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
454  if ( m_choice != e_not_set )
455  ResetSelection();
456  DoSelect(index, pool);
457  }
458 }
459 
460 inline
462 {
463  Select(index, reset, 0);
464 }
465 
466 inline
468 {
469  return m_choice == e_Bool;
470 }
471 
472 inline
474 {
475  CheckSelected(e_Bool);
476  return m_Bool;
477 }
478 
479 inline
481 {
482  Select(e_Bool, NCBI_NS_NCBI::eDoNotResetVariant);
483  return m_Bool;
484 }
485 
486 inline
488 {
489  Select(e_Bool, NCBI_NS_NCBI::eDoNotResetVariant);
490  m_Bool = value;
491 }
492 
493 inline
495 {
496  return m_choice == e_Date;
497 }
498 
499 inline
501 {
502  return ((m_set_State[0] & 0x3) != 0);
503 }
504 
505 inline
507 {
508  return true;
509 }
510 
511 inline
513 {
514  return m_Assembly;
515 }
516 
517 inline
519 {
520  m_set_State[0] |= 0x1;
521  return m_Assembly;
522 }
523 
524 inline
526 {
527  return m_Replaces.NotEmpty();
528 }
529 
530 inline
532 {
533  return IsSetReplaces();
534 }
535 
536 inline
538 {
539  if (!CanGetReplaces()) {
540  ThrowUnassigned(1);
541  }
542  return (*m_Replaces);
543 }
544 
545 inline
547 {
548  return m_Replaced_by.NotEmpty();
549 }
550 
551 inline
553 {
554  return IsSetReplaced_by();
555 }
556 
557 inline
559 {
560  if (!CanGetReplaced_by()) {
561  ThrowUnassigned(2);
562  }
563  return (*m_Replaced_by);
564 }
565 
566 inline
568 {
569  return m_Deleted.NotEmpty();
570 }
571 
572 inline
574 {
575  return IsSetDeleted();
576 }
577 
578 inline
580 {
581  if (!CanGetDeleted()) {
582  ThrowUnassigned(3);
583  }
584  return (*m_Deleted);
585 }
586 
587 ///////////////////////////////////////////////////////////
588 ////////////////// end of inline methods //////////////////
589 ///////////////////////////////////////////////////////////
590 
591 
592 
593 
594 
595 END_objects_SCOPE // namespace ncbi::objects::
596 
598 
599 
600 #endif // OBJECTS_SEQ_SEQ_HIST_BASE_HPP
Definition: Date.hpp:53
CRef –.
Definition: ncbiobj.hpp:618
*** Sequence History Record *********************************** ** assembly = records how seq was ass...
Definition: Seq_hist_.hpp:83
CSeq_hist_rec –.
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
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_SEQ_EXPORT
Definition: ncbi_export.h:825
CSeq_hist_Base(const CSeq_hist_Base &)
bool IsSetDeleted(void) const
Check if a value has been assigned to Deleted data member.
Definition: Seq_hist_.hpp:567
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool IsSetReplaced_by(void) const
these seqs make this one obsolete Check if a value has been assigned to Replaced_by data member.
Definition: Seq_hist_.hpp:546
list< CRef< CSeq_align > > m_Assembly
Definition: Seq_hist_.hpp:422
list< CRef< CSeq_align > > TAssembly
Definition: Seq_hist_.hpp:248
CSerialObject Tparent
Definition: Seq_hist_.hpp:84
bool IsSetAssembly(void) const
how was this assembled? Check if a value has been assigned to Assembly data member.
Definition: Seq_hist_.hpp:500
const TDeleted & GetDeleted(void) const
Get the Deleted member data.
Definition: Seq_hist_.hpp:579
TBool & SetBool(void)
Select the variant.
Definition: Seq_hist_.hpp:480
DECLARE_INTERNAL_TYPE_INFO()
bool CanGetReplaced_by(void) const
Check if it is safe to call GetReplaced_by method.
Definition: Seq_hist_.hpp:552
bool IsSetReplaces(void) const
seq makes these seqs obsolete Check if a value has been assigned to Replaces data member.
Definition: Seq_hist_.hpp:525
const TAssembly & GetAssembly(void) const
Get the Assembly member data.
Definition: Seq_hist_.hpp:512
CSeq_hist_rec TReplaced_by
Definition: Seq_hist_.hpp:250
CRef< TDeleted > m_Deleted
Definition: Seq_hist_.hpp:425
CRef< TReplaced_by > m_Replaced_by
Definition: Seq_hist_.hpp:424
CRef< TReplaces > m_Replaces
Definition: Seq_hist_.hpp:423
CSeq_hist_rec TReplaces
Definition: Seq_hist_.hpp:249
Tparent::CMemberIndex< E_memberIndex, 5 > TmemberIndex
Definition: Seq_hist_.hpp:261
TBool GetBool(void) const
Get the variant data.
Definition: Seq_hist_.hpp:473
Uint4 m_set_State[1]
Definition: Seq_hist_.hpp:421
bool CanGetReplaces(void) const
Check if it is safe to call GetReplaces method.
Definition: Seq_hist_.hpp:531
CSeq_hist_Base & operator=(const CSeq_hist_Base &)
bool IsDate(void) const
Check if variant Date is selected.
Definition: Seq_hist_.hpp:494
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_hist_.hpp:438
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Seq_hist_.hpp:244
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Seq_hist_.hpp:119
const TReplaces & GetReplaces(void) const
Get the Replaces member data.
Definition: Seq_hist_.hpp:537
C_Deleted TDeleted
Definition: Seq_hist_.hpp:251
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Seq_hist_.hpp:444
const TReplaced_by & GetReplaced_by(void) const
Get the Replaced_by member data.
Definition: Seq_hist_.hpp:558
TAssembly & SetAssembly(void)
Assign a value to Assembly data member.
Definition: Seq_hist_.hpp:518
bool IsBool(void) const
Check if variant Bool is selected.
Definition: Seq_hist_.hpp:467
C_Deleted(const C_Deleted &)
E_Choice
Choice variants.
Definition: Seq_hist_.hpp:113
bool CanGetDeleted(void) const
Check if it is safe to call GetDeleted method.
Definition: Seq_hist_.hpp:573
bool CanGetAssembly(void) const
Check if it is safe to call GetAssembly method.
Definition: Seq_hist_.hpp:506
C_Deleted & operator=(const C_Deleted &)
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Sep 04 14:59:05 2024 by modify_doxy.py rev. 669887