NCBI C++ ToolKit
GC_Replicon_.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 GC_Replicon_.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/genomecoll/genome_collection.asn">genome_collection.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/genomecoll/genome_collection.def">genome_collection.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_GENOMECOLL_GC_REPLICON_BASE_HPP
42 #define OBJECTS_GENOMECOLL_GC_REPLICON_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
49 #include <string>
50 
52 
53 #ifndef BEGIN_objects_SCOPE
54 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
55 # define END_objects_SCOPE END_SCOPE(objects)
56 #endif
57 BEGIN_objects_SCOPE // namespace ncbi::objects::
58 
59 
60 // forward declarations
61 class CGC_Sequence;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_GenomeCollection
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///
74 /// CGC_Replicon_Base --
75 ///
76 
78 {
80 public:
81  // constructor
82  CGC_Replicon_Base(void);
83  // destructor
84  virtual ~CGC_Replicon_Base(void);
85 
86  // type info
88 
89  /////////////////////////////////////////////////////////////////////////////
90  /// the sequence(s) representing this molecule
91  /// in the case of 2L and 2R - the molecule is represented by
92  /// several sequences, and there is no seq-id of "chr 2" as a whole.
93  ///
94  /// C_Sequence --
95  ///
96 
98  {
100  public:
101  // constructor
102  C_Sequence(void);
103  // destructor
104  ~C_Sequence(void);
105 
106  // type info
108 
109 
110  /// Choice variants.
111  enum E_Choice {
112  e_not_set = 0, ///< No variant selected
114  e_Set
115  };
116  /// Maximum+1 value of the choice variant enumerator.
118  e_MaxChoice = 3 ///< == e_Set+1
119  };
120 
121  /// Reset the whole object
122  void Reset(void);
123 
124  /// Reset the selection (set it to e_not_set).
125  void ResetSelection(void);
126 
127  /// Which variant is currently selected.
128  ///
129  /// @return
130  /// Choice state enumerator.
131  E_Choice Which(void) const;
132 
133  /// Verify selection, throw exception if it differs from the expected.
134  ///
135  /// @param index
136  /// Expected selection.
137  void CheckSelected(E_Choice index) const;
138 
139  /// Throw 'InvalidSelection' exception.
140  ///
141  /// @param index
142  /// Expected selection.
143  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
144 
145  /// Retrieve selection name (for diagnostic purposes).
146  ///
147  /// @param index
148  /// One of possible selection states.
149  /// @return
150  /// Name string.
151  static string SelectionName(E_Choice index);
152 
153  /// Select the requested variant if needed.
154  ///
155  /// @param index
156  /// New selection state.
157  /// @param reset
158  /// Flag that defines the resetting of the variant data. The data will
159  /// be reset if either the current selection differs from the new one,
160  /// or the flag is set to eDoResetVariant.
162  /// Select the requested variant if needed,
163  /// allocating CObject variants from memory pool.
164  void Select(E_Choice index,
165  EResetVariant reset,
166  CObjectMemoryPool* pool);
167 
168  // types
170  typedef list< CRef< CGC_Sequence > > TSet;
171 
172  // getters
173  // setters
174 
175 
176  /// Check if variant Single is selected.
177  ///
178  /// Single type is defined as 'typedef CGC_Sequence TSingle'.
179  /// @return
180  /// - true, if the variant is selected.
181  /// - false, otherwise.
182  bool IsSingle(void) const;
183 
184  /// Get the variant data.
185  ///
186  /// @return
187  /// Reference to the data.
188  const TSingle& GetSingle(void) const;
189 
190  /// Select the variant.
191  ///
192  /// @return
193  /// Reference to the variant data.
194  TSingle& SetSingle(void);
195  /// Select the variant and set its data.
196  ///
197  /// @param value
198  /// Reference to the data.
199  void SetSingle(TSingle& value);
200 
201 
202  /// Check if variant Set is selected.
203  ///
204  /// Set type is defined as 'typedef list< CRef< CGC_Sequence > > TSet'.
205  /// @return
206  /// - true, if the variant is selected.
207  /// - false, otherwise.
208  bool IsSet(void) const;
209 
210  /// Get the variant data.
211  ///
212  /// @return
213  /// Reference to the data.
214  const TSet& GetSet(void) const;
215 
216  /// Select the variant.
217  ///
218  /// @return
219  /// Reference to the variant data.
220  TSet& SetSet(void);
221 
222 
223  private:
224  // copy constructor and assignment operator
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 {
235  NCBI_NS_NCBI::CUnionBuffer<TSet> m_Set;
236  NCBI_NS_NCBI::CSerialObject *m_object;
237  };
238  };
239  // types
240  typedef string TName;
241  typedef string TLocal_name;
243 
244  // member index
245  enum class E_memberIndex {
246  e__allMandatory = 0,
247  e_name,
248  e_local_name,
249  e_sequence
250  };
252 
253  // getters
254  // setters
255 
256  /// name for this molecule
257  /// the official name,
258  /// Check if a value has been assigned to Name data member.
259  ///
260  /// Data member Name is optional;
261  /// its type is defined as 'typedef string TName'
262  /// @return
263  /// - true, if a value has been assigned.
264  /// - false, otherwise.
265  bool IsSetName(void) const;
266 
267  /// Check if it is safe to call GetName method.
268  ///
269  /// @return
270  /// - true, if the data member is getatable.
271  /// - false, otherwise.
272  bool CanGetName(void) const;
273 
274  /// Reset Name data member.
275  void ResetName(void);
276 
277  /// Get the Name member data.
278  ///
279  /// @return
280  /// Reference to the member data.
281  const TName& GetName(void) const;
282 
283  /// Assign a value to Name data member.
284  ///
285  /// @param value
286  /// Value to assign
287  void SetName(const TName& value);
288  void SetName(TName&& value);
289 
290  /// Assign a value to Name data member.
291  ///
292  /// @return
293  /// Reference to the data value.
294  TName& SetName(void);
295 
296  /// If the chromosome has a different name in this assembly.
297  /// Check if a value has been assigned to Local_name data member.
298  ///
299  /// Data member Local_name is optional;
300  /// its type is defined as 'typedef string TLocal_name'
301  /// @return
302  /// - true, if a value has been assigned.
303  /// - false, otherwise.
304  bool IsSetLocal_name(void) const;
305 
306  /// Check if it is safe to call GetLocal_name method.
307  ///
308  /// @return
309  /// - true, if the data member is getatable.
310  /// - false, otherwise.
311  bool CanGetLocal_name(void) const;
312 
313  /// Reset Local_name data member.
314  void ResetLocal_name(void);
315 
316  /// Get the Local_name member data.
317  ///
318  /// @return
319  /// Reference to the member data.
320  const TLocal_name& GetLocal_name(void) const;
321 
322  /// Assign a value to Local_name data member.
323  ///
324  /// @param value
325  /// Value to assign
326  void SetLocal_name(const TLocal_name& value);
327  void SetLocal_name(TLocal_name&& value);
328 
329  /// Assign a value to Local_name data member.
330  ///
331  /// @return
332  /// Reference to the data value.
333  TLocal_name& SetLocal_name(void);
334 
335  /// Check if a value has been assigned to Sequence data member.
336  ///
337  /// Data member Sequence is mandatory;
338  /// its type is defined as 'typedef C_Sequence TSequence'
339  /// @return
340  /// - true, if a value has been assigned.
341  /// - false, otherwise.
342  bool IsSetSequence(void) const;
343 
344  /// Check if it is safe to call GetSequence method.
345  ///
346  /// @return
347  /// - true, if the data member is getatable.
348  /// - false, otherwise.
349  bool CanGetSequence(void) const;
350 
351  /// Reset Sequence data member.
352  void ResetSequence(void);
353 
354  /// Get the Sequence member data.
355  ///
356  /// @return
357  /// Reference to the member data.
358  const TSequence& GetSequence(void) const;
359 
360  /// Assign a value to Sequence data member.
361  ///
362  /// @param value
363  /// Reference to value.
364  void SetSequence(TSequence& value);
365 
366  /// Assign a value to Sequence data member.
367  ///
368  /// @return
369  /// Reference to the data value.
370  TSequence& SetSequence(void);
371 
372  /// Reset the whole object
373  virtual void Reset(void);
374 
375 
376 private:
377  // Prohibit copy constructor and assignment operator
380 
381  // data
382  Uint4 m_set_State[1];
383  string m_Name;
384  string m_Local_name;
386 };
387 
388 /* @} */
389 
390 
391 
392 
393 
394 ///////////////////////////////////////////////////////////
395 ///////////////////// inline methods //////////////////////
396 ///////////////////////////////////////////////////////////
397 inline
399 {
400  return m_choice;
401 }
402 
403 inline
405 {
406  if ( m_choice != index )
407  ThrowInvalidSelection(index);
408 }
409 
410 inline
411 void CGC_Replicon_Base::C_Sequence::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
412 {
413  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
414  if ( m_choice != e_not_set )
415  ResetSelection();
416  DoSelect(index, pool);
417  }
418 }
419 
420 inline
422 {
423  Select(index, reset, 0);
424 }
425 
426 inline
428 {
429  return m_choice == e_Single;
430 }
431 
432 inline
434 {
435  return m_choice == e_Set;
436 }
437 
438 inline
440 {
441  CheckSelected(e_Set);
442  return *m_Set;
443 }
444 
445 inline
447 {
448  Select(e_Set, NCBI_NS_NCBI::eDoNotResetVariant);
449  return *m_Set;
450 }
451 
452 inline
454 {
455  return ((m_set_State[0] & 0x3) != 0);
456 }
457 
458 inline
460 {
461  return IsSetName();
462 }
463 
464 inline
466 {
467  if (!CanGetName()) {
468  ThrowUnassigned(0);
469  }
470  return m_Name;
471 }
472 
473 inline
475 {
476  m_Name = value;
477  m_set_State[0] |= 0x3;
478 }
479 
480 inline
482 {
483  m_Name = std::forward<CGC_Replicon_Base::TName>(value);
484  m_set_State[0] |= 0x3;
485 }
486 
487 inline
489 {
490 #ifdef _DEBUG
491  if (!IsSetName()) {
493  }
494 #endif
495  m_set_State[0] |= 0x1;
496  return m_Name;
497 }
498 
499 inline
501 {
502  return ((m_set_State[0] & 0xc) != 0);
503 }
504 
505 inline
507 {
508  return IsSetLocal_name();
509 }
510 
511 inline
513 {
514  if (!CanGetLocal_name()) {
515  ThrowUnassigned(1);
516  }
517  return m_Local_name;
518 }
519 
520 inline
522 {
524  m_set_State[0] |= 0xc;
525 }
526 
527 inline
529 {
530  m_Local_name = std::forward<CGC_Replicon_Base::TLocal_name>(value);
531  m_set_State[0] |= 0xc;
532 }
533 
534 inline
536 {
537 #ifdef _DEBUG
538  if (!IsSetLocal_name()) {
540  }
541 #endif
542  m_set_State[0] |= 0x4;
543  return m_Local_name;
544 }
545 
546 inline
548 {
549  return m_Sequence.NotEmpty();
550 }
551 
552 inline
554 {
555  return true;
556 }
557 
558 inline
560 {
561  if ( !m_Sequence ) {
562  const_cast<CGC_Replicon_Base*>(this)->ResetSequence();
563  }
564  return (*m_Sequence);
565 }
566 
567 inline
569 {
570  if ( !m_Sequence ) {
571  ResetSequence();
572  }
573  return (*m_Sequence);
574 }
575 
576 ///////////////////////////////////////////////////////////
577 ////////////////// end of inline methods //////////////////
578 ///////////////////////////////////////////////////////////
579 
580 
581 
582 
583 
584 END_objects_SCOPE // namespace ncbi::objects::
585 
587 
588 
589 #endif // OBJECTS_GENOMECOLL_GC_REPLICON_BASE_HPP
the sequence(s) representing this molecule in the case of 2L and 2R - the molecule is represented by ...
CGC_Replicon_Base –.
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
SBlastSequence GetSequence(const objects::CSeq_loc &sl, EBlastEncoding encoding, objects::CScope *scope, objects::ENa_strand strand=objects::eNa_strand_plus, ESentinelType sentinel=eSentinels, std::string *warnings=NULL)
Retrieves a sequence using the object manager.
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
static string UnassignedString(void)
Definition: serialbase.hpp:175
@ 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_GENOME_COLLECTION_EXPORT
Definition: ncbi_export.h:528
bool IsSet(void) const
Check if variant Set is selected.
bool CanGetLocal_name(void) const
Check if it is safe to call GetLocal_name method.
const TName & GetName(void) const
Get the Name member data.
const TLocal_name & GetLocal_name(void) const
Get the Local_name member data.
CRef< TSequence > m_Sequence
bool IsSingle(void) const
Check if variant Single is selected.
TSet & SetSet(void)
Select the variant.
C_Sequence TSequence
CGC_Replicon_Base & operator=(const CGC_Replicon_Base &)
CSerialObject Tparent
E_Choice Which(void) const
Which variant is currently selected.
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, 4 > TmemberIndex
void ResetSequence(void)
Reset Sequence data member.
CGC_Replicon_Base(const CGC_Replicon_Base &)
NCBI_NS_NCBI::CUnionBuffer< TSet > m_Set
C_Sequence & operator=(const C_Sequence &)
bool CanGetSequence(void) const
Check if it is safe to call GetSequence method.
bool IsSetName(void) const
name for this molecule the official name, Check if a value has been assigned to Name data member.
const TSequence & GetSequence(void) const
Get the Sequence member data.
NCBI_NS_NCBI::CSerialObject * m_object
bool IsSetLocal_name(void) const
If the chromosome has a different name in this assembly.
C_Sequence(const C_Sequence &)
bool IsSetSequence(void) const
Check if a value has been assigned to Sequence data member.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
list< CRef< CGC_Sequence > > TSet
const TSet & GetSet(void) const
Get the variant data.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
TSequence & SetSequence(void)
Assign a value to Sequence data member.
bool CanGetName(void) const
Check if it is safe to call GetName method.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
TName & SetName(void)
Assign a value to Name data member.
TLocal_name & SetLocal_name(void)
Assign a value to Local_name data member.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:34 2024 by modify_doxy.py rev. 669887