NCBI C++ ToolKit
Frameshift_.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 Frameshift_.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/varrep/varrep.asn">varrep.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/varrep/varrep.def">varrep.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_VARREP_FRAMESHIFT_BASE_HPP
42 #define OBJECTS_VARREP_FRAMESHIFT_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 CAaSite;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_VariationIRep
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CFrameshift_Base --
70 ///
71 
73 {
75 public:
76  // constructor
77  CFrameshift_Base(void);
78  // destructor
79  virtual ~CFrameshift_Base(void);
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
90  };
91  /// Maximum+1 value of the choice variant enumerator.
93  e_MaxChoice = 3 ///< == e_Stopcodon+1
94  };
95 
96  /// Reset the whole object
97  virtual void Reset(void);
98 
99  /// Reset the selection (set it to e_not_set).
100  virtual void ResetSelection(void);
101 
102  /// Which variant is currently selected.
103  ///
104  /// @return
105  /// Choice state enumerator.
106  E_Choice Which(void) const;
107 
108  /// Verify selection, throw exception if it differs from the expected.
109  ///
110  /// @param index
111  /// Expected selection.
112  void CheckSelected(E_Choice index) const;
113 
114  /// Throw 'InvalidSelection' exception.
115  ///
116  /// @param index
117  /// Expected selection.
118  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
119 
120  /// Retrieve selection name (for diagnostic purposes).
121  ///
122  /// @param index
123  /// One of possible selection states.
124  /// @return
125  /// Name string.
126  static string SelectionName(E_Choice index);
127 
128  /// Select the requested variant if needed.
129  ///
130  /// @param index
131  /// New selection state.
132  /// @param reset
133  /// Flag that defines the resetting of the variant data. The data will
134  /// be reset if either the current selection differs from the new one,
135  /// or the flag is set to eDoResetVariant.
137  /// Select the requested variant if needed,
138  /// allocating CObject variants from memory pool.
139  void Select(E_Choice index,
140  EResetVariant reset,
141  CObjectMemoryPool* pool);
142 
143  // types
144  typedef CAaSite TAasite;
145 
146  // getters
147  // setters
148 
149 
150  /// Check if variant Aasite is selected.
151  ///
152  /// Aasite type is defined as 'typedef CAaSite TAasite'.
153  /// @return
154  /// - true, if the variant is selected.
155  /// - false, otherwise.
156  bool IsAasite(void) const;
157 
158  /// Get the variant data.
159  ///
160  /// @return
161  /// Reference to the data.
162  const TAasite& GetAasite(void) const;
163 
164  /// Select the variant.
165  ///
166  /// @return
167  /// Reference to the variant data.
168  TAasite& SetAasite(void);
169  /// Select the variant and set its data.
170  ///
171  /// @param value
172  /// Reference to the data.
173  void SetAasite(TAasite& value);
174 
175 
176  /// Check if variant Stopcodon is selected.
177  ///
178  /// @return
179  /// - true, if the variant is selected.
180  /// - false, otherwise.
181  bool IsStopcodon(void) const;
182 
183  /// Select the variant.
184  void SetStopcodon(void);
185 
186 
187 private:
188  // copy constructor and assignment operator
191  // choice state
193  // helper methods
194  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
195 
196  static const char* const sm_SelectionNames[];
197  // data
198  union {
199  NCBI_NS_NCBI::CSerialObject *m_object;
200  };
201 };
202 
203 /* @} */
204 
205 
206 
207 
208 
209 ///////////////////////////////////////////////////////////
210 ///////////////////// inline methods //////////////////////
211 ///////////////////////////////////////////////////////////
212 inline
214 {
215  return m_choice;
216 }
217 
218 inline
220 {
221  if ( m_choice != index )
222  ThrowInvalidSelection(index);
223 }
224 
225 inline
226 void CFrameshift_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
227 {
228  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
229  if ( m_choice != e_not_set )
230  ResetSelection();
231  DoSelect(index, pool);
232  }
233 }
234 
235 inline
236 void CFrameshift_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
237 {
238  Select(index, reset, 0);
239 }
240 
241 inline
243 {
244  return m_choice == e_Aasite;
245 }
246 
247 inline
249 {
250  return m_choice == e_Stopcodon;
251 }
252 
253 inline
255 {
257 }
258 
259 ///////////////////////////////////////////////////////////
260 ////////////////// end of inline methods //////////////////
261 ///////////////////////////////////////////////////////////
262 
263 
264 
265 
266 
267 END_objects_SCOPE // namespace ncbi::objects::
268 
270 
271 
272 #endif // OBJECTS_VARREP_FRAMESHIFT_BASE_HPP
CAaSite –.
Definition: AaSite.hpp:66
CFrameshift_Base –.
Definition: Frameshift_.hpp:73
Base class for all serializable objects.
Definition: serialbase.hpp:150
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
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Frameshift_.cpp:69
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Frameshift_.cpp:57
TAasite & SetAasite(void)
Select the variant.
virtual ~CFrameshift_Base(void)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Frameshift_.hpp:92
bool IsStopcodon(void) const
Check if variant Stopcodon is selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void SetStopcodon(void)
Select the variant.
bool IsAasite(void) const
Check if variant Aasite is selected.
NCBI_NS_NCBI::CSerialObject * m_object
virtual void Reset(void)
Reset the whole object.
Definition: Frameshift_.cpp:51
CFrameshift_Base(const CFrameshift_Base &)
const TAasite & GetAasite(void) const
Get the variant data.
Definition: Frameshift_.cpp:97
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Frameshift_.cpp:92
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Frameshift_.cpp:87
static const char *const sm_SelectionNames[]
CSerialObject Tparent
Definition: Frameshift_.hpp:74
E_Choice Which(void) const
Which variant is currently selected.
CFrameshift_Base & operator=(const CFrameshift_Base &)
E_Choice
Choice variants.
Definition: Frameshift_.hpp:86
@ e_MaxChoice
== e_Stopcodon+1
Definition: Frameshift_.hpp:93
@ e_not_set
No variant selected.
Definition: Frameshift_.hpp:87
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Tue May 28 05:52:06 2024 by modify_doxy.py rev. 669887