NCBI C++ ToolKit
T3Request_.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 T3Request_.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/taxon3/taxon3.asn">taxon3.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/taxon3/taxon3.def">taxon3.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_TAXON3_T3REQUEST_BASE_HPP
42 #define OBJECTS_TAXON3_T3REQUEST_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <string>
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 COrg_ref;
61 class CSequenceOfInt;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_Taxon3
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///
74 /// CT3Request_Base --
75 ///
76 
78 {
80 public:
81  // constructor
82  CT3Request_Base(void);
83  // destructor
84  virtual ~CT3Request_Base(void);
85 
86  // type info
88 
89 
90  /// Choice variants.
91  enum E_Choice {
92  e_not_set = 0, ///< No variant selected
96  e_Join
97  };
98  /// Maximum+1 value of the choice variant enumerator.
100  e_MaxChoice = 5 ///< == e_Join+1
101  };
102 
103  /// Reset the whole object
104  virtual void Reset(void);
105 
106  /// Reset the selection (set it to e_not_set).
107  virtual void ResetSelection(void);
108 
109  /// Which variant is currently selected.
110  ///
111  /// @return
112  /// Choice state enumerator.
113  E_Choice Which(void) const;
114 
115  /// Verify selection, throw exception if it differs from the expected.
116  ///
117  /// @param index
118  /// Expected selection.
119  void CheckSelected(E_Choice index) const;
120 
121  /// Throw 'InvalidSelection' exception.
122  ///
123  /// @param index
124  /// Expected selection.
125  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
126 
127  /// Retrieve selection name (for diagnostic purposes).
128  ///
129  /// @param index
130  /// One of possible selection states.
131  /// @return
132  /// Name string.
133  static string SelectionName(E_Choice index);
134 
135  /// Select the requested variant if needed.
136  ///
137  /// @param index
138  /// New selection state.
139  /// @param reset
140  /// Flag that defines the resetting of the variant data. The data will
141  /// be reset if either the current selection differs from the new one,
142  /// or the flag is set to eDoResetVariant.
144  /// Select the requested variant if needed,
145  /// allocating CObject variants from memory pool.
146  void Select(E_Choice index,
147  EResetVariant reset,
148  CObjectMemoryPool* pool);
149 
150  // types
151  typedef int TTaxid;
152  typedef string TName;
153  typedef COrg_ref TOrg;
155 
156  // getters
157  // setters
158 
159 
160  /// Check if variant Taxid is selected.
161  ///
162  /// Taxid type is defined as 'typedef int TTaxid'.
163  /// @return
164  /// - true, if the variant is selected.
165  /// - false, otherwise.
166  bool IsTaxid(void) const;
167 
168  /// Get the variant data.
169  ///
170  /// @return
171  /// Copy of the variant data.
172  TTaxid GetTaxid(void) const;
173 
174  /// Select the variant.
175  ///
176  /// @return
177  /// Reference to the variant data.
178  TTaxid& SetTaxid(void);
179 
180  /// Select the variant and set its data.
181  ///
182  /// @param value
183  /// Variant data.
184  void SetTaxid(TTaxid value);
185 
186 
187  /// Check if variant Name is selected.
188  ///
189  /// Name type is defined as 'typedef string TName'.
190  /// @return
191  /// - true, if the variant is selected.
192  /// - false, otherwise.
193  bool IsName(void) const;
194 
195  /// Get the variant data.
196  ///
197  /// @return
198  /// Reference to the data.
199  const TName& GetName(void) const;
200 
201  /// Select the variant.
202  ///
203  /// @return
204  /// Reference to the variant data.
205  TName& SetName(void);
206 
207  /// Select the variant and set its data.
208  ///
209  /// @param value
210  /// Variant data.
211  void SetName(const TName& value);
212 
213 
214  /// Check if variant Org is selected.
215  ///
216  /// Org type is defined as 'typedef COrg_ref TOrg'.
217  /// @return
218  /// - true, if the variant is selected.
219  /// - false, otherwise.
220  bool IsOrg(void) const;
221 
222  /// Get the variant data.
223  ///
224  /// @return
225  /// Reference to the data.
226  const TOrg& GetOrg(void) const;
227 
228  /// Select the variant.
229  ///
230  /// @return
231  /// Reference to the variant data.
232  TOrg& SetOrg(void);
233  /// Select the variant and set its data.
234  ///
235  /// @param value
236  /// Reference to the data.
237  void SetOrg(TOrg& value);
238 
239 
240  /// Check if variant Join is selected.
241  ///
242  /// Join type is defined as 'typedef CSequenceOfInt TJoin'.
243  /// @return
244  /// - true, if the variant is selected.
245  /// - false, otherwise.
246  bool IsJoin(void) const;
247 
248  /// Get the variant data.
249  ///
250  /// @return
251  /// Reference to the data.
252  const TJoin& GetJoin(void) const;
253 
254  /// Select the variant.
255  ///
256  /// @return
257  /// Reference to the variant data.
258  TJoin& SetJoin(void);
259  /// Select the variant and set its data.
260  ///
261  /// @param value
262  /// Reference to the data.
263  void SetJoin(TJoin& value);
264 
265 
266 private:
267  // copy constructor and assignment operator
270  // choice state
272  // helper methods
273  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
274 
275  static const char* const sm_SelectionNames[];
276  // data
277  union {
279  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
280  NCBI_NS_NCBI::CSerialObject *m_object;
281  };
282 };
283 
284 /* @} */
285 
286 
287 
288 
289 
290 ///////////////////////////////////////////////////////////
291 ///////////////////// inline methods //////////////////////
292 ///////////////////////////////////////////////////////////
293 inline
295 {
296  return m_choice;
297 }
298 
299 inline
301 {
302  if ( m_choice != index )
303  ThrowInvalidSelection(index);
304 }
305 
306 inline
307 void CT3Request_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
308 {
309  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
310  if ( m_choice != e_not_set )
311  ResetSelection();
312  DoSelect(index, pool);
313  }
314 }
315 
316 inline
317 void CT3Request_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
318 {
319  Select(index, reset, 0);
320 }
321 
322 inline
323 bool CT3Request_Base::IsTaxid(void) const
324 {
325  return m_choice == e_Taxid;
326 }
327 
328 inline
330 {
332  return m_Taxid;
333 }
334 
335 inline
337 {
339  return m_Taxid;
340 }
341 
342 inline
344 {
346  m_Taxid = value;
347 }
348 
349 inline
350 bool CT3Request_Base::IsName(void) const
351 {
352  return m_choice == e_Name;
353 }
354 
355 inline
357 {
359  return *m_string;
360 }
361 
362 inline
364 {
366  return *m_string;
367 }
368 
369 inline
370 bool CT3Request_Base::IsOrg(void) const
371 {
372  return m_choice == e_Org;
373 }
374 
375 inline
376 bool CT3Request_Base::IsJoin(void) const
377 {
378  return m_choice == e_Join;
379 }
380 
381 ///////////////////////////////////////////////////////////
382 ////////////////// end of inline methods //////////////////
383 ///////////////////////////////////////////////////////////
384 
385 
386 
387 
388 
389 END_objects_SCOPE // namespace ncbi::objects::
390 
392 
393 
394 #endif // OBJECTS_TAXON3_T3REQUEST_BASE_HPP
CSequenceOfInt –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
CT3Request_Base –.
Definition: T3Request_.hpp:78
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
#define NCBI_TAXON3_EXPORT
Definition: ncbi_export.h:865
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: T3Request_.hpp:300
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: T3Request_.cpp:74
bool IsName(void) const
Check if variant Name is selected.
Definition: T3Request_.hpp:350
bool IsJoin(void) const
Check if variant Join is selected.
Definition: T3Request_.hpp:376
E_Choice m_choice
Definition: T3Request_.hpp:271
TTaxid GetTaxid(void) const
Get the variant data.
Definition: T3Request_.hpp:329
TName & SetName(void)
Select the variant.
Definition: T3Request_.hpp:363
bool IsOrg(void) const
Check if variant Org is selected.
Definition: T3Request_.hpp:370
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TName & GetName(void) const
Get the variant data.
Definition: T3Request_.hpp:356
CT3Request_Base & operator=(const CT3Request_Base &)
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: T3Request_.hpp:99
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: T3Request_.hpp:279
NCBI_NS_NCBI::CSerialObject * m_object
Definition: T3Request_.hpp:280
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: T3Request_.hpp:279
bool IsTaxid(void) const
Check if variant Taxid is selected.
Definition: T3Request_.hpp:323
E_Choice Which(void) const
Which variant is currently selected.
Definition: T3Request_.hpp:294
TTaxid & SetTaxid(void)
Select the variant.
Definition: T3Request_.hpp:336
CSequenceOfInt TJoin
Definition: T3Request_.hpp:154
CSerialObject Tparent
Definition: T3Request_.hpp:79
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CT3Request_Base(const CT3Request_Base &)
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: T3Request_.cpp:58
E_Choice
Choice variants.
Definition: T3Request_.hpp:91
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: T3Request_.cpp:108
@ e_not_set
No variant selected.
Definition: T3Request_.hpp:92
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sun Jun 16 04:34:10 2024 by modify_doxy.py rev. 669887