NCBI C++ ToolKit
SearchByRsIdReply_.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 SearchByRsIdReply_.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/variation_libs/dbsnp/search_by_rsid/search_by_rsid.asn">search_by_rsid.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/variation_libs/dbsnp/search_by_rsid/search_by_rsid.def">search_by_rsid.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_VARIATION_LIBS_DBSNP_SEARCH_BY_RSID_SEARCHBYRSIDREPLY_BASE_HPP
42 #define OBJECTS_VARIATION_LIBS_DBSNP_SEARCH_BY_RSID_SEARCHBYRSIDREPLY_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
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 CError;
61 class CPlacement;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_search_by_rsid
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 /// Service reply format definition.
74 ///
75 /// CSearchByRsIdReply_Base --
76 ///
77 
79 {
81 public:
82  // constructor
84  // destructor
85  virtual ~CSearchByRsIdReply_Base(void);
86 
87  // type info
89 
90 
91  /// Choice variants.
92  enum E_Choice {
93  e_not_set = 0, ///< No variant selected
94  e_Placements, ///< On success list of placements will be placed here.
95  e_Error ///< On failure error details will be placed here,
96  };
97  /// Maximum+1 value of the choice variant enumerator.
99  e_MaxChoice = 3 ///< == e_Error+1
100  };
101 
102  /// Reset the whole object
103  virtual void Reset(void);
104 
105  /// Reset the selection (set it to e_not_set).
106  virtual void ResetSelection(void);
107 
108  /// Which variant is currently selected.
109  ///
110  /// @return
111  /// Choice state enumerator.
112  E_Choice Which(void) const;
113 
114  /// Verify selection, throw exception if it differs from the expected.
115  ///
116  /// @param index
117  /// Expected selection.
118  void CheckSelected(E_Choice index) const;
119 
120  /// Throw 'InvalidSelection' exception.
121  ///
122  /// @param index
123  /// Expected selection.
124  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
125 
126  /// Retrieve selection name (for diagnostic purposes).
127  ///
128  /// @param index
129  /// One of possible selection states.
130  /// @return
131  /// Name string.
132  static string SelectionName(E_Choice index);
133 
134  /// Select the requested variant if needed.
135  ///
136  /// @param index
137  /// New selection state.
138  /// @param reset
139  /// Flag that defines the resetting of the variant data. The data will
140  /// be reset if either the current selection differs from the new one,
141  /// or the flag is set to eDoResetVariant.
143  /// Select the requested variant if needed,
144  /// allocating CObject variants from memory pool.
145  void Select(E_Choice index,
146  EResetVariant reset,
147  CObjectMemoryPool* pool);
148 
149  // types
150  typedef list< CRef< CPlacement > > TPlacements;
151  typedef CError TError;
152 
153  // getters
154  // setters
155 
156 
157  /// Check if variant Placements is selected.
158  ///
159  /// Placements type is defined as 'typedef list< CRef< CPlacement > > TPlacements'.
160  /// @return
161  /// - true, if the variant is selected.
162  /// - false, otherwise.
163  bool IsPlacements(void) const;
164 
165  /// Get the variant data.
166  ///
167  /// @return
168  /// Reference to the data.
169  const TPlacements& GetPlacements(void) const;
170 
171  /// Select the variant.
172  ///
173  /// @return
174  /// Reference to the variant data.
175  TPlacements& SetPlacements(void);
176 
177 
178  /// Check if variant Error is selected.
179  ///
180  /// Error type is defined as 'typedef CError TError'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsError(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TError& GetError(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TError& SetError(void);
197  /// Select the variant and set its data.
198  ///
199  /// @param value
200  /// Reference to the data.
201  void SetError(TError& 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  union {
216  NCBI_NS_NCBI::CUnionBuffer<TPlacements> m_Placements;
217  NCBI_NS_NCBI::CSerialObject *m_object;
218  };
219 };
220 
221 /* @} */
222 
223 
224 
225 
226 
227 ///////////////////////////////////////////////////////////
228 ///////////////////// inline methods //////////////////////
229 ///////////////////////////////////////////////////////////
230 inline
232 {
233  return m_choice;
234 }
235 
236 inline
238 {
239  if ( m_choice != index )
240  ThrowInvalidSelection(index);
241 }
242 
243 inline
244 void CSearchByRsIdReply_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
245 {
246  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
247  if ( m_choice != e_not_set )
248  ResetSelection();
249  DoSelect(index, pool);
250  }
251 }
252 
253 inline
255 {
256  Select(index, reset, 0);
257 }
258 
259 inline
261 {
262  return m_choice == e_Placements;
263 }
264 
265 inline
267 {
269  return *m_Placements;
270 }
271 
272 inline
274 {
276  return *m_Placements;
277 }
278 
279 inline
281 {
282  return m_choice == e_Error;
283 }
284 
285 ///////////////////////////////////////////////////////////
286 ////////////////// end of inline methods //////////////////
287 ///////////////////////////////////////////////////////////
288 
289 
290 
291 
292 
293 END_objects_SCOPE // namespace ncbi::objects::
294 
296 
297 
298 #endif // OBJECTS_VARIATION_LIBS_DBSNP_SEARCH_BY_RSID_SEARCHBYRSIDREPLY_BASE_HPP
CError –.
Definition: Error.hpp:66
CPlacement –.
Definition: Placement.hpp:66
Service reply format definition.
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 ~CSearchByRsIdReply_Base(void)
bool IsPlacements(void) const
Check if variant Placements is selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
E_Choice Which(void) const
Which variant is currently selected.
list< CRef< CPlacement > > TPlacements
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
static const char *const sm_SelectionNames[]
NCBI_NS_NCBI::CSerialObject * m_object
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
NCBI_NS_NCBI::CUnionBuffer< TPlacements > m_Placements
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
CSearchByRsIdReply_Base & operator=(const CSearchByRsIdReply_Base &)
TError & SetError(void)
Select the variant.
const TPlacements & GetPlacements(void) const
Get the variant data.
const TError & GetError(void) const
Get the variant data.
bool IsError(void) const
Check if variant Error is selected.
NCBI_NS_NCBI::CUnionBuffer< TPlacements > m_Placements
virtual void Reset(void)
Reset the whole object.
TPlacements & SetPlacements(void)
Select the variant.
CSearchByRsIdReply_Base(const CSearchByRsIdReply_Base &)
@ e_not_set
No variant selected.
@ e_Error
On failure error details will be placed here,.
@ e_Placements
On success list of placements will be placed here.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:36 2024 by modify_doxy.py rev. 669887