NCBI C++ ToolKit
Feat_qual_legal_val_choice_.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 Feat_qual_legal_val_choice_.hpp
29 /// Data storage class.
30 ///
31 /// This file was generated by application DATATOOL
32 /// using the following specifications:
33 /// <a href="http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="http://www.ncbi.nlm.nih.gov/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_FEAT_QUAL_LEGAL_VAL_CHOICE_BASE_HPP
42 #define OBJECTS_MACRO_FEAT_QUAL_LEGAL_VAL_CHOICE_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
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Macro
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CFeat_qual_legal_val_choice_Base --
70 ///
71 
73 {
75 public:
76  // constructor
78  // destructor
80 
81  // type info
83 
84 
85  /// Choice variants.
86  enum E_Choice {
87  e_not_set = 0, ///< No variant selected
89  };
90  /// Maximum+1 value of the choice variant enumerator.
92  e_MaxChoice = 2 ///< == e_Qual+1
93  };
94 
95  /// Reset the whole object
96  virtual void Reset(void);
97 
98  /// Reset the selection (set it to e_not_set).
99  virtual void ResetSelection(void);
100 
101  /// Which variant is currently selected.
102  ///
103  /// @return
104  /// Choice state enumerator.
105  E_Choice Which(void) const;
106 
107  /// Verify selection, throw exception if it differs from the expected.
108  ///
109  /// @param index
110  /// Expected selection.
111  void CheckSelected(E_Choice index) const;
112 
113  /// Throw 'InvalidSelection' exception.
114  ///
115  /// @param index
116  /// Expected selection.
117  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
118 
119  /// Retrieve selection name (for diagnostic purposes).
120  ///
121  /// @param index
122  /// One of possible selection states.
123  /// @return
124  /// Name string.
125  static string SelectionName(E_Choice index);
126 
127  /// Select the requested variant if needed.
128  ///
129  /// @param index
130  /// New selection state.
131  /// @param reset
132  /// Flag that defines the resetting of the variant data. The data will
133  /// be reset if either the current selection differs from the new one,
134  /// or the flag is set to eDoResetVariant.
135  void Select(E_Choice index, EResetVariant reset = eDoResetVariant);
136  /// Select the requested variant if needed,
137  /// allocating CObject variants from memory pool.
138  void Select(E_Choice index,
139  EResetVariant reset,
140  CObjectMemoryPool* pool);
141 
142  // types
144 
145  // getters
146  // setters
147 
148 
149  /// Check if variant Qual is selected.
150  ///
151  /// Qual type is defined as 'typedef CFeat_qual_legal_val TQual'.
152  /// @return
153  /// - true, if the variant is selected.
154  /// - false, otherwise.
155  bool IsQual(void) const;
156 
157  /// Get the variant data.
158  ///
159  /// @return
160  /// Reference to the data.
161  const TQual& GetQual(void) const;
162 
163  /// Select the variant.
164  ///
165  /// @return
166  /// Reference to the variant data.
167  TQual& SetQual(void);
168  /// Select the variant and set its data.
169  ///
170  /// @param value
171  /// Reference to the data.
172  void SetQual(TQual& value);
173 
174 
175 private:
176  // copy constructor and assignment operator
179  // choice state
181  // helper methods
182  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
183 
184  static const char* const sm_SelectionNames[];
185  // data
186  NCBI_NS_NCBI::CSerialObject *m_object;
187 };
188 
189 /* @} */
190 
191 
192 
193 
194 
195 ///////////////////////////////////////////////////////////
196 ///////////////////// inline methods //////////////////////
197 ///////////////////////////////////////////////////////////
198 inline
200 {
201  return m_choice;
202 }
203 
204 inline
206 {
207  if ( m_choice != index )
208  ThrowInvalidSelection(index);
209 }
210 
211 inline
212 void CFeat_qual_legal_val_choice_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
213 {
214  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
215  if ( m_choice != e_not_set )
216  ResetSelection();
217  DoSelect(index, pool);
218  }
219 }
220 
221 inline
223 {
224  Select(index, reset, 0);
225 }
226 
227 inline
229 {
230  return m_choice == e_Qual;
231 }
232 
233 ///////////////////////////////////////////////////////////
234 ////////////////// end of inline methods //////////////////
235 ///////////////////////////////////////////////////////////
236 
237 
238 
239 
240 
241 END_objects_SCOPE // namespace ncbi::objects::
242 
244 
245 
246 #endif // OBJECTS_MACRO_FEAT_QUAL_LEGAL_VAL_CHOICE_BASE_HPP
#define NCBI_NORETURN
Definition: ncbiconf_msvc.h:73
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
EResetVariant
Definition: serialbase.hpp:75
Base class for all serializable objects.
Definition: serialbase.hpp:148
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1185
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
Modified on Thu Sep 03 14:34:06 2015 by modify_doxy.py rev. 426318