NCBI C++ ToolKit
Location_choice_.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 Location_choice_.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/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.def">macro.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_MACRO_LOCATION_CHOICE_BASE_HPP
42 #define OBJECTS_MACRO_LOCATION_CHOICE_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 CLocation_interval;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Macro
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CLocation_choice_Base --
70 ///
71 
73 {
75 public:
76  // constructor
78  // destructor
79  virtual ~CLocation_choice_Base(void);
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
90  e_Point
91  };
92  /// Maximum+1 value of the choice variant enumerator.
94  e_MaxChoice = 4 ///< == e_Point+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
146  typedef int TPoint;
147 
148  // getters
149  // setters
150 
151 
152  /// Check if variant Interval is selected.
153  ///
154  /// Interval type is defined as 'typedef CLocation_interval TInterval'.
155  /// @return
156  /// - true, if the variant is selected.
157  /// - false, otherwise.
158  bool IsInterval(void) const;
159 
160  /// Get the variant data.
161  ///
162  /// @return
163  /// Reference to the data.
164  const TInterval& GetInterval(void) const;
165 
166  /// Select the variant.
167  ///
168  /// @return
169  /// Reference to the variant data.
170  TInterval& SetInterval(void);
171  /// Select the variant and set its data.
172  ///
173  /// @param value
174  /// Reference to the data.
175  void SetInterval(TInterval& value);
176 
177 
178  /// Check if variant Whole_sequence is selected.
179  ///
180  /// @return
181  /// - true, if the variant is selected.
182  /// - false, otherwise.
183  bool IsWhole_sequence(void) const;
184 
185  /// Select the variant.
186  void SetWhole_sequence(void);
187 
188 
189  /// Check if variant Point is selected.
190  ///
191  /// Point type is defined as 'typedef int TPoint'.
192  /// @return
193  /// - true, if the variant is selected.
194  /// - false, otherwise.
195  bool IsPoint(void) const;
196 
197  /// Get the variant data.
198  ///
199  /// @return
200  /// Copy of the variant data.
201  TPoint GetPoint(void) const;
202 
203  /// Select the variant.
204  ///
205  /// @return
206  /// Reference to the variant data.
207  TPoint& SetPoint(void);
208 
209  /// Select the variant and set its data.
210  ///
211  /// @param value
212  /// Variant data.
213  void SetPoint(TPoint value);
214 
215 
216 private:
217  // copy constructor and assignment operator
220  // choice state
222  // helper methods
223  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
224 
225  static const char* const sm_SelectionNames[];
226  // data
227  union {
229  NCBI_NS_NCBI::CSerialObject *m_object;
230  };
231 };
232 
233 /* @} */
234 
235 
236 
237 
238 
239 ///////////////////////////////////////////////////////////
240 ///////////////////// inline methods //////////////////////
241 ///////////////////////////////////////////////////////////
242 inline
244 {
245  return m_choice;
246 }
247 
248 inline
250 {
251  if ( m_choice != index )
252  ThrowInvalidSelection(index);
253 }
254 
255 inline
256 void CLocation_choice_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
257 {
258  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
259  if ( m_choice != e_not_set )
260  ResetSelection();
261  DoSelect(index, pool);
262  }
263 }
264 
265 inline
267 {
268  Select(index, reset, 0);
269 }
270 
271 inline
273 {
274  return m_choice == e_Interval;
275 }
276 
277 inline
279 {
280  return m_choice == e_Whole_sequence;
281 }
282 
283 inline
285 {
287 }
288 
289 inline
291 {
292  return m_choice == e_Point;
293 }
294 
295 inline
297 {
299  return m_Point;
300 }
301 
302 inline
304 {
306  return m_Point;
307 }
308 
309 inline
311 {
313  m_Point = value;
314 }
315 
316 ///////////////////////////////////////////////////////////
317 ////////////////// end of inline methods //////////////////
318 ///////////////////////////////////////////////////////////
319 
320 
321 
322 
323 
324 END_objects_SCOPE // namespace ncbi::objects::
325 
327 
328 
329 #endif // OBJECTS_MACRO_LOCATION_CHOICE_BASE_HPP
CLocation_choice_Base –.
CLocation_interval –.
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 ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
bool IsWhole_sequence(void) const
Check if variant Whole_sequence is selected.
E_Choice
Choice variants.
virtual void Reset(void)
Reset the whole object.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
CLocation_choice_Base & operator=(const CLocation_choice_Base &)
const TInterval & GetInterval(void) const
Get the variant data.
E_Choice Which(void) const
Which variant is currently selected.
TPoint GetPoint(void) const
Get the variant data.
void SetWhole_sequence(void)
Select the variant.
TInterval & SetInterval(void)
Select the variant.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CLocation_interval TInterval
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
TPoint & SetPoint(void)
Select the variant.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
bool IsPoint(void) const
Check if variant Point is selected.
NCBI_NS_NCBI::CSerialObject * m_object
CLocation_choice_Base(const CLocation_choice_Base &)
bool IsInterval(void) const
Check if variant Interval is selected.
static const char *const sm_SelectionNames[]
virtual ~CLocation_choice_Base(void)
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu May 30 12:26:44 2024 by modify_doxy.py rev. 669887