NCBI C++ ToolKit
T3StatusFlags_.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 T3StatusFlags_.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/taxon3/taxon3.asn">taxon3.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/taxon3/taxon3.def">taxon3.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_TAXON3_T3STATUSFLAGS_BASE_HPP
42 #define OBJECTS_TAXON3_T3STATUSFLAGS_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_Taxon3
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CT3StatusFlags_Base --
70 ///
71 
73 {
75 public:
76  // constructor
77  CT3StatusFlags_Base(void);
78  // destructor
79  virtual ~CT3StatusFlags_Base(void);
80 
81  // type info
83 
84  /////////////////////////////////////////////////////////////////////////////
85  ///
86  /// C_Value --
87  ///
88 
90  {
92  public:
93  // constructor
94  C_Value(void);
95  // destructor
96  ~C_Value(void);
97 
98  // type info
100 
101 
102  /// Choice variants.
103  enum E_Choice {
104  e_not_set = 0, ///< No variant selected
107  e_Str
108  };
109  /// Maximum+1 value of the choice variant enumerator.
111  e_MaxChoice = 4 ///< == e_Str+1
112  };
113 
114  /// Reset the whole object
115  void Reset(void);
116 
117  /// Reset the selection (set it to e_not_set).
118  void ResetSelection(void);
119 
120  /// Which variant is currently selected.
121  ///
122  /// @return
123  /// Choice state enumerator.
124  E_Choice Which(void) const;
125 
126  /// Verify selection, throw exception if it differs from the expected.
127  ///
128  /// @param index
129  /// Expected selection.
130  void CheckSelected(E_Choice index) const;
131 
132  /// Throw 'InvalidSelection' exception.
133  ///
134  /// @param index
135  /// Expected selection.
136  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
137 
138  /// Retrieve selection name (for diagnostic purposes).
139  ///
140  /// @param index
141  /// One of possible selection states.
142  /// @return
143  /// Name string.
144  static string SelectionName(E_Choice index);
145 
146  /// Select the requested variant if needed.
147  ///
148  /// @param index
149  /// New selection state.
150  /// @param reset
151  /// Flag that defines the resetting of the variant data. The data will
152  /// be reset if either the current selection differs from the new one,
153  /// or the flag is set to eDoResetVariant.
155  /// Select the requested variant if needed,
156  /// allocating CObject variants from memory pool.
157  void Select(E_Choice index,
158  EResetVariant reset,
159  CObjectMemoryPool* pool);
160 
161  // types
162  typedef bool TBool;
163  typedef int TInt;
164  typedef string TStr;
165 
166  // getters
167  // setters
168 
169 
170  /// Check if variant Bool is selected.
171  ///
172  /// Bool type is defined as 'typedef bool TBool'.
173  /// @return
174  /// - true, if the variant is selected.
175  /// - false, otherwise.
176  bool IsBool(void) const;
177 
178  /// Get the variant data.
179  ///
180  /// @return
181  /// Copy of the variant data.
182  TBool GetBool(void) const;
183 
184  /// Select the variant.
185  ///
186  /// @return
187  /// Reference to the variant data.
188  TBool& SetBool(void);
189 
190  /// Select the variant and set its data.
191  ///
192  /// @param value
193  /// Variant data.
194  void SetBool(TBool value);
195 
196 
197  /// Check if variant Int is selected.
198  ///
199  /// Int type is defined as 'typedef int TInt'.
200  /// @return
201  /// - true, if the variant is selected.
202  /// - false, otherwise.
203  bool IsInt(void) const;
204 
205  /// Get the variant data.
206  ///
207  /// @return
208  /// Copy of the variant data.
209  TInt GetInt(void) const;
210 
211  /// Select the variant.
212  ///
213  /// @return
214  /// Reference to the variant data.
215  TInt& SetInt(void);
216 
217  /// Select the variant and set its data.
218  ///
219  /// @param value
220  /// Variant data.
221  void SetInt(TInt value);
222 
223 
224  /// Check if variant Str is selected.
225  ///
226  /// Str type is defined as 'typedef string TStr'.
227  /// @return
228  /// - true, if the variant is selected.
229  /// - false, otherwise.
230  bool IsStr(void) const;
231 
232  /// Get the variant data.
233  ///
234  /// @return
235  /// Reference to the data.
236  const TStr& GetStr(void) const;
237 
238  /// Select the variant.
239  ///
240  /// @return
241  /// Reference to the variant data.
242  TStr& SetStr(void);
243 
244  /// Select the variant and set its data.
245  ///
246  /// @param value
247  /// Variant data.
248  void SetStr(const TStr& value);
249 
250 
251  private:
252  // copy constructor and assignment operator
253  C_Value(const C_Value& );
255  // choice state
257  // helper methods
258  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
259 
260  static const char* const sm_SelectionNames[];
261  // data
262  union {
265  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
267  };
268  };
269  // types
270  typedef string TProperty;
271  typedef C_Value TValue;
272 
273  // member index
274  enum class E_memberIndex {
275  e__allMandatory = 0,
276  e_property,
277  e_value
278  };
280 
281  // getters
282  // setters
283 
284  /// Check if a value has been assigned to Property data member.
285  ///
286  /// Data member Property is mandatory;
287  /// its type is defined as 'typedef string TProperty'
288  /// @return
289  /// - true, if a value has been assigned.
290  /// - false, otherwise.
291  bool IsSetProperty(void) const;
292 
293  /// Check if it is safe to call GetProperty method.
294  ///
295  /// @return
296  /// - true, if the data member is getatable.
297  /// - false, otherwise.
298  bool CanGetProperty(void) const;
299 
300  /// Reset Property data member.
301  void ResetProperty(void);
302 
303  /// Get the Property member data.
304  ///
305  /// @return
306  /// Reference to the member data.
307  const TProperty& GetProperty(void) const;
308 
309  /// Assign a value to Property data member.
310  ///
311  /// @param value
312  /// Value to assign
313  void SetProperty(const TProperty& value);
314  void SetProperty(TProperty&& value);
315 
316  /// Assign a value to Property data member.
317  ///
318  /// @return
319  /// Reference to the data value.
320  TProperty& SetProperty(void);
321 
322  /// Check if a value has been assigned to Value data member.
323  ///
324  /// Data member Value is mandatory;
325  /// its type is defined as 'typedef C_Value TValue'
326  /// @return
327  /// - true, if a value has been assigned.
328  /// - false, otherwise.
329  bool IsSetValue(void) const;
330 
331  /// Check if it is safe to call GetValue method.
332  ///
333  /// @return
334  /// - true, if the data member is getatable.
335  /// - false, otherwise.
336  bool CanGetValue(void) const;
337 
338  /// Reset Value data member.
339  void ResetValue(void);
340 
341  /// Get the Value member data.
342  ///
343  /// @return
344  /// Reference to the member data.
345  const TValue& GetValue(void) const;
346 
347  /// Assign a value to Value data member.
348  ///
349  /// @param value
350  /// Reference to value.
351  void SetValue(TValue& value);
352 
353  /// Assign a value to Value data member.
354  ///
355  /// @return
356  /// Reference to the data value.
357  TValue& SetValue(void);
358 
359  /// Reset the whole object
360  virtual void Reset(void);
361 
362 
363 private:
364  // Prohibit copy constructor and assignment operator
367 
368  // data
369  Uint4 m_set_State[1];
370  string m_Property;
372 };
373 
374 /* @} */
375 
376 
377 
378 
379 
380 ///////////////////////////////////////////////////////////
381 ///////////////////// inline methods //////////////////////
382 ///////////////////////////////////////////////////////////
383 inline
385 {
386  return m_choice;
387 }
388 
389 inline
391 {
392  if ( m_choice != index )
393  ThrowInvalidSelection(index);
394 }
395 
396 inline
397 void CT3StatusFlags_Base::C_Value::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
398 {
399  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
400  if ( m_choice != e_not_set )
401  ResetSelection();
402  DoSelect(index, pool);
403  }
404 }
405 
406 inline
408 {
409  Select(index, reset, 0);
410 }
411 
412 inline
414 {
415  return m_choice == e_Bool;
416 }
417 
418 inline
420 {
421  CheckSelected(e_Bool);
422  return m_Bool;
423 }
424 
425 inline
427 {
428  Select(e_Bool, NCBI_NS_NCBI::eDoNotResetVariant);
429  return m_Bool;
430 }
431 
432 inline
434 {
435  Select(e_Bool, NCBI_NS_NCBI::eDoNotResetVariant);
436  m_Bool = value;
437 }
438 
439 inline
441 {
442  return m_choice == e_Int;
443 }
444 
445 inline
447 {
448  CheckSelected(e_Int);
449  return m_Int;
450 }
451 
452 inline
454 {
455  Select(e_Int, NCBI_NS_NCBI::eDoNotResetVariant);
456  return m_Int;
457 }
458 
459 inline
461 {
462  Select(e_Int, NCBI_NS_NCBI::eDoNotResetVariant);
463  m_Int = value;
464 }
465 
466 inline
468 {
469  return m_choice == e_Str;
470 }
471 
472 inline
474 {
475  CheckSelected(e_Str);
476  return *m_string;
477 }
478 
479 inline
481 {
482  Select(e_Str, NCBI_NS_NCBI::eDoNotResetVariant);
483  return *m_string;
484 }
485 
486 inline
488 {
489  return ((m_set_State[0] & 0x3) != 0);
490 }
491 
492 inline
494 {
495  return IsSetProperty();
496 }
497 
498 inline
500 {
501  if (!CanGetProperty()) {
502  ThrowUnassigned(0);
503  }
504  return m_Property;
505 }
506 
507 inline
509 {
510  m_Property = value;
511  m_set_State[0] |= 0x3;
512 }
513 
514 inline
516 {
517  m_Property = std::forward<CT3StatusFlags_Base::TProperty>(value);
518  m_set_State[0] |= 0x3;
519 }
520 
521 inline
523 {
524 #ifdef _DEBUG
525  if (!IsSetProperty()) {
527  }
528 #endif
529  m_set_State[0] |= 0x1;
530  return m_Property;
531 }
532 
533 inline
535 {
536  return m_Value.NotEmpty();
537 }
538 
539 inline
541 {
542  return true;
543 }
544 
545 inline
547 {
548  if ( !m_Value ) {
549  const_cast<CT3StatusFlags_Base*>(this)->ResetValue();
550  }
551  return (*m_Value);
552 }
553 
554 inline
556 {
557  if ( !m_Value ) {
558  ResetValue();
559  }
560  return (*m_Value);
561 }
562 
563 ///////////////////////////////////////////////////////////
564 ////////////////// end of inline methods //////////////////
565 ///////////////////////////////////////////////////////////
566 
567 
568 
569 
570 
571 END_objects_SCOPE // namespace ncbi::objects::
572 
574 
575 
576 #endif // OBJECTS_TAXON3_T3STATUSFLAGS_BASE_HPP
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
CT3StatusFlags_Base –.
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
static string UnassignedString(void)
Definition: serialbase.hpp:175
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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_TAXON3_EXPORT
Definition: ncbi_export.h:865
bool IsBool(void) const
Check if variant Bool is selected.
CSerialObject Tparent
TBool & SetBool(void)
Select the variant.
TValue & SetValue(void)
Assign a value to Value data member.
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
TBool GetBool(void) const
Get the variant data.
CT3StatusFlags_Base & operator=(const CT3StatusFlags_Base &)
TInt & SetInt(void)
Select the variant.
bool CanGetProperty(void) const
Check if it is safe to call GetProperty method.
bool IsStr(void) const
Check if variant Str is selected.
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TStr & GetStr(void) const
Get the variant data.
const TProperty & GetProperty(void) const
Get the Property member data.
E_Choice Which(void) const
Which variant is currently selected.
bool CanGetValue(void) const
Check if it is safe to call GetValue method.
CRef< TValue > m_Value
bool IsInt(void) const
Check if variant Int is selected.
const TValue & GetValue(void) const
Get the Value member data.
TProperty & SetProperty(void)
Assign a value to Property data member.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void ResetValue(void)
Reset Value data member.
CT3StatusFlags_Base(const CT3StatusFlags_Base &)
TStr & SetStr(void)
Select the variant.
C_Value & operator=(const C_Value &)
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool IsSetProperty(void) const
Check if a value has been assigned to Property data member.
TInt GetInt(void) const
Get the variant data.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsSetValue(void) const
Check if a value has been assigned to Value data member.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:31 2024 by modify_doxy.py rev. 669887