NCBI C++ ToolKit
Biostruc_id_.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 Biostruc_id_.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/mmdb1/mmdb1.asn">mmdb1.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/mmdb1/mmdb1.def">mmdb1.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_MMDB1_BIOSTRUC_ID_BASE_HPP
42 #define OBJECTS_MMDB1_BIOSTRUC_ID_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 // forward declarations
60 class CDbtag;
61 class CObject_id;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_MMDB
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 /// A Biostruc-id is a collection identifiers for the molecular assembly.
74 /// Mmdb-id's are NCBI-assigned, and are intended to be unique and stable
75 /// identifiers. Other-id's are synonyms.
76 ///
77 /// CBiostruc_id_Base --
78 ///
79 
81 {
83 public:
84  // constructor
85  CBiostruc_id_Base(void);
86  // destructor
87  virtual ~CBiostruc_id_Base(void);
88 
89  // type info
91 
92 
93  /// Choice variants.
94  enum E_Choice {
95  e_not_set = 0, ///< No variant selected
98  e_Local_id
99  };
100  /// Maximum+1 value of the choice variant enumerator.
102  e_MaxChoice = 4 ///< == e_Local_id+1
103  };
104 
105  /// Reset the whole object
106  virtual void Reset(void);
107 
108  /// Reset the selection (set it to e_not_set).
109  virtual void ResetSelection(void);
110 
111  /// Which variant is currently selected.
112  ///
113  /// @return
114  /// Choice state enumerator.
115  E_Choice Which(void) const;
116 
117  /// Verify selection, throw exception if it differs from the expected.
118  ///
119  /// @param index
120  /// Expected selection.
121  void CheckSelected(E_Choice index) const;
122 
123  /// Throw 'InvalidSelection' exception.
124  ///
125  /// @param index
126  /// Expected selection.
127  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
128 
129  /// Retrieve selection name (for diagnostic purposes).
130  ///
131  /// @param index
132  /// One of possible selection states.
133  /// @return
134  /// Name string.
135  static string SelectionName(E_Choice index);
136 
137  /// Select the requested variant if needed.
138  ///
139  /// @param index
140  /// New selection state.
141  /// @param reset
142  /// Flag that defines the resetting of the variant data. The data will
143  /// be reset if either the current selection differs from the new one,
144  /// or the flag is set to eDoResetVariant.
146  /// Select the requested variant if needed,
147  /// allocating CObject variants from memory pool.
148  void Select(E_Choice index,
149  EResetVariant reset,
150  CObjectMemoryPool* pool);
151 
152  // types
156 
157  // getters
158  // setters
159 
160 
161  /// Check if variant Mmdb_id is selected.
162  ///
163  /// Mmdb_id type is defined as 'typedef CMmdb_id TMmdb_id'.
164  /// @return
165  /// - true, if the variant is selected.
166  /// - false, otherwise.
167  bool IsMmdb_id(void) const;
168 
169  /// Get the variant data.
170  ///
171  /// @return
172  /// Reference to the data.
173  const TMmdb_id& GetMmdb_id(void) const;
174 
175  /// Select the variant.
176  ///
177  /// @return
178  /// Reference to the variant data.
179  TMmdb_id& SetMmdb_id(void);
180 
181  /// Select the variant and set its data.
182  ///
183  /// @param value
184  /// Variant data.
185  void SetMmdb_id(const TMmdb_id& value);
186 
187 
188  /// Check if variant Other_database is selected.
189  ///
190  /// Other_database type is defined as 'typedef CDbtag TOther_database'.
191  /// @return
192  /// - true, if the variant is selected.
193  /// - false, otherwise.
194  bool IsOther_database(void) const;
195 
196  /// Get the variant data.
197  ///
198  /// @return
199  /// Reference to the data.
200  const TOther_database& GetOther_database(void) const;
201 
202  /// Select the variant.
203  ///
204  /// @return
205  /// Reference to the variant data.
206  TOther_database& SetOther_database(void);
207  /// Select the variant and set its data.
208  ///
209  /// @param value
210  /// Reference to the data.
211  void SetOther_database(TOther_database& value);
212 
213 
214  /// Check if variant Local_id is selected.
215  ///
216  /// Local_id type is defined as 'typedef CObject_id TLocal_id'.
217  /// @return
218  /// - true, if the variant is selected.
219  /// - false, otherwise.
220  bool IsLocal_id(void) const;
221 
222  /// Get the variant data.
223  ///
224  /// @return
225  /// Reference to the data.
226  const TLocal_id& GetLocal_id(void) const;
227 
228  /// Select the variant.
229  ///
230  /// @return
231  /// Reference to the variant data.
232  TLocal_id& SetLocal_id(void);
233  /// Select the variant and set its data.
234  ///
235  /// @param value
236  /// Reference to the data.
237  void SetLocal_id(TLocal_id& value);
238 
239 
240 private:
241  // copy constructor and assignment operator
244  // choice state
246  // helper methods
247  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
248 
249  static const char* const sm_SelectionNames[];
250  // data
251  union {
252  NCBI_NS_NCBI::CUnionBuffer<TMmdb_id> m_Mmdb_id;
253  NCBI_NS_NCBI::CSerialObject *m_object;
254  };
255 };
256 
257 /* @} */
258 
259 
260 
261 
262 
263 ///////////////////////////////////////////////////////////
264 ///////////////////// inline methods //////////////////////
265 ///////////////////////////////////////////////////////////
266 inline
268 {
269  return m_choice;
270 }
271 
272 inline
274 {
275  if ( m_choice != index )
276  ThrowInvalidSelection(index);
277 }
278 
279 inline
280 void CBiostruc_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
281 {
282  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
283  if ( m_choice != e_not_set )
284  ResetSelection();
285  DoSelect(index, pool);
286  }
287 }
288 
289 inline
290 void CBiostruc_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
291 {
292  Select(index, reset, 0);
293 }
294 
295 inline
297 {
298  return m_choice == e_Mmdb_id;
299 }
300 
301 inline
303 {
305  return *m_Mmdb_id;
306 }
307 
308 inline
310 {
312  return *m_Mmdb_id;
313 }
314 
315 inline
317 {
318  return m_choice == e_Other_database;
319 }
320 
321 inline
323 {
324  return m_choice == e_Local_id;
325 }
326 
327 ///////////////////////////////////////////////////////////
328 ////////////////// end of inline methods //////////////////
329 ///////////////////////////////////////////////////////////
330 
331 
332 
333 
334 
335 END_objects_SCOPE // namespace ncbi::objects::
336 
338 
339 
340 #endif // OBJECTS_MMDB1_BIOSTRUC_ID_BASE_HPP
User-defined methods of the data storage class.
A Biostruc-id is a collection identifiers for the molecular assembly.
Definition: Dbtag.hpp:53
CMmdb_id –.
Definition: Mmdb_id.hpp:66
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_MMDB1_EXPORT
Definition: ncbi_export.h:624
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
CSerialObject Tparent
bool IsOther_database(void) const
Check if variant Other_database is selected.
NCBI_NS_NCBI::CUnionBuffer< TMmdb_id > m_Mmdb_id
NCBI_NS_NCBI::CSerialObject * m_object
TMmdb_id & SetMmdb_id(void)
Select the variant.
E_Choice Which(void) const
Which variant is currently selected.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
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.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
NCBI_NS_NCBI::CUnionBuffer< TMmdb_id > m_Mmdb_id
CObject_id TLocal_id
const TMmdb_id & GetMmdb_id(void) const
Get the variant data.
CBiostruc_id_Base & operator=(const CBiostruc_id_Base &)
CBiostruc_id_Base(const CBiostruc_id_Base &)
E_Choice
Choice variants.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
bool IsLocal_id(void) const
Check if variant Local_id is selected.
bool IsMmdb_id(void) const
Check if variant Mmdb_id is selected.
@ e_not_set
No variant selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed May 22 11:28:37 2024 by modify_doxy.py rev. 669887