NCBI C++ ToolKit
Cdd_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 Cdd_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/cdd/cdd.asn">cdd.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/cdd/cdd.def">cdd.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_CDD_CDD_ID_BASE_HPP
42 #define OBJECTS_CDD_CDD_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 CGlobal_id;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Cdd
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CCdd_id_Base --
70 ///
71 
73 {
75 public:
76  // constructor
77  CCdd_id_Base(void);
78  // destructor
79  virtual ~CCdd_id_Base(void);
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
88  e_Uid, ///< for synchronization with Entrez holds PSSM-Ids
89  e_Gid ///< holds accession/version pairs
90  };
91  /// Maximum+1 value of the choice variant enumerator.
93  e_MaxChoice = 3 ///< == e_Gid+1
94  };
95 
96  /// Reset the whole object
97  virtual void Reset(void);
98 
99  /// Reset the selection (set it to e_not_set).
100  virtual void ResetSelection(void);
101 
102  /// Which variant is currently selected.
103  ///
104  /// @return
105  /// Choice state enumerator.
106  E_Choice Which(void) const;
107 
108  /// Verify selection, throw exception if it differs from the expected.
109  ///
110  /// @param index
111  /// Expected selection.
112  void CheckSelected(E_Choice index) const;
113 
114  /// Throw 'InvalidSelection' exception.
115  ///
116  /// @param index
117  /// Expected selection.
118  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
119 
120  /// Retrieve selection name (for diagnostic purposes).
121  ///
122  /// @param index
123  /// One of possible selection states.
124  /// @return
125  /// Name string.
126  static string SelectionName(E_Choice index);
127 
128  /// Select the requested variant if needed.
129  ///
130  /// @param index
131  /// New selection state.
132  /// @param reset
133  /// Flag that defines the resetting of the variant data. The data will
134  /// be reset if either the current selection differs from the new one,
135  /// or the flag is set to eDoResetVariant.
137  /// Select the requested variant if needed,
138  /// allocating CObject variants from memory pool.
139  void Select(E_Choice index,
140  EResetVariant reset,
141  CObjectMemoryPool* pool);
142 
143  // types
144  typedef int TUid;
145  typedef CGlobal_id TGid;
146 
147  // getters
148  // setters
149 
150 
151  /// Check if variant Uid is selected.
152  ///
153  /// Uid type is defined as 'typedef int TUid'.
154  /// @return
155  /// - true, if the variant is selected.
156  /// - false, otherwise.
157  bool IsUid(void) const;
158 
159  /// Get the variant data.
160  ///
161  /// @return
162  /// Copy of the variant data.
163  TUid GetUid(void) const;
164 
165  /// Select the variant.
166  ///
167  /// @return
168  /// Reference to the variant data.
169  TUid& SetUid(void);
170 
171  /// Select the variant and set its data.
172  ///
173  /// @param value
174  /// Variant data.
175  void SetUid(TUid value);
176 
177 
178  /// Check if variant Gid is selected.
179  ///
180  /// Gid type is defined as 'typedef CGlobal_id TGid'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsGid(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TGid& GetGid(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TGid& SetGid(void);
197  /// Select the variant and set its data.
198  ///
199  /// @param value
200  /// Reference to the data.
201  void SetGid(TGid& 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 {
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 CCdd_id_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
254 void CCdd_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
255 {
256  Select(index, reset, 0);
257 }
258 
259 inline
260 bool CCdd_id_Base::IsUid(void) const
261 {
262  return m_choice == e_Uid;
263 }
264 
265 inline
267 {
269  return m_Uid;
270 }
271 
272 inline
274 {
276  return m_Uid;
277 }
278 
279 inline
281 {
283  m_Uid = value;
284 }
285 
286 inline
287 bool CCdd_id_Base::IsGid(void) const
288 {
289  return m_choice == e_Gid;
290 }
291 
292 ///////////////////////////////////////////////////////////
293 ////////////////// end of inline methods //////////////////
294 ///////////////////////////////////////////////////////////
295 
296 
297 
298 
299 
300 END_objects_SCOPE // namespace ncbi::objects::
301 
303 
304 
305 #endif // OBJECTS_CDD_CDD_ID_BASE_HPP
CCdd_id_Base –.
Definition: Cdd_id_.hpp:73
CGlobal_id –.
Definition: Global_id.hpp:66
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
#define NCBI_CDD_EXPORT
Definition: ncbi_export.h:368
bool IsGid(void) const
Check if variant Gid is selected.
Definition: Cdd_id_.hpp:287
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
CGlobal_id TGid
Definition: Cdd_id_.hpp:145
TUid & SetUid(void)
Select the variant.
Definition: Cdd_id_.hpp:273
E_Choice Which(void) const
Which variant is currently selected.
Definition: Cdd_id_.hpp:231
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Cdd_id_.cpp:57
CSerialObject Tparent
Definition: Cdd_id_.hpp:74
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Cdd_id_.hpp:92
CCdd_id_Base(const CCdd_id_Base &)
TUid GetUid(void) const
Get the variant data.
Definition: Cdd_id_.hpp:266
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Cdd_id_.hpp:237
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Cdd_id_.hpp:217
E_Choice
Choice variants.
Definition: Cdd_id_.hpp:86
CCdd_id_Base & operator=(const CCdd_id_Base &)
DECLARE_INTERNAL_TYPE_INFO()
bool IsUid(void) const
Check if variant Uid is selected.
Definition: Cdd_id_.hpp:260
E_Choice m_choice
Definition: Cdd_id_.hpp:209
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Cdd_id_.cpp:69
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Cdd_id_.cpp:95
@ e_Gid
holds accession/version pairs
Definition: Cdd_id_.hpp:89
@ e_not_set
No variant selected.
Definition: Cdd_id_.hpp:87
@ e_Uid
for synchronization with Entrez holds PSSM-Ids
Definition: Cdd_id_.hpp:88
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:15 2024 by modify_doxy.py rev. 669887