NCBI C++ ToolKit
Replace_func_.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 Replace_func_.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_REPLACE_FUNC_BASE_HPP
42 #define OBJECTS_MACRO_REPLACE_FUNC_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 CSimple_replace;
61 
62 
63 // generated classes
64 
65 
66 /** @addtogroup dataspec_NCBI_Macro
67  *
68  * @{
69  */
70 
71 /////////////////////////////////////////////////////////////////////////////
72 ///
73 /// CReplace_func_Base --
74 ///
75 
77 {
79 public:
80  // constructor
81  CReplace_func_Base(void);
82  // destructor
83  virtual ~CReplace_func_Base(void);
84 
85  // type info
87 
88 
89  /// Choice variants.
90  enum E_Choice {
91  e_not_set = 0, ///< No variant selected
94  };
95  /// Maximum+1 value of the choice variant enumerator.
97  e_MaxChoice = 3 ///< == e_Haem_replace+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
149  typedef string THaem_replace;
150 
151  // getters
152  // setters
153 
154 
155  /// Check if variant Simple_replace is selected.
156  ///
157  /// Simple_replace type is defined as 'typedef CSimple_replace TSimple_replace'.
158  /// @return
159  /// - true, if the variant is selected.
160  /// - false, otherwise.
161  bool IsSimple_replace(void) const;
162 
163  /// Get the variant data.
164  ///
165  /// @return
166  /// Reference to the data.
167  const TSimple_replace& GetSimple_replace(void) const;
168 
169  /// Select the variant.
170  ///
171  /// @return
172  /// Reference to the variant data.
174  /// Select the variant and set its data.
175  ///
176  /// @param value
177  /// Reference to the data.
179 
180 
181  /// Check if variant Haem_replace is selected.
182  ///
183  /// Haem_replace type is defined as 'typedef string THaem_replace'.
184  /// @return
185  /// - true, if the variant is selected.
186  /// - false, otherwise.
187  bool IsHaem_replace(void) const;
188 
189  /// Get the variant data.
190  ///
191  /// @return
192  /// Reference to the data.
193  const THaem_replace& GetHaem_replace(void) const;
194 
195  /// Select the variant.
196  ///
197  /// @return
198  /// Reference to the variant data.
200 
201  /// Select the variant and set its data.
202  ///
203  /// @param value
204  /// Variant data.
205  void SetHaem_replace(const THaem_replace& value);
206 
207 
208 private:
209  // copy constructor and assignment operator
212  // choice state
214  // helper methods
215  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
216 
217  static const char* const sm_SelectionNames[];
218  // data
219  union {
220  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
221  NCBI_NS_NCBI::CSerialObject *m_object;
222  };
223 };
224 
225 /* @} */
226 
227 
228 
229 
230 
231 ///////////////////////////////////////////////////////////
232 ///////////////////// inline methods //////////////////////
233 ///////////////////////////////////////////////////////////
234 inline
236 {
237  return m_choice;
238 }
239 
240 inline
242 {
243  if ( m_choice != index )
244  ThrowInvalidSelection(index);
245 }
246 
247 inline
248 void CReplace_func_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
249 {
250  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
251  if ( m_choice != e_not_set )
252  ResetSelection();
253  DoSelect(index, pool);
254  }
255 }
256 
257 inline
259 {
260  Select(index, reset, 0);
261 }
262 
263 inline
265 {
266  return m_choice == e_Simple_replace;
267 }
268 
269 inline
271 {
272  return m_choice == e_Haem_replace;
273 }
274 
275 inline
277 {
279  return *m_string;
280 }
281 
282 inline
284 {
286  return *m_string;
287 }
288 
289 ///////////////////////////////////////////////////////////
290 ////////////////// end of inline methods //////////////////
291 ///////////////////////////////////////////////////////////
292 
293 
294 
295 
296 
297 END_objects_SCOPE // namespace ncbi::objects::
298 
300 
301 
302 #endif // OBJECTS_MACRO_REPLACE_FUNC_BASE_HPP
CReplace_func_Base –.
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
CReplace_func_Base(const CReplace_func_Base &)
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
NCBI_NS_NCBI::CSerialObject * m_object
const TSimple_replace & GetSimple_replace(void) const
Get the variant data.
CSerialObject Tparent
const THaem_replace & GetHaem_replace(void) const
Get the variant data.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TSimple_replace & SetSimple_replace(void)
Select the variant.
CReplace_func_Base & operator=(const CReplace_func_Base &)
bool IsHaem_replace(void) const
Check if variant Haem_replace is selected.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
virtual void Reset(void)
Reset the whole object.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
virtual ~CReplace_func_Base(void)
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
static const char *const sm_SelectionNames[]
bool IsSimple_replace(void) const
Check if variant Simple_replace is selected.
THaem_replace & SetHaem_replace(void)
Select the variant.
E_Choice Which(void) const
Which variant is currently selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CSimple_replace TSimple_replace
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
E_Choice
Choice variants.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
@ e_not_set
No variant selected.
@ e_MaxChoice
== e_Haem_replace+1
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:57:52 2024 by modify_doxy.py rev. 669887