NCBI C++ ToolKit
CDSGenePr_constraint_field_.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 CDSGenePr_constraint_field_.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_CDSGENEPR_CONSTRAINT_FIELD_BASE_HPP
42 #define OBJECTS_MACRO_CDSGENEPR_CONSTRAINT_FIELD_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
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 /// CCDSGeneProt_constraint_field_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
88  e_Field
89  };
90  /// Maximum+1 value of the choice variant enumerator.
92  e_MaxChoice = 2 ///< == e_Field+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.
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 Field is selected.
150  ///
151  /// Field type is defined as 'typedef ECDSGeneProt_field TField'.
152  /// @return
153  /// - true, if the variant is selected.
154  /// - false, otherwise.
155  bool IsField(void) const;
156 
157  /// Get the variant data.
158  ///
159  /// @return
160  /// Copy of the variant data.
161  TField GetField(void) const;
162 
163  /// Select the variant.
164  ///
165  /// @return
166  /// Reference to the variant data.
167  TField& SetField(void);
168 
169  /// Select the variant and set its data.
170  ///
171  /// @param value
172  /// Variant data.
173  void SetField(TField value);
174 
175 
176 private:
177  // copy constructor and assignment operator
180  // choice state
182  // helper methods
183  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
184 
185  static const char* const sm_SelectionNames[];
186  // data
187  union {
189  };
190 };
191 
192 /* @} */
193 
194 
195 
196 
197 
198 ///////////////////////////////////////////////////////////
199 ///////////////////// inline methods //////////////////////
200 ///////////////////////////////////////////////////////////
201 inline
203 {
204  return m_choice;
205 }
206 
207 inline
209 {
210  if ( m_choice != index )
211  ThrowInvalidSelection(index);
212 }
213 
214 inline
215 void CCDSGeneProt_constraint_field_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
216 {
217  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
218  if ( m_choice != e_not_set )
219  ResetSelection();
220  DoSelect(index, pool);
221  }
222 }
223 
224 inline
226 {
227  Select(index, reset, 0);
228 }
229 
230 inline
232 {
233  return m_choice == e_Field;
234 }
235 
236 inline
238 {
240  return m_Field;
241 }
242 
243 inline
245 {
247  return m_Field;
248 }
249 
250 inline
252 {
254  m_Field = value;
255 }
256 
257 ///////////////////////////////////////////////////////////
258 ////////////////// end of inline methods //////////////////
259 ///////////////////////////////////////////////////////////
260 
261 
262 
263 
264 
265 END_objects_SCOPE // namespace ncbi::objects::
266 
268 
269 
270 #endif // OBJECTS_MACRO_CDSGENEPR_CONSTRAINT_FIELD_BASE_HPP
User-defined methods of the data storage class.
CCDSGeneProt_constraint_field_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
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.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
TField GetField(void) const
Get the variant data.
CCDSGeneProt_constraint_field_Base & operator=(const CCDSGeneProt_constraint_field_Base &)
E_Choice Which(void) const
Which variant is currently selected.
CCDSGeneProt_constraint_field_Base(const CCDSGeneProt_constraint_field_Base &)
virtual void Reset(void)
Reset the whole object.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
ECDSGeneProt_field
Access to ECDSGeneProt_field's attributes (values, names) as defined in spec.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TField & SetField(void)
Select the variant.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
bool IsField(void) const
Check if variant Field is selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
Modified on Wed Dec 06 07:15:57 2023 by modify_doxy.py rev. 669887