NCBI C++ ToolKit
ID2S_Seq_loc_.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 ID2S_Seq_loc_.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/seqsplit/seqsplit.asn">seqsplit.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqsplit/seqsplit.def">seqsplit.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_SEQSPLIT_ID2S_SEQ_LOC_BASE_HPP
42 #define OBJECTS_SEQSPLIT_ID2S_SEQ_LOC_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 CID2S_Gi_Interval;
61 class CID2S_Gi_Ints;
62 class CID2S_Gi_Range;
64 class CID2S_Seq_id_Ints;
65 class CID2S_Seq_loc;
66 class CSeq_id;
67 
68 
69 // generated classes
70 
71 
72 /** @addtogroup dataspec_NCBI_Seq_split
73  *
74  * @{
75  */
76 
77 /////////////////////////////////////////////////////////////////////////////
78 /// ID2S-Seq-loc is used to represent unordered and unstranded
79 /// set of intervals on set of sequences.
80 /// It's optimized for compact encoding of several common cases:
81 /// Seq-ids of type gi,
82 /// intervals covering whole sequences,
83 /// whole sequences with sequential gis,
84 /// set of intervals on the same sequence (Seq-id sharing).
85 ///
86 /// CID2S_Seq_loc_Base --
87 ///
88 
90 {
92 public:
93  // constructor
94  CID2S_Seq_loc_Base(void);
95  // destructor
96  virtual ~CID2S_Seq_loc_Base(void);
97 
98  // type info
100 
101 
102  /// Choice variants.
103  enum E_Choice {
104  e_not_set = 0, ///< No variant selected
105  e_Whole_gi, ///< whole sequence by gi
106  e_Whole_seq_id, ///< whole sequence by Seq-id
107  e_Whole_gi_range, ///< set of whole sequences by gis
108  e_Gi_interval, ///< interval on sequence by gi
109  e_Seq_id_interval, ///< interval on sequence by Seq-id
110  e_Gi_ints, ///< set of intervals on the same gi
111  e_Seq_id_ints, ///< set of intervals on the same id
112  e_Loc_set ///< combination of locations
113  };
114  /// Maximum+1 value of the choice variant enumerator.
116  e_MaxChoice = 9 ///< == e_Loc_set+1
117  };
118 
119  /// Reset the whole object
120  virtual void Reset(void);
121 
122  /// Reset the selection (set it to e_not_set).
123  virtual void ResetSelection(void);
124 
125  /// Which variant is currently selected.
126  ///
127  /// @return
128  /// Choice state enumerator.
129  E_Choice Which(void) const;
130 
131  /// Verify selection, throw exception if it differs from the expected.
132  ///
133  /// @param index
134  /// Expected selection.
135  void CheckSelected(E_Choice index) const;
136 
137  /// Throw 'InvalidSelection' exception.
138  ///
139  /// @param index
140  /// Expected selection.
141  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
142 
143  /// Retrieve selection name (for diagnostic purposes).
144  ///
145  /// @param index
146  /// One of possible selection states.
147  /// @return
148  /// Name string.
149  static string SelectionName(E_Choice index);
150 
151  /// Select the requested variant if needed.
152  ///
153  /// @param index
154  /// New selection state.
155  /// @param reset
156  /// Flag that defines the resetting of the variant data. The data will
157  /// be reset if either the current selection differs from the new one,
158  /// or the flag is set to eDoResetVariant.
160  /// Select the requested variant if needed,
161  /// allocating CObject variants from memory pool.
162  void Select(E_Choice index,
163  EResetVariant reset,
164  CObjectMemoryPool* pool);
165 
166  // types
174  typedef list< CRef< CID2S_Seq_loc > > TLoc_set;
175 
176  // getters
177  // setters
178 
179 
180  /// Check if variant Whole_gi is selected.
181  ///
182  /// Whole_gi type is defined as 'typedef NCBI_NS_NCBI::TGi TWhole_gi'.
183  /// @return
184  /// - true, if the variant is selected.
185  /// - false, otherwise.
186  bool IsWhole_gi(void) const;
187 
188  /// Get the variant data.
189  ///
190  /// @return
191  /// Copy of the variant data.
192  TWhole_gi GetWhole_gi(void) const;
193 
194  /// Select the variant.
195  ///
196  /// @return
197  /// Reference to the variant data.
198  TWhole_gi& SetWhole_gi(void);
199 
200  /// Select the variant and set its data.
201  ///
202  /// @param value
203  /// Variant data.
204  void SetWhole_gi(TWhole_gi value);
205 
206 
207  /// Check if variant Whole_seq_id is selected.
208  ///
209  /// Whole_seq_id type is defined as 'typedef CSeq_id TWhole_seq_id'.
210  /// @return
211  /// - true, if the variant is selected.
212  /// - false, otherwise.
213  bool IsWhole_seq_id(void) const;
214 
215  /// Get the variant data.
216  ///
217  /// @return
218  /// Reference to the data.
219  const TWhole_seq_id& GetWhole_seq_id(void) const;
220 
221  /// Select the variant.
222  ///
223  /// @return
224  /// Reference to the variant data.
225  TWhole_seq_id& SetWhole_seq_id(void);
226  /// Select the variant and set its data.
227  ///
228  /// @param value
229  /// Reference to the data.
230  void SetWhole_seq_id(TWhole_seq_id& value);
231 
232 
233  /// Check if variant Whole_gi_range is selected.
234  ///
235  /// Whole_gi_range type is defined as 'typedef CID2S_Gi_Range TWhole_gi_range'.
236  /// @return
237  /// - true, if the variant is selected.
238  /// - false, otherwise.
239  bool IsWhole_gi_range(void) const;
240 
241  /// Get the variant data.
242  ///
243  /// @return
244  /// Reference to the data.
245  const TWhole_gi_range& GetWhole_gi_range(void) const;
246 
247  /// Select the variant.
248  ///
249  /// @return
250  /// Reference to the variant data.
251  TWhole_gi_range& SetWhole_gi_range(void);
252  /// Select the variant and set its data.
253  ///
254  /// @param value
255  /// Reference to the data.
256  void SetWhole_gi_range(TWhole_gi_range& value);
257 
258 
259  /// Check if variant Gi_interval is selected.
260  ///
261  /// Gi_interval type is defined as 'typedef CID2S_Gi_Interval TGi_interval'.
262  /// @return
263  /// - true, if the variant is selected.
264  /// - false, otherwise.
265  bool IsGi_interval(void) const;
266 
267  /// Get the variant data.
268  ///
269  /// @return
270  /// Reference to the data.
271  const TGi_interval& GetGi_interval(void) const;
272 
273  /// Select the variant.
274  ///
275  /// @return
276  /// Reference to the variant data.
277  TGi_interval& SetGi_interval(void);
278  /// Select the variant and set its data.
279  ///
280  /// @param value
281  /// Reference to the data.
282  void SetGi_interval(TGi_interval& value);
283 
284 
285  /// Check if variant Seq_id_interval is selected.
286  ///
287  /// Seq_id_interval type is defined as 'typedef CID2S_Seq_id_Interval TSeq_id_interval'.
288  /// @return
289  /// - true, if the variant is selected.
290  /// - false, otherwise.
291  bool IsSeq_id_interval(void) const;
292 
293  /// Get the variant data.
294  ///
295  /// @return
296  /// Reference to the data.
297  const TSeq_id_interval& GetSeq_id_interval(void) const;
298 
299  /// Select the variant.
300  ///
301  /// @return
302  /// Reference to the variant data.
303  TSeq_id_interval& SetSeq_id_interval(void);
304  /// Select the variant and set its data.
305  ///
306  /// @param value
307  /// Reference to the data.
308  void SetSeq_id_interval(TSeq_id_interval& value);
309 
310 
311  /// Check if variant Gi_ints is selected.
312  ///
313  /// Gi_ints type is defined as 'typedef CID2S_Gi_Ints TGi_ints'.
314  /// @return
315  /// - true, if the variant is selected.
316  /// - false, otherwise.
317  bool IsGi_ints(void) const;
318 
319  /// Get the variant data.
320  ///
321  /// @return
322  /// Reference to the data.
323  const TGi_ints& GetGi_ints(void) const;
324 
325  /// Select the variant.
326  ///
327  /// @return
328  /// Reference to the variant data.
329  TGi_ints& SetGi_ints(void);
330  /// Select the variant and set its data.
331  ///
332  /// @param value
333  /// Reference to the data.
334  void SetGi_ints(TGi_ints& value);
335 
336 
337  /// Check if variant Seq_id_ints is selected.
338  ///
339  /// Seq_id_ints type is defined as 'typedef CID2S_Seq_id_Ints TSeq_id_ints'.
340  /// @return
341  /// - true, if the variant is selected.
342  /// - false, otherwise.
343  bool IsSeq_id_ints(void) const;
344 
345  /// Get the variant data.
346  ///
347  /// @return
348  /// Reference to the data.
349  const TSeq_id_ints& GetSeq_id_ints(void) const;
350 
351  /// Select the variant.
352  ///
353  /// @return
354  /// Reference to the variant data.
355  TSeq_id_ints& SetSeq_id_ints(void);
356  /// Select the variant and set its data.
357  ///
358  /// @param value
359  /// Reference to the data.
360  void SetSeq_id_ints(TSeq_id_ints& value);
361 
362 
363  /// Check if variant Loc_set is selected.
364  ///
365  /// Loc_set type is defined as 'typedef list< CRef< CID2S_Seq_loc > > TLoc_set'.
366  /// @return
367  /// - true, if the variant is selected.
368  /// - false, otherwise.
369  bool IsLoc_set(void) const;
370 
371  /// Get the variant data.
372  ///
373  /// @return
374  /// Reference to the data.
375  const TLoc_set& GetLoc_set(void) const;
376 
377  /// Select the variant.
378  ///
379  /// @return
380  /// Reference to the variant data.
381  TLoc_set& SetLoc_set(void);
382 
383 
384 private:
385  // copy constructor and assignment operator
388  // choice state
390  // helper methods
391  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
392 
393  static const char* const sm_SelectionNames[];
394  // data
395  union {
397  NCBI_NS_NCBI::CUnionBuffer<TLoc_set> m_Loc_set;
398  NCBI_NS_NCBI::CSerialObject *m_object;
399  };
400 };
401 
402 /* @} */
403 
404 
405 
406 
407 
408 ///////////////////////////////////////////////////////////
409 ///////////////////// inline methods //////////////////////
410 ///////////////////////////////////////////////////////////
411 inline
413 {
414  return m_choice;
415 }
416 
417 inline
419 {
420  if ( m_choice != index )
421  ThrowInvalidSelection(index);
422 }
423 
424 inline
425 void CID2S_Seq_loc_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
426 {
427  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
428  if ( m_choice != e_not_set )
429  ResetSelection();
430  DoSelect(index, pool);
431  }
432 }
433 
434 inline
436 {
437  Select(index, reset, 0);
438 }
439 
440 inline
442 {
443  return m_choice == e_Whole_gi;
444 }
445 
446 inline
448 {
450  return reinterpret_cast<const TWhole_gi&>(m_Whole_gi);
451 }
452 
453 inline
455 {
457  return reinterpret_cast<TWhole_gi&>(m_Whole_gi);
458 }
459 
460 inline
462 {
464  reinterpret_cast<TWhole_gi&>(m_Whole_gi) = value;
465 }
466 
467 inline
469 {
470  return m_choice == e_Whole_seq_id;
471 }
472 
473 inline
475 {
476  return m_choice == e_Whole_gi_range;
477 }
478 
479 inline
481 {
482  return m_choice == e_Gi_interval;
483 }
484 
485 inline
487 {
488  return m_choice == e_Seq_id_interval;
489 }
490 
491 inline
493 {
494  return m_choice == e_Gi_ints;
495 }
496 
497 inline
499 {
500  return m_choice == e_Seq_id_ints;
501 }
502 
503 inline
505 {
506  return m_choice == e_Loc_set;
507 }
508 
509 inline
511 {
513  return *m_Loc_set;
514 }
515 
516 inline
518 {
520  return *m_Loc_set;
521 }
522 
523 ///////////////////////////////////////////////////////////
524 ////////////////// end of inline methods //////////////////
525 ///////////////////////////////////////////////////////////
526 
527 
528 
529 
530 
531 END_objects_SCOPE // namespace ncbi::objects::
532 
534 
535 
536 #endif // OBJECTS_SEQSPLIT_ID2S_SEQ_LOC_BASE_HPP
CID2S_Gi_Interval –.
CID2S_Gi_Ints –.
CID2S_Gi_Range –.
CID2S_Seq_id_Interval –.
CID2S_Seq_id_Ints –.
ID2S-Seq-loc is used to represent unordered and unstranded set of intervals on set of sequences.
CID2S_Seq_loc –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
Int8 TIntId
Definition: ncbimisc.hpp:999
CStrictId< SStrictId_Gi, SStrictId_Gi::TId > TGi
Definition: ncbimisc.hpp:1025
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
#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_ID2_EXPORT
Definition: ncbi_export.h:552
bool IsSeq_id_ints(void) const
Check if variant Seq_id_ints is selected.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
bool IsWhole_seq_id(void) const
Check if variant Whole_seq_id is selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TLoc_set & GetLoc_set(void) const
Get the variant data.
TLoc_set & SetLoc_set(void)
Select the variant.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
E_Choice
Choice variants.
bool IsGi_ints(void) const
Check if variant Gi_ints is selected.
TWhole_gi GetWhole_gi(void) const
Get the variant data.
list< CRef< CID2S_Seq_loc > > TLoc_set
NCBI_NS_NCBI::CSerialObject * m_object
ncbi::TIntId m_Whole_gi
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
NCBI_NS_NCBI::TGi TWhole_gi
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CID2S_Seq_id_Interval TSeq_id_interval
CID2S_Gi_Interval TGi_interval
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
CID2S_Seq_loc_Base & operator=(const CID2S_Seq_loc_Base &)
bool IsWhole_gi(void) const
Check if variant Whole_gi is selected.
bool IsLoc_set(void) const
Check if variant Loc_set is selected.
CID2S_Gi_Ints TGi_ints
NCBI_NS_NCBI::CUnionBuffer< TLoc_set > m_Loc_set
CID2S_Seq_id_Ints TSeq_id_ints
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
TWhole_gi & SetWhole_gi(void)
Select the variant.
bool IsWhole_gi_range(void) const
Check if variant Whole_gi_range is selected.
NCBI_NS_NCBI::CUnionBuffer< TLoc_set > m_Loc_set
bool IsSeq_id_interval(void) const
Check if variant Seq_id_interval is selected.
CID2S_Gi_Range TWhole_gi_range
CSerialObject Tparent
CID2S_Seq_loc_Base(const CID2S_Seq_loc_Base &)
bool IsGi_interval(void) const
Check if variant Gi_interval is selected.
E_Choice Which(void) const
Which variant is currently selected.
@ e_Whole_gi
whole sequence by gi
@ e_Loc_set
combination of locations
@ e_Seq_id_ints
set of intervals on the same id
@ e_Whole_seq_id
whole sequence by Seq-id
@ e_Seq_id_interval
interval on sequence by Seq-id
@ e_Gi_ints
set of intervals on the same gi
@ e_Whole_gi_range
set of whole sequences by gis
@ e_Gi_interval
interval on sequence by gi
@ e_not_set
No variant selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu May 02 14:27:14 2024 by modify_doxy.py rev. 669887