NCBI C++ ToolKit
Residue_pntrs_.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 Residue_pntrs_.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/mmdb3/mmdb3.asn">mmdb3.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/mmdb3/mmdb3.def">mmdb3.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_MMDB3_RESIDUE_PNTRS_BASE_HPP
42 #define OBJECTS_MMDB3_RESIDUE_PNTRS_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
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 // forward declarations
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_MMDB_Features
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///
74 /// CResidue_pntrs_Base --
75 ///
76 
78 {
80 public:
81  // constructor
82  CResidue_pntrs_Base(void);
83  // destructor
84  virtual ~CResidue_pntrs_Base(void);
85 
86  // type info
88 
89 
90  /// Choice variants.
91  enum E_Choice {
92  e_not_set = 0, ///< No variant selected
94  e_Interval
95  };
96  /// Maximum+1 value of the choice variant enumerator.
98  e_MaxChoice = 3 ///< == e_Interval+1
99  };
100 
101  /// Reset the whole object
102  virtual void Reset(void);
103 
104  /// Reset the selection (set it to e_not_set).
105  virtual void ResetSelection(void);
106 
107  /// Which variant is currently selected.
108  ///
109  /// @return
110  /// Choice state enumerator.
111  E_Choice Which(void) const;
112 
113  /// Verify selection, throw exception if it differs from the expected.
114  ///
115  /// @param index
116  /// Expected selection.
117  void CheckSelected(E_Choice index) const;
118 
119  /// Throw 'InvalidSelection' exception.
120  ///
121  /// @param index
122  /// Expected selection.
123  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
124 
125  /// Retrieve selection name (for diagnostic purposes).
126  ///
127  /// @param index
128  /// One of possible selection states.
129  /// @return
130  /// Name string.
131  static string SelectionName(E_Choice index);
132 
133  /// Select the requested variant if needed.
134  ///
135  /// @param index
136  /// New selection state.
137  /// @param reset
138  /// Flag that defines the resetting of the variant data. The data will
139  /// be reset if either the current selection differs from the new one,
140  /// or the flag is set to eDoResetVariant.
142  /// Select the requested variant if needed,
143  /// allocating CObject variants from memory pool.
144  void Select(E_Choice index,
145  EResetVariant reset,
146  CObjectMemoryPool* pool);
147 
148  // types
150  typedef list< CRef< CResidue_interval_pntr > > TInterval;
151 
152  // getters
153  // setters
154 
155 
156  /// Check if variant Explicit is selected.
157  ///
158  /// Explicit type is defined as 'typedef CResidue_explicit_pntrs TExplicit'.
159  /// @return
160  /// - true, if the variant is selected.
161  /// - false, otherwise.
162  bool IsExplicit(void) const;
163 
164  /// Get the variant data.
165  ///
166  /// @return
167  /// Reference to the data.
168  const TExplicit& GetExplicit(void) const;
169 
170  /// Select the variant.
171  ///
172  /// @return
173  /// Reference to the variant data.
174  TExplicit& SetExplicit(void);
175  /// Select the variant and set its data.
176  ///
177  /// @param value
178  /// Reference to the data.
179  void SetExplicit(TExplicit& value);
180 
181 
182  /// Check if variant Interval is selected.
183  ///
184  /// Interval type is defined as 'typedef list< CRef< CResidue_interval_pntr > > TInterval'.
185  /// @return
186  /// - true, if the variant is selected.
187  /// - false, otherwise.
188  bool IsInterval(void) const;
189 
190  /// Get the variant data.
191  ///
192  /// @return
193  /// Reference to the data.
194  const TInterval& GetInterval(void) const;
195 
196  /// Select the variant.
197  ///
198  /// @return
199  /// Reference to the variant data.
200  TInterval& SetInterval(void);
201 
202 
203 private:
204  // copy constructor and assignment operator
207  // choice state
209  // helper methods
210  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
211 
212  static const char* const sm_SelectionNames[];
213  // data
214  union {
215  NCBI_NS_NCBI::CUnionBuffer<TInterval> m_Interval;
216  NCBI_NS_NCBI::CSerialObject *m_object;
217  };
218 };
219 
220 /* @} */
221 
222 
223 
224 
225 
226 ///////////////////////////////////////////////////////////
227 ///////////////////// inline methods //////////////////////
228 ///////////////////////////////////////////////////////////
229 inline
231 {
232  return m_choice;
233 }
234 
235 inline
237 {
238  if ( m_choice != index )
239  ThrowInvalidSelection(index);
240 }
241 
242 inline
243 void CResidue_pntrs_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
244 {
245  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
246  if ( m_choice != e_not_set )
247  ResetSelection();
248  DoSelect(index, pool);
249  }
250 }
251 
252 inline
254 {
255  Select(index, reset, 0);
256 }
257 
258 inline
260 {
261  return m_choice == e_Explicit;
262 }
263 
264 inline
266 {
267  return m_choice == e_Interval;
268 }
269 
270 inline
272 {
274  return *m_Interval;
275 }
276 
277 inline
279 {
281  return *m_Interval;
282 }
283 
284 ///////////////////////////////////////////////////////////
285 ////////////////// end of inline methods //////////////////
286 ///////////////////////////////////////////////////////////
287 
288 
289 
290 
291 
292 END_objects_SCOPE // namespace ncbi::objects::
293 
295 
296 
297 #endif // OBJECTS_MMDB3_RESIDUE_PNTRS_BASE_HPP
CResidue_explicit_pntrs –.
CResidue_interval_pntr –.
CResidue_pntrs_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
#define NCBI_MMDB3_EXPORT
Definition: ncbi_export.h:640
CSerialObject Tparent
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
list< CRef< CResidue_interval_pntr > > TInterval
bool IsInterval(void) const
Check if variant Interval is selected.
const TInterval & GetInterval(void) const
Get the variant data.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
TInterval & SetInterval(void)
Select the variant.
E_Choice Which(void) const
Which variant is currently selected.
CResidue_pntrs_Base & operator=(const CResidue_pntrs_Base &)
NCBI_NS_NCBI::CSerialObject * m_object
NCBI_NS_NCBI::CUnionBuffer< TInterval > m_Interval
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
CResidue_pntrs_Base(const CResidue_pntrs_Base &)
E_Choice
Choice variants.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
CResidue_explicit_pntrs TExplicit
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
NCBI_NS_NCBI::CUnionBuffer< TInterval > m_Interval
bool IsExplicit(void) const
Check if variant Explicit is selected.
@ e_not_set
No variant selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Jun 14 16:49:41 2024 by modify_doxy.py rev. 669887