NCBI C++ ToolKit
SeqLocation_.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 SeqLocation_.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_SEQLOCATION_BASE_HPP
42 #define OBJECTS_VARREP_SEQLOCATION_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 CAaLocation;
57 class CNtLocation;
58 
59 
60 // generated classes
61 
62 
63 /** @addtogroup dataspec_NCBI_VariationIRep
64  *
65  * @{
66  */
67 
68 /////////////////////////////////////////////////////////////////////////////
69 ///
70 /// CSeqLocation_Base --
71 ///
72 
74 {
76 public:
77  // constructor
78  CSeqLocation_Base(void);
79  // destructor
80  virtual ~CSeqLocation_Base(void);
81 
82  // type info
84 
85 
86  /// Choice variants.
87  enum E_Choice {
88  e_not_set = 0, ///< No variant selected
90  e_Ntloc
91  };
92  /// Maximum+1 value of the choice variant enumerator.
94  e_MaxChoice = 3 ///< == e_Ntloc+1
95  };
96 
97  /// Reset the whole object
98  virtual void Reset(void);
99 
100  /// Reset the selection (set it to e_not_set).
101  virtual void ResetSelection(void);
102 
103  /// Which variant is currently selected.
104  ///
105  /// @return
106  /// Choice state enumerator.
107  E_Choice Which(void) const;
108 
109  /// Verify selection, throw exception if it differs from the expected.
110  ///
111  /// @param index
112  /// Expected selection.
113  void CheckSelected(E_Choice index) const;
114 
115  /// Throw 'InvalidSelection' exception.
116  ///
117  /// @param index
118  /// Expected selection.
119  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
120 
121  /// Retrieve selection name (for diagnostic purposes).
122  ///
123  /// @param index
124  /// One of possible selection states.
125  /// @return
126  /// Name string.
127  static string SelectionName(E_Choice index);
128 
129  /// Select the requested variant if needed.
130  ///
131  /// @param index
132  /// New selection state.
133  /// @param reset
134  /// Flag that defines the resetting of the variant data. The data will
135  /// be reset if either the current selection differs from the new one,
136  /// or the flag is set to eDoResetVariant.
138  /// Select the requested variant if needed,
139  /// allocating CObject variants from memory pool.
140  void Select(E_Choice index,
141  EResetVariant reset,
142  CObjectMemoryPool* pool);
143 
144  // types
147 
148  // getters
149  // setters
150 
151 
152  /// Check if variant Aaloc is selected.
153  ///
154  /// Aaloc type is defined as 'typedef CAaLocation TAaloc'.
155  /// @return
156  /// - true, if the variant is selected.
157  /// - false, otherwise.
158  bool IsAaloc(void) const;
159 
160  /// Get the variant data.
161  ///
162  /// @return
163  /// Reference to the data.
164  const TAaloc& GetAaloc(void) const;
165 
166  /// Select the variant.
167  ///
168  /// @return
169  /// Reference to the variant data.
170  TAaloc& SetAaloc(void);
171  /// Select the variant and set its data.
172  ///
173  /// @param value
174  /// Reference to the data.
175  void SetAaloc(TAaloc& value);
176 
177 
178  /// Check if variant Ntloc is selected.
179  ///
180  /// Ntloc type is defined as 'typedef CNtLocation TNtloc'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsNtloc(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TNtloc& GetNtloc(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TNtloc& SetNtloc(void);
197  /// Select the variant and set its data.
198  ///
199  /// @param value
200  /// Reference to the data.
201  void SetNtloc(TNtloc& value);
202 
203 
204 private:
205  // copy constructor and assignment operator
208  // choice state
210  // helper methods
211  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
212 
213  static const char* const sm_SelectionNames[];
214  // data
215  NCBI_NS_NCBI::CSerialObject *m_object;
216 };
217 
218 /* @} */
219 
220 
221 
222 
223 
224 ///////////////////////////////////////////////////////////
225 ///////////////////// inline methods //////////////////////
226 ///////////////////////////////////////////////////////////
227 inline
229 {
230  return m_choice;
231 }
232 
233 inline
235 {
236  if ( m_choice != index )
237  ThrowInvalidSelection(index);
238 }
239 
240 inline
241 void CSeqLocation_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
242 {
243  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
244  if ( m_choice != e_not_set )
245  ResetSelection();
246  DoSelect(index, pool);
247  }
248 }
249 
250 inline
251 void CSeqLocation_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
252 {
253  Select(index, reset, 0);
254 }
255 
256 inline
258 {
259  return m_choice == e_Aaloc;
260 }
261 
262 inline
264 {
265  return m_choice == e_Ntloc;
266 }
267 
268 ///////////////////////////////////////////////////////////
269 ////////////////// end of inline methods //////////////////
270 ///////////////////////////////////////////////////////////
271 
272 
273 
274 
275 
276 END_objects_SCOPE // namespace ncbi::objects::
277 
279 
280 
281 #endif // OBJECTS_VARREP_SEQLOCATION_BASE_HPP
CNtLocation –.
Definition: NtLocation.hpp:66
CSeqLocation_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_NCBI::CSerialObject * m_object
TAaloc & SetAaloc(void)
Select the variant.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
E_Choice
Choice variants.
virtual ~CSeqLocation_Base(void)
E_Choice Which(void) const
Which variant is currently selected.
CSeqLocation_Base(const CSeqLocation_Base &)
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
CAaLocation TAaloc
const TAaloc & GetAaloc(void) const
Get the variant data.
CSerialObject Tparent
virtual void Reset(void)
Reset the whole object.
TNtloc & SetNtloc(void)
Select the variant.
CSeqLocation_Base & operator=(const CSeqLocation_Base &)
bool IsAaloc(void) const
Check if variant Aaloc is selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
CNtLocation TNtloc
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsNtloc(void) const
Check if variant Ntloc is selected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
const TNtloc & GetNtloc(void) const
Get the variant data.
static const char *const sm_SelectionNames[]
@ e_not_set
No variant selected.
@ e_MaxChoice
== e_Ntloc+1
Modified on Fri Jan 05 07:26:15 2024 by modify_doxy.py rev. 669887