NCBI C++ ToolKit
GC_GenomicPart_.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 GC_GenomicPart_.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/genomecoll/genome_collection.asn">genome_collection.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/genomecoll/genome_collection.def">genome_collection.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_GENOMECOLL_GC_GENOMICPART_BASE_HPP
42 #define OBJECTS_GENOMECOLL_GC_GENOMICPART_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
56 class CGC_Assembly;
57 class CGC_Replicon;
58 class CGC_Sequence;
59 
60 
61 // generated classes
62 
63 
64 /** @addtogroup dataspec_NCBI_GenomeCollection
65  *
66  * @{
67  */
68 
69 /////////////////////////////////////////////////////////////////////////////
70 ///
71 /// CGC_GenomicPart_Base --
72 ///
73 
75 {
77 public:
78  // constructor
80  // destructor
81  virtual ~CGC_GenomicPart_Base(void);
82 
83  // type info
85 
86 
87  /// Choice variants.
88  enum E_Choice {
89  e_not_set = 0, ///< No variant selected
92  e_Seqs
93  };
94  /// Maximum+1 value of the choice variant enumerator.
96  e_MaxChoice = 4 ///< == e_Seqs+1
97  };
98 
99  /// Reset the whole object
100  virtual void Reset(void);
101 
102  /// Reset the selection (set it to e_not_set).
103  virtual void ResetSelection(void);
104 
105  /// Which variant is currently selected.
106  ///
107  /// @return
108  /// Choice state enumerator.
109  E_Choice Which(void) const;
110 
111  /// Verify selection, throw exception if it differs from the expected.
112  ///
113  /// @param index
114  /// Expected selection.
115  void CheckSelected(E_Choice index) const;
116 
117  /// Throw 'InvalidSelection' exception.
118  ///
119  /// @param index
120  /// Expected selection.
121  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
122 
123  /// Retrieve selection name (for diagnostic purposes).
124  ///
125  /// @param index
126  /// One of possible selection states.
127  /// @return
128  /// Name string.
129  static string SelectionName(E_Choice index);
130 
131  /// Select the requested variant if needed.
132  ///
133  /// @param index
134  /// New selection state.
135  /// @param reset
136  /// Flag that defines the resetting of the variant data. The data will
137  /// be reset if either the current selection differs from the new one,
138  /// or the flag is set to eDoResetVariant.
140  /// Select the requested variant if needed,
141  /// allocating CObject variants from memory pool.
142  void Select(E_Choice index,
143  EResetVariant reset,
144  CObjectMemoryPool* pool);
145 
146  // types
150 
151  // getters
152  // setters
153 
154 
155  /// Check if variant Assembly is selected.
156  ///
157  /// Assembly type is defined as 'typedef CGC_Assembly TAssembly'.
158  /// @return
159  /// - true, if the variant is selected.
160  /// - false, otherwise.
161  bool IsAssembly(void) const;
162 
163  /// Get the variant data.
164  ///
165  /// @return
166  /// Reference to the data.
167  const TAssembly& GetAssembly(void) const;
168 
169  /// Select the variant.
170  ///
171  /// @return
172  /// Reference to the variant data.
173  TAssembly& SetAssembly(void);
174  /// Select the variant and set its data.
175  ///
176  /// @param value
177  /// Reference to the data.
178  void SetAssembly(TAssembly& value);
179 
180 
181  /// Check if variant Mol is selected.
182  ///
183  /// Mol type is defined as 'typedef CGC_Replicon TMol'.
184  /// @return
185  /// - true, if the variant is selected.
186  /// - false, otherwise.
187  bool IsMol(void) const;
188 
189  /// Get the variant data.
190  ///
191  /// @return
192  /// Reference to the data.
193  const TMol& GetMol(void) const;
194 
195  /// Select the variant.
196  ///
197  /// @return
198  /// Reference to the variant data.
199  TMol& SetMol(void);
200  /// Select the variant and set its data.
201  ///
202  /// @param value
203  /// Reference to the data.
204  void SetMol(TMol& value);
205 
206 
207  /// Check if variant Seqs is selected.
208  ///
209  /// Seqs type is defined as 'typedef CGC_Sequence TSeqs'.
210  /// @return
211  /// - true, if the variant is selected.
212  /// - false, otherwise.
213  bool IsSeqs(void) const;
214 
215  /// Get the variant data.
216  ///
217  /// @return
218  /// Reference to the data.
219  const TSeqs& GetSeqs(void) const;
220 
221  /// Select the variant.
222  ///
223  /// @return
224  /// Reference to the variant data.
225  TSeqs& SetSeqs(void);
226  /// Select the variant and set its data.
227  ///
228  /// @param value
229  /// Reference to the data.
230  void SetSeqs(TSeqs& value);
231 
232 
233 private:
234  // copy constructor and assignment operator
237  // choice state
239  // helper methods
240  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
241 
242  static const char* const sm_SelectionNames[];
243  // data
244  NCBI_NS_NCBI::CSerialObject *m_object;
245 };
246 
247 /* @} */
248 
249 
250 
251 
252 
253 ///////////////////////////////////////////////////////////
254 ///////////////////// inline methods //////////////////////
255 ///////////////////////////////////////////////////////////
256 inline
258 {
259  return m_choice;
260 }
261 
262 inline
264 {
265  if ( m_choice != index )
266  ThrowInvalidSelection(index);
267 }
268 
269 inline
270 void CGC_GenomicPart_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
271 {
272  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
273  if ( m_choice != e_not_set )
274  ResetSelection();
275  DoSelect(index, pool);
276  }
277 }
278 
279 inline
281 {
282  Select(index, reset, 0);
283 }
284 
285 inline
287 {
288  return m_choice == e_Assembly;
289 }
290 
291 inline
293 {
294  return m_choice == e_Mol;
295 }
296 
297 inline
299 {
300  return m_choice == e_Seqs;
301 }
302 
303 ///////////////////////////////////////////////////////////
304 ////////////////// end of inline methods //////////////////
305 ///////////////////////////////////////////////////////////
306 
307 
308 
309 
310 
311 END_objects_SCOPE // namespace ncbi::objects::
312 
314 
315 
316 #endif // OBJECTS_GENOMECOLL_GC_GENOMICPART_BASE_HPP
CGC_GenomicPart_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
#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_GENOME_COLLECTION_EXPORT
Definition: ncbi_export.h:528
bool IsAssembly(void) const
Check if variant Assembly is selected.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
CGC_GenomicPart_Base(const CGC_GenomicPart_Base &)
CGC_GenomicPart_Base & operator=(const CGC_GenomicPart_Base &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsMol(void) const
Check if variant Mol is selected.
bool IsSeqs(void) const
Check if variant Seqs is selected.
E_Choice Which(void) const
Which variant is currently selected.
E_Choice
Choice variants.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
NCBI_NS_NCBI::CSerialObject * m_object
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
@ e_not_set
No variant selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Jun 19 17:05:56 2024 by modify_doxy.py rev. 669887