NCBI C++ ToolKit
Create_TSA_ids_src_.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 Create_TSA_ids_src_.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_CREATE_TSA_IDS_SRC_BASE_HPP
42 #define OBJECTS_MACRO_CREATE_TSA_IDS_SRC_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 CText_portion;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Macro
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CCreate_TSA_ids_src_Base --
70 ///
71 
73 {
75 public:
76  // constructor
78  // destructor
79  virtual ~CCreate_TSA_ids_src_Base(void);
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
89  e_Defline
90  };
91  /// Maximum+1 value of the choice variant enumerator.
93  e_MaxChoice = 3 ///< == e_Defline+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
145 
146  // getters
147  // setters
148 
149 
150  /// Check if variant Local_id is selected.
151  ///
152  /// @return
153  /// - true, if the variant is selected.
154  /// - false, otherwise.
155  bool IsLocal_id(void) const;
156 
157  /// Select the variant.
158  void SetLocal_id(void);
159 
160 
161  /// Check if variant Defline is selected.
162  ///
163  /// Defline type is defined as 'typedef CText_portion TDefline'.
164  /// @return
165  /// - true, if the variant is selected.
166  /// - false, otherwise.
167  bool IsDefline(void) const;
168 
169  /// Get the variant data.
170  ///
171  /// @return
172  /// Reference to the data.
173  const TDefline& GetDefline(void) const;
174 
175  /// Select the variant.
176  ///
177  /// @return
178  /// Reference to the variant data.
179  TDefline& SetDefline(void);
180  /// Select the variant and set its data.
181  ///
182  /// @param value
183  /// Reference to the data.
184  void SetDefline(TDefline& value);
185 
186 
187 private:
188  // copy constructor and assignment operator
191  // choice state
193  // helper methods
194  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
195 
196  static const char* const sm_SelectionNames[];
197  // data
198  union {
199  NCBI_NS_NCBI::CSerialObject *m_object;
200  };
201 };
202 
203 /* @} */
204 
205 
206 
207 
208 
209 ///////////////////////////////////////////////////////////
210 ///////////////////// inline methods //////////////////////
211 ///////////////////////////////////////////////////////////
212 inline
214 {
215  return m_choice;
216 }
217 
218 inline
220 {
221  if ( m_choice != index )
222  ThrowInvalidSelection(index);
223 }
224 
225 inline
226 void CCreate_TSA_ids_src_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
227 {
228  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
229  if ( m_choice != e_not_set )
230  ResetSelection();
231  DoSelect(index, pool);
232  }
233 }
234 
235 inline
237 {
238  Select(index, reset, 0);
239 }
240 
241 inline
243 {
244  return m_choice == e_Local_id;
245 }
246 
247 inline
249 {
251 }
252 
253 inline
255 {
256  return m_choice == e_Defline;
257 }
258 
259 ///////////////////////////////////////////////////////////
260 ////////////////// end of inline methods //////////////////
261 ///////////////////////////////////////////////////////////
262 
263 
264 
265 
266 
267 END_objects_SCOPE // namespace ncbi::objects::
268 
270 
271 
272 #endif // OBJECTS_MACRO_CREATE_TSA_IDS_SRC_BASE_HPP
CCreate_TSA_ids_src_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
CText_portion –.
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 CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
static const char *const sm_SelectionNames[]
bool IsLocal_id(void) const
Check if variant Local_id is selected.
CCreate_TSA_ids_src_Base(const CCreate_TSA_ids_src_Base &)
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CCreate_TSA_ids_src_Base & operator=(const CCreate_TSA_ids_src_Base &)
E_Choice Which(void) const
Which variant is currently selected.
NCBI_NS_NCBI::CSerialObject * m_object
virtual void Reset(void)
Reset the whole object.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
void SetLocal_id(void)
Select the variant.
const TDefline & GetDefline(void) const
Get the variant data.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
TDefline & SetDefline(void)
Select the variant.
bool IsDefline(void) const
Check if variant Defline is selected.
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu May 23 12:28:44 2024 by modify_doxy.py rev. 669887