NCBI C++ ToolKit
AaLocation_.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 AaLocation_.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_AALOCATION_BASE_HPP
42 #define OBJECTS_VARREP_AALOCATION_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 CAaInterval;
57 class CAaSite;
58 class CAaSiteRange;
59 
60 
61 // generated classes
62 
63 
64 /** @addtogroup dataspec_NCBI_VariationIRep
65  *
66  * @{
67  */
68 
69 /////////////////////////////////////////////////////////////////////////////
70 ///
71 /// CAaLocation_Base --
72 ///
73 
75 {
77 public:
78  // constructor
79  CAaLocation_Base(void);
80  // destructor
81  virtual ~CAaLocation_Base(void);
82 
83  // type info
85 
86 
87  /// Choice variants.
88  enum E_Choice {
89  e_not_set = 0, ///< No variant selected
92  e_Int
93  };
94  /// Maximum+1 value of the choice variant enumerator.
96  e_MaxChoice = 4 ///< == e_Int+1
97  };
98 
99  /// Reset the whole object
100  virtual void Reset(void);
101 
102  /// Reset the selection (set it to e_not_set).
103  virtual void ResetSelection(void);
104 
105  /// Which variant is currently selected.
106  ///
107  /// @return
108  /// Choice state enumerator.
109  E_Choice Which(void) const;
110 
111  /// Verify selection, throw exception if it differs from the expected.
112  ///
113  /// @param index
114  /// Expected selection.
115  void CheckSelected(E_Choice index) const;
116 
117  /// Throw 'InvalidSelection' exception.
118  ///
119  /// @param index
120  /// Expected selection.
121  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
122 
123  /// Retrieve selection name (for diagnostic purposes).
124  ///
125  /// @param index
126  /// One of possible selection states.
127  /// @return
128  /// Name string.
129  static string SelectionName(E_Choice index);
130 
131  /// Select the requested variant if needed.
132  ///
133  /// @param index
134  /// New selection state.
135  /// @param reset
136  /// Flag that defines the resetting of the variant data. The data will
137  /// be reset if either the current selection differs from the new one,
138  /// or the flag is set to eDoResetVariant.
140  /// Select the requested variant if needed,
141  /// allocating CObject variants from memory pool.
142  void Select(E_Choice index,
143  EResetVariant reset,
144  CObjectMemoryPool* pool);
145 
146  // types
147  typedef CAaSite TSite;
149  typedef CAaInterval TInt;
150 
151  // getters
152  // setters
153 
154 
155  /// Check if variant Site is selected.
156  ///
157  /// Site type is defined as 'typedef CAaSite TSite'.
158  /// @return
159  /// - true, if the variant is selected.
160  /// - false, otherwise.
161  bool IsSite(void) const;
162 
163  /// Get the variant data.
164  ///
165  /// @return
166  /// Reference to the data.
167  const TSite& GetSite(void) const;
168 
169  /// Select the variant.
170  ///
171  /// @return
172  /// Reference to the variant data.
173  TSite& SetSite(void);
174  /// Select the variant and set its data.
175  ///
176  /// @param value
177  /// Reference to the data.
178  void SetSite(TSite& value);
179 
180 
181  /// Check if variant Range is selected.
182  ///
183  /// Range type is defined as 'typedef CAaSiteRange TRange'.
184  /// @return
185  /// - true, if the variant is selected.
186  /// - false, otherwise.
187  bool IsRange(void) const;
188 
189  /// Get the variant data.
190  ///
191  /// @return
192  /// Reference to the data.
193  const TRange& GetRange(void) const;
194 
195  /// Select the variant.
196  ///
197  /// @return
198  /// Reference to the variant data.
199  TRange& SetRange(void);
200  /// Select the variant and set its data.
201  ///
202  /// @param value
203  /// Reference to the data.
204  void SetRange(TRange& value);
205 
206 
207  /// Check if variant Int is selected.
208  ///
209  /// Int type is defined as 'typedef CAaInterval TInt'.
210  /// @return
211  /// - true, if the variant is selected.
212  /// - false, otherwise.
213  bool IsInt(void) const;
214 
215  /// Get the variant data.
216  ///
217  /// @return
218  /// Reference to the data.
219  const TInt& GetInt(void) const;
220 
221  /// Select the variant.
222  ///
223  /// @return
224  /// Reference to the variant data.
225  TInt& SetInt(void);
226  /// Select the variant and set its data.
227  ///
228  /// @param value
229  /// Reference to the data.
230  void SetInt(TInt& value);
231 
232 
233 private:
234  // copy constructor and assignment operator
237  // choice state
239  // helper methods
240  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
241 
242  static const char* const sm_SelectionNames[];
243  // data
244  NCBI_NS_NCBI::CSerialObject *m_object;
245 };
246 
247 /* @} */
248 
249 
250 
251 
252 
253 ///////////////////////////////////////////////////////////
254 ///////////////////// inline methods //////////////////////
255 ///////////////////////////////////////////////////////////
256 inline
258 {
259  return m_choice;
260 }
261 
262 inline
264 {
265  if ( m_choice != index )
266  ThrowInvalidSelection(index);
267 }
268 
269 inline
270 void CAaLocation_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
271 {
272  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
273  if ( m_choice != e_not_set )
274  ResetSelection();
275  DoSelect(index, pool);
276  }
277 }
278 
279 inline
280 void CAaLocation_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
281 {
282  Select(index, reset, 0);
283 }
284 
285 inline
286 bool CAaLocation_Base::IsSite(void) const
287 {
288  return m_choice == e_Site;
289 }
290 
291 inline
293 {
294  return m_choice == e_Range;
295 }
296 
297 inline
298 bool CAaLocation_Base::IsInt(void) const
299 {
300  return m_choice == e_Int;
301 }
302 
303 ///////////////////////////////////////////////////////////
304 ////////////////// end of inline methods //////////////////
305 ///////////////////////////////////////////////////////////
306 
307 
308 
309 
310 
311 END_objects_SCOPE // namespace ncbi::objects::
312 
314 
315 
316 #endif // OBJECTS_VARREP_AALOCATION_BASE_HPP
CAaLocation_Base –.
Definition: AaLocation_.hpp:75
CAaSiteRange –.
Definition: AaSiteRange.hpp:66
CAaSite –.
Definition: AaSite.hpp:66
Base class for all serializable objects.
Definition: serialbase.hpp:150
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
CAaInterval TInt
const TInt & GetInt(void) const
Get the variant data.
TInt & SetInt(void)
Select the variant.
E_Choice
Choice variants.
Definition: AaLocation_.hpp:88
E_Choice Which(void) const
Which variant is currently selected.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: AaLocation_.cpp:59
virtual void Reset(void)
Reset the whole object.
Definition: AaLocation_.cpp:53
NCBI_NS_NCBI::CSerialObject * m_object
const TSite & GetSite(void) const
Get the variant data.
CAaLocation_Base & operator=(const CAaLocation_Base &)
static const char *const sm_SelectionNames[]
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: AaLocation_.hpp:95
CSerialObject Tparent
Definition: AaLocation_.hpp:76
TSite & SetSite(void)
Select the variant.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: AaLocation_.cpp:98
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
CAaSiteRange TRange
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TRange & GetRange(void) const
Get the variant data.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
TRange & SetRange(void)
Select the variant.
CAaLocation_Base(const CAaLocation_Base &)
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: AaLocation_.cpp:73
bool IsInt(void) const
Check if variant Int is selected.
bool IsRange(void) const
Check if variant Range is selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
virtual ~CAaLocation_Base(void)
bool IsSite(void) const
Check if variant Site is selected.
@ e_not_set
No variant selected.
Definition: AaLocation_.hpp:89
@ e_MaxChoice
== e_Int+1
Definition: AaLocation_.hpp:96
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:49 2024 by modify_doxy.py rev. 669887