NCBI C++ ToolKit
Text_marker_.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 Text_marker_.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_TEXT_MARKER_BASE_HPP
42 #define OBJECTS_MACRO_TEXT_MARKER_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 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Macro
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CText_marker_Base --
70 ///
71 
73 {
75 public:
76  // constructor
77  CText_marker_Base(void);
78  // destructor
79  virtual ~CText_marker_Base(void);
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
90  e_Letters
91  };
92  /// Maximum+1 value of the choice variant enumerator.
94  e_MaxChoice = 4 ///< == e_Letters+1
95  };
96 
97  /// Reset the whole object
98  virtual void Reset(void);
99 
100  /// Reset the selection (set it to e_not_set).
101  virtual void ResetSelection(void);
102 
103  /// Which variant is currently selected.
104  ///
105  /// @return
106  /// Choice state enumerator.
107  E_Choice Which(void) const;
108 
109  /// Verify selection, throw exception if it differs from the expected.
110  ///
111  /// @param index
112  /// Expected selection.
113  void CheckSelected(E_Choice index) const;
114 
115  /// Throw 'InvalidSelection' exception.
116  ///
117  /// @param index
118  /// Expected selection.
119  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
120 
121  /// Retrieve selection name (for diagnostic purposes).
122  ///
123  /// @param index
124  /// One of possible selection states.
125  /// @return
126  /// Name string.
127  static string SelectionName(E_Choice index);
128 
129  /// Select the requested variant if needed.
130  ///
131  /// @param index
132  /// New selection state.
133  /// @param reset
134  /// Flag that defines the resetting of the variant data. The data will
135  /// be reset if either the current selection differs from the new one,
136  /// or the flag is set to eDoResetVariant.
138  /// Select the requested variant if needed,
139  /// allocating CObject variants from memory pool.
140  void Select(E_Choice index,
141  EResetVariant reset,
142  CObjectMemoryPool* pool);
143 
144  // types
145  typedef string TFree_text;
146 
147  // getters
148  // setters
149 
150 
151  /// Check if variant Free_text is selected.
152  ///
153  /// Free_text type is defined as 'typedef string TFree_text'.
154  /// @return
155  /// - true, if the variant is selected.
156  /// - false, otherwise.
157  bool IsFree_text(void) const;
158 
159  /// Get the variant data.
160  ///
161  /// @return
162  /// Reference to the data.
163  const TFree_text& GetFree_text(void) const;
164 
165  /// Select the variant.
166  ///
167  /// @return
168  /// Reference to the variant data.
169  TFree_text& SetFree_text(void);
170 
171  /// Select the variant and set its data.
172  ///
173  /// @param value
174  /// Variant data.
175  void SetFree_text(const TFree_text& value);
176 
177 
178  /// Check if variant Digits is selected.
179  ///
180  /// @return
181  /// - true, if the variant is selected.
182  /// - false, otherwise.
183  bool IsDigits(void) const;
184 
185  /// Select the variant.
186  void SetDigits(void);
187 
188 
189  /// Check if variant Letters is selected.
190  ///
191  /// @return
192  /// - true, if the variant is selected.
193  /// - false, otherwise.
194  bool IsLetters(void) const;
195 
196  /// Select the variant.
197  void SetLetters(void);
198 
199 
200 private:
201  // copy constructor and assignment operator
204  // choice state
206  // helper methods
207  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
208 
209  static const char* const sm_SelectionNames[];
210  // data
211  union {
212  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
214  };
215 };
216 
217 /* @} */
218 
219 
220 
221 
222 
223 ///////////////////////////////////////////////////////////
224 ///////////////////// inline methods //////////////////////
225 ///////////////////////////////////////////////////////////
226 inline
228 {
229  return m_choice;
230 }
231 
232 inline
234 {
235  if ( m_choice != index )
236  ThrowInvalidSelection(index);
237 }
238 
239 inline
240 void CText_marker_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
241 {
242  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
243  if ( m_choice != e_not_set )
244  ResetSelection();
245  DoSelect(index, pool);
246  }
247 }
248 
249 inline
250 void CText_marker_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
251 {
252  Select(index, reset, 0);
253 }
254 
255 inline
257 {
258  return m_choice == e_Free_text;
259 }
260 
261 inline
263 {
265  return *m_string;
266 }
267 
268 inline
270 {
272  return *m_string;
273 }
274 
275 inline
277 {
278  return m_choice == e_Digits;
279 }
280 
281 inline
283 {
285 }
286 
287 inline
289 {
290  return m_choice == e_Letters;
291 }
292 
293 inline
295 {
297 }
298 
299 ///////////////////////////////////////////////////////////
300 ////////////////// end of inline methods //////////////////
301 ///////////////////////////////////////////////////////////
302 
303 
304 
305 
306 
307 END_objects_SCOPE // namespace ncbi::objects::
308 
310 
311 
312 #endif // OBJECTS_MACRO_TEXT_MARKER_BASE_HPP
Base class for all serializable objects.
Definition: serialbase.hpp:150
CText_marker_Base –.
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
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
bool IsLetters(void) const
Check if variant Letters is selected.
const TFree_text & GetFree_text(void) const
Get the variant data.
void SetLetters(void)
Select the variant.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
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.
TFree_text & SetFree_text(void)
Select the variant.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
bool IsDigits(void) const
Check if variant Digits is selected.
static const char *const sm_SelectionNames[]
virtual void Reset(void)
Reset the whole object.
E_Choice
Choice variants.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
CText_marker_Base & operator=(const CText_marker_Base &)
E_Choice Which(void) const
Which variant is currently selected.
CSerialObject Tparent
void SetDigits(void)
Select the variant.
bool IsFree_text(void) const
Check if variant Free_text is selected.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
CText_marker_Base(const CText_marker_Base &)
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
virtual ~CText_marker_Base(void)
@ e_MaxChoice
== e_Letters+1
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed May 29 18:43:26 2024 by modify_doxy.py rev. 669887