NCBI C++ ToolKit
Annot_id_.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 Annot_id_.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/seq/seq.asn">seq.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seq/seq.def">seq.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_SEQ_ANNOT_ID_BASE_HPP
42 #define OBJECTS_SEQ_ANNOT_ID_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 CDbtag;
57 class CObject_id;
58 class CTextannot_id;
59 
60 
61 // generated classes
62 
63 
64 /** @addtogroup dataspec_NCBI_Sequence
65  *
66  * @{
67  */
68 
69 /////////////////////////////////////////////////////////////////////////////
70 ///
71 /// CAnnot_id_Base --
72 ///
73 
75 {
77 public:
78  // constructor
79  CAnnot_id_Base(void);
80  // destructor
81  virtual ~CAnnot_id_Base(void);
82 
83  // type info
85 
86 
87  /// Choice variants.
88  enum E_Choice {
89  e_not_set = 0, ///< No variant selected
93  e_Other
94  };
95  /// Maximum+1 value of the choice variant enumerator.
97  e_MaxChoice = 5 ///< == e_Other+1
98  };
99 
100  /// Reset the whole object
101  virtual void Reset(void);
102 
103  /// Reset the selection (set it to e_not_set).
104  virtual void ResetSelection(void);
105 
106  /// Which variant is currently selected.
107  ///
108  /// @return
109  /// Choice state enumerator.
110  E_Choice Which(void) const;
111 
112  /// Verify selection, throw exception if it differs from the expected.
113  ///
114  /// @param index
115  /// Expected selection.
116  void CheckSelected(E_Choice index) const;
117 
118  /// Throw 'InvalidSelection' exception.
119  ///
120  /// @param index
121  /// Expected selection.
122  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
123 
124  /// Retrieve selection name (for diagnostic purposes).
125  ///
126  /// @param index
127  /// One of possible selection states.
128  /// @return
129  /// Name string.
130  static string SelectionName(E_Choice index);
131 
132  /// Select the requested variant if needed.
133  ///
134  /// @param index
135  /// New selection state.
136  /// @param reset
137  /// Flag that defines the resetting of the variant data. The data will
138  /// be reset if either the current selection differs from the new one,
139  /// or the flag is set to eDoResetVariant.
141  /// Select the requested variant if needed,
142  /// allocating CObject variants from memory pool.
143  void Select(E_Choice index,
144  EResetVariant reset,
145  CObjectMemoryPool* pool);
146 
147  // types
150  typedef CDbtag TGeneral;
152 
153  // getters
154  // setters
155 
156 
157  /// Check if variant Local is selected.
158  ///
159  /// Local type is defined as 'typedef CObject_id TLocal'.
160  /// @return
161  /// - true, if the variant is selected.
162  /// - false, otherwise.
163  bool IsLocal(void) const;
164 
165  /// Get the variant data.
166  ///
167  /// @return
168  /// Reference to the data.
169  const TLocal& GetLocal(void) const;
170 
171  /// Select the variant.
172  ///
173  /// @return
174  /// Reference to the variant data.
175  TLocal& SetLocal(void);
176  /// Select the variant and set its data.
177  ///
178  /// @param value
179  /// Reference to the data.
180  void SetLocal(TLocal& value);
181 
182 
183  /// Check if variant Ncbi is selected.
184  ///
185  /// Ncbi type is defined as 'typedef NCBI_NS_NCBI::TEntrezId TNcbi'.
186  /// @return
187  /// - true, if the variant is selected.
188  /// - false, otherwise.
189  bool IsNcbi(void) const;
190 
191  /// Get the variant data.
192  ///
193  /// @return
194  /// Copy of the variant data.
195  TNcbi GetNcbi(void) const;
196 
197  /// Select the variant.
198  ///
199  /// @return
200  /// Reference to the variant data.
201  TNcbi& SetNcbi(void);
202 
203  /// Select the variant and set its data.
204  ///
205  /// @param value
206  /// Variant data.
207  void SetNcbi(TNcbi value);
208 
209 
210  /// Check if variant General is selected.
211  ///
212  /// General type is defined as 'typedef CDbtag TGeneral'.
213  /// @return
214  /// - true, if the variant is selected.
215  /// - false, otherwise.
216  bool IsGeneral(void) const;
217 
218  /// Get the variant data.
219  ///
220  /// @return
221  /// Reference to the data.
222  const TGeneral& GetGeneral(void) const;
223 
224  /// Select the variant.
225  ///
226  /// @return
227  /// Reference to the variant data.
228  TGeneral& SetGeneral(void);
229  /// Select the variant and set its data.
230  ///
231  /// @param value
232  /// Reference to the data.
233  void SetGeneral(TGeneral& value);
234 
235 
236  /// Check if variant Other is selected.
237  ///
238  /// Other type is defined as 'typedef CTextannot_id TOther'.
239  /// @return
240  /// - true, if the variant is selected.
241  /// - false, otherwise.
242  bool IsOther(void) const;
243 
244  /// Get the variant data.
245  ///
246  /// @return
247  /// Reference to the data.
248  const TOther& GetOther(void) const;
249 
250  /// Select the variant.
251  ///
252  /// @return
253  /// Reference to the variant data.
254  TOther& SetOther(void);
255  /// Select the variant and set its data.
256  ///
257  /// @param value
258  /// Reference to the data.
259  void SetOther(TOther& value);
260 
261 
262 private:
263  // copy constructor and assignment operator
266  // choice state
268  // helper methods
269  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
270 
271  static const char* const sm_SelectionNames[];
272  // data
273  union {
275  NCBI_NS_NCBI::CSerialObject *m_object;
276  };
277 };
278 
279 /* @} */
280 
281 
282 
283 
284 
285 ///////////////////////////////////////////////////////////
286 ///////////////////// inline methods //////////////////////
287 ///////////////////////////////////////////////////////////
288 inline
290 {
291  return m_choice;
292 }
293 
294 inline
296 {
297  if ( m_choice != index )
298  ThrowInvalidSelection(index);
299 }
300 
301 inline
302 void CAnnot_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
303 {
304  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
305  if ( m_choice != e_not_set )
306  ResetSelection();
307  DoSelect(index, pool);
308  }
309 }
310 
311 inline
312 void CAnnot_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
313 {
314  Select(index, reset, 0);
315 }
316 
317 inline
318 bool CAnnot_id_Base::IsLocal(void) const
319 {
320  return m_choice == e_Local;
321 }
322 
323 inline
324 bool CAnnot_id_Base::IsNcbi(void) const
325 {
326  return m_choice == e_Ncbi;
327 }
328 
329 inline
331 {
333  return reinterpret_cast<const TNcbi&>(m_Ncbi);
334 }
335 
336 inline
338 {
340  return reinterpret_cast<TNcbi&>(m_Ncbi);
341 }
342 
343 inline
345 {
347  reinterpret_cast<TNcbi&>(m_Ncbi) = value;
348 }
349 
350 inline
352 {
353  return m_choice == e_General;
354 }
355 
356 inline
357 bool CAnnot_id_Base::IsOther(void) const
358 {
359  return m_choice == e_Other;
360 }
361 
362 ///////////////////////////////////////////////////////////
363 ////////////////// end of inline methods //////////////////
364 ///////////////////////////////////////////////////////////
365 
366 
367 
368 
369 
370 END_objects_SCOPE // namespace ncbi::objects::
371 
373 
374 
375 #endif // OBJECTS_SEQ_ANNOT_ID_BASE_HPP
CAnnot_id_Base –.
Definition: Annot_id_.hpp:75
Definition: Dbtag.hpp:53
Base class for all serializable objects.
Definition: serialbase.hpp:150
CTextannot_id –.
SStrictId_Entrez::TId TEntrezId
TEntrezId type for entrez ids which require the same strictness as TGi.
Definition: ncbimisc.hpp:1041
Int8 TIntId
Definition: ncbimisc.hpp:999
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_SEQ_EXPORT
Definition: ncbi_export.h:825
NCBI_NS_NCBI::TEntrezId TNcbi
Definition: Annot_id_.hpp:149
CAnnot_id_Base & operator=(const CAnnot_id_Base &)
TNcbi GetNcbi(void) const
Get the variant data.
Definition: Annot_id_.hpp:330
CSerialObject Tparent
Definition: Annot_id_.hpp:76
E_Choice m_choice
Definition: Annot_id_.hpp:267
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
E_Choice Which(void) const
Which variant is currently selected.
Definition: Annot_id_.hpp:289
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Annot_id_.hpp:351
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Annot_id_.cpp:59
ncbi::TIntId m_Ncbi
Definition: Annot_id_.hpp:274
E_Choice
Choice variants.
Definition: Annot_id_.hpp:88
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Annot_id_.cpp:73
TNcbi & SetNcbi(void)
Select the variant.
Definition: Annot_id_.hpp:337
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Annot_id_.hpp:295
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Annot_id_.hpp:96
bool IsOther(void) const
Check if variant Other is selected.
Definition: Annot_id_.hpp:357
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Annot_id_.hpp:275
ncbi::TIntId m_Ncbi
Definition: Annot_id_.hpp:274
CObject_id TLocal
Definition: Annot_id_.hpp:148
CTextannot_id TOther
Definition: Annot_id_.hpp:151
CAnnot_id_Base(const CAnnot_id_Base &)
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Annot_id_.hpp:318
DECLARE_INTERNAL_TYPE_INFO()
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Annot_id_.cpp:107
bool IsNcbi(void) const
Check if variant Ncbi is selected.
Definition: Annot_id_.hpp:324
@ e_not_set
No variant selected.
Definition: Annot_id_.hpp:89
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sat May 25 14:17:09 2024 by modify_doxy.py rev. 669887