NCBI C++ ToolKit
Quantity_constraint_.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 Quantity_constraint_.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_QUANTITY_CONSTRAINT_BASE_HPP
42 #define OBJECTS_MACRO_QUANTITY_CONSTRAINT_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 // generated classes
56 
57 
58 /** @addtogroup dataspec_NCBI_Macro
59  *
60  * @{
61  */
62 
63 /////////////////////////////////////////////////////////////////////////////
64 ///
65 /// CQuantity_constraint_Base --
66 ///
67 
69 {
71 public:
72  // constructor
74  // destructor
75  virtual ~CQuantity_constraint_Base(void);
76 
77  // type info
79 
80 
81  /// Choice variants.
82  enum E_Choice {
83  e_not_set = 0, ///< No variant selected
87  };
88  /// Maximum+1 value of the choice variant enumerator.
90  e_MaxChoice = 4 ///< == e_Less_than+1
91  };
92 
93  /// Reset the whole object
94  virtual void Reset(void);
95 
96  /// Reset the selection (set it to e_not_set).
97  virtual void ResetSelection(void);
98 
99  /// Which variant is currently selected.
100  ///
101  /// @return
102  /// Choice state enumerator.
103  E_Choice Which(void) const;
104 
105  /// Verify selection, throw exception if it differs from the expected.
106  ///
107  /// @param index
108  /// Expected selection.
109  void CheckSelected(E_Choice index) const;
110 
111  /// Throw 'InvalidSelection' exception.
112  ///
113  /// @param index
114  /// Expected selection.
115  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
116 
117  /// Retrieve selection name (for diagnostic purposes).
118  ///
119  /// @param index
120  /// One of possible selection states.
121  /// @return
122  /// Name string.
123  static string SelectionName(E_Choice index);
124 
125  /// Select the requested variant if needed.
126  ///
127  /// @param index
128  /// New selection state.
129  /// @param reset
130  /// Flag that defines the resetting of the variant data. The data will
131  /// be reset if either the current selection differs from the new one,
132  /// or the flag is set to eDoResetVariant.
134  /// Select the requested variant if needed,
135  /// allocating CObject variants from memory pool.
136  void Select(E_Choice index,
137  EResetVariant reset,
138  CObjectMemoryPool* pool);
139 
140  // types
141  typedef int TEquals;
142  typedef int TGreater_than;
143  typedef int TLess_than;
144 
145  // getters
146  // setters
147 
148 
149  /// Check if variant Equals is selected.
150  ///
151  /// Equals type is defined as 'typedef int TEquals'.
152  /// @return
153  /// - true, if the variant is selected.
154  /// - false, otherwise.
155  bool IsEquals(void) const;
156 
157  /// Get the variant data.
158  ///
159  /// @return
160  /// Copy of the variant data.
161  TEquals GetEquals(void) const;
162 
163  /// Select the variant.
164  ///
165  /// @return
166  /// Reference to the variant data.
167  TEquals& SetEquals(void);
168 
169  /// Select the variant and set its data.
170  ///
171  /// @param value
172  /// Variant data.
173  void SetEquals(TEquals value);
174 
175 
176  /// Check if variant Greater_than is selected.
177  ///
178  /// Greater_than type is defined as 'typedef int TGreater_than'.
179  /// @return
180  /// - true, if the variant is selected.
181  /// - false, otherwise.
182  bool IsGreater_than(void) const;
183 
184  /// Get the variant data.
185  ///
186  /// @return
187  /// Copy of the variant data.
188  TGreater_than GetGreater_than(void) const;
189 
190  /// Select the variant.
191  ///
192  /// @return
193  /// Reference to the variant data.
195 
196  /// Select the variant and set its data.
197  ///
198  /// @param value
199  /// Variant data.
201 
202 
203  /// Check if variant Less_than is selected.
204  ///
205  /// Less_than type is defined as 'typedef int TLess_than'.
206  /// @return
207  /// - true, if the variant is selected.
208  /// - false, otherwise.
209  bool IsLess_than(void) const;
210 
211  /// Get the variant data.
212  ///
213  /// @return
214  /// Copy of the variant data.
215  TLess_than GetLess_than(void) const;
216 
217  /// Select the variant.
218  ///
219  /// @return
220  /// Reference to the variant data.
221  TLess_than& SetLess_than(void);
222 
223  /// Select the variant and set its data.
224  ///
225  /// @param value
226  /// Variant data.
228 
229 
230 private:
231  // copy constructor and assignment operator
234  // choice state
236  // helper methods
237  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
238 
239  static const char* const sm_SelectionNames[];
240  // data
241  union {
245  };
246 };
247 
248 /* @} */
249 
250 
251 
252 
253 
254 ///////////////////////////////////////////////////////////
255 ///////////////////// inline methods //////////////////////
256 ///////////////////////////////////////////////////////////
257 inline
259 {
260  return m_choice;
261 }
262 
263 inline
265 {
266  if ( m_choice != index )
267  ThrowInvalidSelection(index);
268 }
269 
270 inline
271 void CQuantity_constraint_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
272 {
273  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
274  if ( m_choice != e_not_set )
275  ResetSelection();
276  DoSelect(index, pool);
277  }
278 }
279 
280 inline
282 {
283  Select(index, reset, 0);
284 }
285 
286 inline
288 {
289  return m_choice == e_Equals;
290 }
291 
292 inline
294 {
296  return m_Equals;
297 }
298 
299 inline
301 {
303  return m_Equals;
304 }
305 
306 inline
308 {
310  m_Equals = value;
311 }
312 
313 inline
315 {
316  return m_choice == e_Greater_than;
317 }
318 
319 inline
321 {
323  return m_Greater_than;
324 }
325 
326 inline
328 {
330  return m_Greater_than;
331 }
332 
333 inline
335 {
338 }
339 
340 inline
342 {
343  return m_choice == e_Less_than;
344 }
345 
346 inline
348 {
350  return m_Less_than;
351 }
352 
353 inline
355 {
357  return m_Less_than;
358 }
359 
360 inline
362 {
364  m_Less_than = value;
365 }
366 
367 ///////////////////////////////////////////////////////////
368 ////////////////// end of inline methods //////////////////
369 ///////////////////////////////////////////////////////////
370 
371 
372 
373 
374 
375 END_objects_SCOPE // namespace ncbi::objects::
376 
378 
379 
380 #endif // OBJECTS_MACRO_QUANTITY_CONSTRAINT_BASE_HPP
CQuantity_constraint_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
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
static const char *const sm_SelectionNames[]
CQuantity_constraint_Base(const CQuantity_constraint_Base &)
TEquals GetEquals(void) const
Get the variant data.
bool IsLess_than(void) const
Check if variant Less_than is selected.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
TLess_than GetLess_than(void) const
Get the variant data.
CQuantity_constraint_Base & operator=(const CQuantity_constraint_Base &)
E_Choice Which(void) const
Which variant is currently selected.
bool IsEquals(void) const
Check if variant Equals is selected.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
TLess_than & SetLess_than(void)
Select the variant.
TEquals & SetEquals(void)
Select the variant.
virtual void Reset(void)
Reset the whole object.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TGreater_than GetGreater_than(void) const
Get the variant data.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
TGreater_than & SetGreater_than(void)
Select the variant.
bool IsGreater_than(void) const
Check if variant Greater_than is selected.
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Tue May 28 05:48:52 2024 by modify_doxy.py rev. 669887