NCBI C++ ToolKit
RNA_ref_.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 RNA_ref_.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_RNA_REF_BASE_HPP
42 #define OBJECTS_SEQFEAT_RNA_REF_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
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 CRNA_gen;
61 class CTrna_ext;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_RNA
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///*** rnas ***********************************************
74 ///*
75 ///* various rnas
76 ///*
77 /// minimal RNA sequence
78 ///
79 /// CRNA_ref_Base --
80 ///
81 
83 {
85 public:
86  // constructor
87  CRNA_ref_Base(void);
88  // destructor
89  virtual ~CRNA_ref_Base(void);
90 
91  // type info
93 
94  /// type of RNA feature
95  enum EType {
96  eType_unknown = 0,
97  eType_premsg = 1,
98  eType_mRNA = 2,
99  eType_tRNA = 3,
100  eType_rRNA = 4,
101  eType_snRNA = 5, ///< will become ncRNA, with RNA-gen.class = snRNA
102  eType_scRNA = 6, ///< will become ncRNA, with RNA-gen.class = scRNA
103  eType_snoRNA = 7, ///< will become ncRNA, with RNA-gen.class = snoRNA
104  eType_ncRNA = 8, ///< non-coding RNA; subsumes snRNA, scRNA, snoRNA
105  eType_tmRNA = 9,
106  eType_miscRNA = 10,
107  eType_other = 255
108  };
109 
110  /// Access to EType's attributes (values, names) as defined in spec
111  static const NCBI_NS_NCBI::CEnumeratedTypeValues* ENUM_METHOD_NAME(EType)(void);
112 
113  /////////////////////////////////////////////////////////////////////////////
114  ///
115  /// C_Ext --
116  ///
117 
119  {
121  public:
122  // constructor
123  C_Ext(void);
124  // destructor
125  ~C_Ext(void);
126 
127  // type info
129 
130 
131  /// Choice variants.
132  enum E_Choice {
133  e_not_set = 0, ///< No variant selected
134  e_Name, ///< for naming "other" type
135  e_TRNA, ///< for tRNAs
136  e_Gen
137  };
138  /// Maximum+1 value of the choice variant enumerator.
140  e_MaxChoice = 4 ///< == e_Gen+1
141  };
142 
143  /// Reset the whole object
144  void Reset(void);
145 
146  /// Reset the selection (set it to e_not_set).
147  void ResetSelection(void);
148 
149  /// Which variant is currently selected.
150  ///
151  /// @return
152  /// Choice state enumerator.
153  E_Choice Which(void) const;
154 
155  /// Verify selection, throw exception if it differs from the expected.
156  ///
157  /// @param index
158  /// Expected selection.
159  void CheckSelected(E_Choice index) const;
160 
161  /// Throw 'InvalidSelection' exception.
162  ///
163  /// @param index
164  /// Expected selection.
165  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
166 
167  /// Retrieve selection name (for diagnostic purposes).
168  ///
169  /// @param index
170  /// One of possible selection states.
171  /// @return
172  /// Name string.
173  static string SelectionName(E_Choice index);
174 
175  /// Select the requested variant if needed.
176  ///
177  /// @param index
178  /// New selection state.
179  /// @param reset
180  /// Flag that defines the resetting of the variant data. The data will
181  /// be reset if either the current selection differs from the new one,
182  /// or the flag is set to eDoResetVariant.
184  /// Select the requested variant if needed,
185  /// allocating CObject variants from memory pool.
186  void Select(E_Choice index,
187  EResetVariant reset,
188  CObjectMemoryPool* pool);
189 
190  // types
191  typedef string TName;
192  typedef CTrna_ext TTRNA;
193  typedef CRNA_gen TGen;
194 
195  // getters
196  // setters
197 
198 
199  /// Check if variant Name is selected.
200  ///
201  /// Name type is defined as 'typedef string TName'.
202  /// @return
203  /// - true, if the variant is selected.
204  /// - false, otherwise.
205  bool IsName(void) const;
206 
207  /// Get the variant data.
208  ///
209  /// @return
210  /// Reference to the data.
211  const TName& GetName(void) const;
212 
213  /// Select the variant.
214  ///
215  /// @return
216  /// Reference to the variant data.
217  TName& SetName(void);
218 
219  /// Select the variant and set its data.
220  ///
221  /// @param value
222  /// Variant data.
223  void SetName(const TName& value);
224 
225 
226  /// Check if variant TRNA is selected.
227  ///
228  /// TRNA type is defined as 'typedef CTrna_ext TTRNA'.
229  /// @return
230  /// - true, if the variant is selected.
231  /// - false, otherwise.
232  bool IsTRNA(void) const;
233 
234  /// Get the variant data.
235  ///
236  /// @return
237  /// Reference to the data.
238  const TTRNA& GetTRNA(void) const;
239 
240  /// Select the variant.
241  ///
242  /// @return
243  /// Reference to the variant data.
244  TTRNA& SetTRNA(void);
245  /// Select the variant and set its data.
246  ///
247  /// @param value
248  /// Reference to the data.
249  void SetTRNA(TTRNA& value);
250 
251 
252  /// Check if variant Gen is selected.
253  ///
254  /// Gen type is defined as 'typedef CRNA_gen TGen'.
255  /// @return
256  /// - true, if the variant is selected.
257  /// - false, otherwise.
258  bool IsGen(void) const;
259 
260  /// Get the variant data.
261  ///
262  /// @return
263  /// Reference to the data.
264  const TGen& GetGen(void) const;
265 
266  /// Select the variant.
267  ///
268  /// @return
269  /// Reference to the variant data.
270  TGen& SetGen(void);
271  /// Select the variant and set its data.
272  ///
273  /// @param value
274  /// Reference to the data.
275  void SetGen(TGen& value);
276 
277 
278  private:
279  // copy constructor and assignment operator
280  C_Ext(const C_Ext& );
281  C_Ext& operator=(const C_Ext& );
282  // choice state
284  // helper methods
285  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
286 
287  static const char* const sm_SelectionNames[];
288  // data
289  union {
290  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
291  NCBI_NS_NCBI::CSerialObject *m_object;
292  };
293  };
294  // types
295  typedef EType TType;
296  typedef bool TPseudo;
297  typedef C_Ext TExt;
298 
299  // member index
300  enum class E_memberIndex {
301  e__allMandatory = 0,
302  e_type,
303  e_pseudo,
304  e_ext
305  };
307 
308  // getters
309  // setters
310 
311  /// Check if a value has been assigned to Type data member.
312  ///
313  /// Data member Type is mandatory;
314  /// its type is defined as 'typedef EType TType'
315  /// @return
316  /// - true, if a value has been assigned.
317  /// - false, otherwise.
318  bool IsSetType(void) const;
319 
320  /// Check if it is safe to call GetType method.
321  ///
322  /// @return
323  /// - true, if the data member is getatable.
324  /// - false, otherwise.
325  bool CanGetType(void) const;
326 
327  /// Reset Type data member.
328  void ResetType(void);
329 
330  /// Get the Type member data.
331  ///
332  /// @return
333  /// Copy of the member data.
334  TType GetType(void) const;
335 
336  /// Assign a value to Type data member.
337  ///
338  /// @param value
339  /// Value to assign
340  void SetType(TType value);
341 
342  /// Assign a value to Type data member.
343  ///
344  /// @return
345  /// Reference to the data value.
346  TType& SetType(void);
347 
348  /// Check if a value has been assigned to Pseudo data member.
349  ///
350  /// Data member Pseudo is optional;
351  /// its type is defined as 'typedef bool TPseudo'
352  /// @return
353  /// - true, if a value has been assigned.
354  /// - false, otherwise.
355  bool IsSetPseudo(void) const;
356 
357  /// Check if it is safe to call GetPseudo method.
358  ///
359  /// @return
360  /// - true, if the data member is getatable.
361  /// - false, otherwise.
362  bool CanGetPseudo(void) const;
363 
364  /// Reset Pseudo data member.
365  void ResetPseudo(void);
366 
367  /// Get the Pseudo member data.
368  ///
369  /// @return
370  /// Copy of the member data.
371  TPseudo GetPseudo(void) const;
372 
373  /// Assign a value to Pseudo data member.
374  ///
375  /// @param value
376  /// Value to assign
377  void SetPseudo(TPseudo value);
378 
379  /// Assign a value to Pseudo data member.
380  ///
381  /// @return
382  /// Reference to the data value.
383  TPseudo& SetPseudo(void);
384 
385  /// generic fields for ncRNA, tmRNA, miscRNA
386  /// Check if a value has been assigned to Ext data member.
387  ///
388  /// Data member Ext is optional;
389  /// its type is defined as 'typedef C_Ext TExt'
390  /// @return
391  /// - true, if a value has been assigned.
392  /// - false, otherwise.
393  bool IsSetExt(void) const;
394 
395  /// Check if it is safe to call GetExt method.
396  ///
397  /// @return
398  /// - true, if the data member is getatable.
399  /// - false, otherwise.
400  bool CanGetExt(void) const;
401 
402  /// Reset Ext data member.
403  void ResetExt(void);
404 
405  /// Get the Ext member data.
406  ///
407  /// @return
408  /// Reference to the member data.
409  const TExt& GetExt(void) const;
410 
411  /// Assign a value to Ext data member.
412  ///
413  /// @param value
414  /// Reference to value.
415  void SetExt(TExt& value);
416 
417  /// Assign a value to Ext data member.
418  ///
419  /// @return
420  /// Reference to the data value.
421  TExt& SetExt(void);
422 
423  /// Reset the whole object
424  virtual void Reset(void);
425 
426 
427 private:
428  // Prohibit copy constructor and assignment operator
431 
432  // data
433  Uint4 m_set_State[1];
435  bool m_Pseudo;
437 };
438 
439 /* @} */
440 
441 
442 
443 
444 
445 ///////////////////////////////////////////////////////////
446 ///////////////////// inline methods //////////////////////
447 ///////////////////////////////////////////////////////////
448 inline
450 {
451  return m_choice;
452 }
453 
454 inline
456 {
457  if ( m_choice != index )
458  ThrowInvalidSelection(index);
459 }
460 
461 inline
462 void CRNA_ref_Base::C_Ext::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
463 {
464  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
465  if ( m_choice != e_not_set )
466  ResetSelection();
467  DoSelect(index, pool);
468  }
469 }
470 
471 inline
473 {
474  Select(index, reset, 0);
475 }
476 
477 inline
479 {
480  return m_choice == e_Name;
481 }
482 
483 inline
485 {
486  CheckSelected(e_Name);
487  return *m_string;
488 }
489 
490 inline
492 {
493  Select(e_Name, NCBI_NS_NCBI::eDoNotResetVariant);
494  return *m_string;
495 }
496 
497 inline
499 {
500  return m_choice == e_TRNA;
501 }
502 
503 inline
505 {
506  return m_choice == e_Gen;
507 }
508 
509 inline
510 bool CRNA_ref_Base::IsSetType(void) const
511 {
512  return ((m_set_State[0] & 0x3) != 0);
513 }
514 
515 inline
517 {
518  return IsSetType();
519 }
520 
521 inline
523 {
524  m_Type = (EType)(0);
525  m_set_State[0] &= ~0x3;
526 }
527 
528 inline
530 {
531  if (!CanGetType()) {
532  ThrowUnassigned(0);
533  }
534  return m_Type;
535 }
536 
537 inline
539 {
540  m_Type = value;
541  m_set_State[0] |= 0x3;
542 }
543 
544 inline
546 {
547 #ifdef _DEBUG
548  if (!IsSetType()) {
549  memset(&m_Type,UnassignedByte(),sizeof(m_Type));
550  }
551 #endif
552  m_set_State[0] |= 0x1;
553  return m_Type;
554 }
555 
556 inline
558 {
559  return ((m_set_State[0] & 0xc) != 0);
560 }
561 
562 inline
564 {
565  return IsSetPseudo();
566 }
567 
568 inline
570 {
571  m_Pseudo = 0;
572  m_set_State[0] &= ~0xc;
573 }
574 
575 inline
577 {
578  if (!CanGetPseudo()) {
579  ThrowUnassigned(1);
580  }
581  return m_Pseudo;
582 }
583 
584 inline
586 {
587  m_Pseudo = value;
588  m_set_State[0] |= 0xc;
589 }
590 
591 inline
593 {
594 #ifdef _DEBUG
595  if (!IsSetPseudo()) {
596  memset(&m_Pseudo,UnassignedByte(),sizeof(m_Pseudo));
597  }
598 #endif
599  m_set_State[0] |= 0x4;
600  return m_Pseudo;
601 }
602 
603 inline
604 bool CRNA_ref_Base::IsSetExt(void) const
605 {
606  return m_Ext.NotEmpty();
607 }
608 
609 inline
610 bool CRNA_ref_Base::CanGetExt(void) const
611 {
612  return IsSetExt();
613 }
614 
615 inline
617 {
618  if (!CanGetExt()) {
619  ThrowUnassigned(2);
620  }
621  return (*m_Ext);
622 }
623 
624 ///////////////////////////////////////////////////////////
625 ////////////////// end of inline methods //////////////////
626 ///////////////////////////////////////////////////////////
627 
628 
629 
630 
631 
632 END_objects_SCOPE // namespace ncbi::objects::
633 
635 
636 
637 #endif // OBJECTS_SEQFEAT_RNA_REF_BASE_HPP
*** rnas *********************************************** * * various rnas * minimal RNA sequence
Definition: RNA_ref_.hpp:83
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
E_Choice
Choice variants.
Definition: RNA_ref_.hpp:132
CRNA_ref_Base(const CRNA_ref_Base &)
CRef< TExt > m_Ext
Definition: RNA_ref_.hpp:436
TName & SetName(void)
Select the variant.
Definition: RNA_ref_.hpp:491
NCBI_NS_NCBI::CSerialObject * m_object
Definition: RNA_ref_.hpp:291
C_Ext & operator=(const C_Ext &)
CRNA_ref_Base & operator=(const CRNA_ref_Base &)
TType GetType(void) const
Get the Type member data.
Definition: RNA_ref_.hpp:529
E_Choice Which(void) const
Which variant is currently selected.
Definition: RNA_ref_.hpp:449
bool IsTRNA(void) const
Check if variant TRNA is selected.
Definition: RNA_ref_.hpp:498
DECLARE_INTERNAL_TYPE_INFO()
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
Definition: RNA_ref_.hpp:306
C_Ext(const C_Ext &)
EType
type of RNA feature
Definition: RNA_ref_.hpp:95
bool IsSetExt(void) const
generic fields for ncRNA, tmRNA, miscRNA Check if a value has been assigned to Ext data member.
Definition: RNA_ref_.hpp:604
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool IsGen(void) const
Check if variant Gen is selected.
Definition: RNA_ref_.hpp:504
CSerialObject Tparent
Definition: RNA_ref_.hpp:120
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: RNA_ref_.hpp:290
TType & SetType(void)
Assign a value to Type data member.
Definition: RNA_ref_.hpp:545
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: RNA_ref_.hpp:455
bool CanGetExt(void) const
Check if it is safe to call GetExt method.
Definition: RNA_ref_.hpp:610
void ResetType(void)
Reset Type data member.
Definition: RNA_ref_.hpp:522
TPseudo & SetPseudo(void)
Assign a value to Pseudo data member.
Definition: RNA_ref_.hpp:592
TPseudo GetPseudo(void) const
Get the Pseudo member data.
Definition: RNA_ref_.hpp:576
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
bool CanGetType(void) const
Check if it is safe to call GetType method.
Definition: RNA_ref_.hpp:516
bool IsSetType(void) const
Check if a value has been assigned to Type data member.
Definition: RNA_ref_.hpp:510
const TName & GetName(void) const
Get the variant data.
Definition: RNA_ref_.hpp:484
bool IsSetPseudo(void) const
Check if a value has been assigned to Pseudo data member.
Definition: RNA_ref_.hpp:557
void ResetPseudo(void)
Reset Pseudo data member.
Definition: RNA_ref_.hpp:569
CSerialObject Tparent
Definition: RNA_ref_.hpp:84
bool CanGetPseudo(void) const
Check if it is safe to call GetPseudo method.
Definition: RNA_ref_.hpp:563
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: RNA_ref_.hpp:139
Uint4 m_set_State[1]
Definition: RNA_ref_.hpp:433
bool IsName(void) const
Check if variant Name is selected.
Definition: RNA_ref_.hpp:478
@ e_Name
for naming "other" type
Definition: RNA_ref_.hpp:134
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu Apr 25 08:20:43 2024 by modify_doxy.py rev. 669887