NCBI C++ ToolKit
Seq_entry_.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 Seq_entry_.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/seqset/seqset.asn">seqset.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqset/seqset.def">seqset.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_SEQSET_SEQ_ENTRY_BASE_HPP
42 #define OBJECTS_SEQSET_SEQ_ENTRY_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 CBioseq;
57 class CBioseq_set;
58 
59 
60 // generated classes
61 
62 
63 /** @addtogroup dataspec_NCBI_Seqset
64  *
65  * @{
66  */
67 
68 /////////////////////////////////////////////////////////////////////////////
69 ///
70 /// CSeq_entry_Base --
71 ///
72 
74 {
76 public:
77  // constructor
78  CSeq_entry_Base(void);
79  // destructor
80  virtual ~CSeq_entry_Base(void);
81 
82  // type info
84 
85 
86  /// Choice variants.
87  enum E_Choice {
88  e_not_set = 0, ///< No variant selected
90  e_Set
91  };
92  /// Maximum+1 value of the choice variant enumerator.
94  e_MaxChoice = 3 ///< == e_Set+1
95  };
96 
97  /// Reset the whole object
98  virtual void Reset(void);
99 
100  /// Reset the selection (set it to e_not_set).
101  virtual void ResetSelection(void);
102 
103  /// Which variant is currently selected.
104  ///
105  /// @return
106  /// Choice state enumerator.
107  E_Choice Which(void) const;
108 
109  /// Verify selection, throw exception if it differs from the expected.
110  ///
111  /// @param index
112  /// Expected selection.
113  void CheckSelected(E_Choice index) const;
114 
115  /// Throw 'InvalidSelection' exception.
116  ///
117  /// @param index
118  /// Expected selection.
119  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
120 
121  /// Retrieve selection name (for diagnostic purposes).
122  ///
123  /// @param index
124  /// One of possible selection states.
125  /// @return
126  /// Name string.
127  static string SelectionName(E_Choice index);
128 
129  /// Select the requested variant if needed.
130  ///
131  /// @param index
132  /// New selection state.
133  /// @param reset
134  /// Flag that defines the resetting of the variant data. The data will
135  /// be reset if either the current selection differs from the new one,
136  /// or the flag is set to eDoResetVariant.
138  /// Select the requested variant if needed,
139  /// allocating CObject variants from memory pool.
140  void Select(E_Choice index,
141  EResetVariant reset,
142  CObjectMemoryPool* pool);
143 
144  // types
145  typedef CBioseq TSeq;
146  typedef CBioseq_set TSet;
147 
148  // getters
149  // setters
150 
151 
152  /// Check if variant Seq is selected.
153  ///
154  /// Seq type is defined as 'typedef CBioseq TSeq'.
155  /// @return
156  /// - true, if the variant is selected.
157  /// - false, otherwise.
158  bool IsSeq(void) const;
159 
160  /// Get the variant data.
161  ///
162  /// @return
163  /// Reference to the data.
164  const TSeq& GetSeq(void) const;
165 
166  /// Select the variant.
167  ///
168  /// @return
169  /// Reference to the variant data.
170  TSeq& SetSeq(void);
171  /// Select the variant and set its data.
172  ///
173  /// @param value
174  /// Reference to the data.
175  void SetSeq(TSeq& value);
176 
177 
178  /// Check if variant Set is selected.
179  ///
180  /// Set type is defined as 'typedef CBioseq_set TSet'.
181  /// @return
182  /// - true, if the variant is selected.
183  /// - false, otherwise.
184  bool IsSet(void) const;
185 
186  /// Get the variant data.
187  ///
188  /// @return
189  /// Reference to the data.
190  const TSet& GetSet(void) const;
191 
192  /// Select the variant.
193  ///
194  /// @return
195  /// Reference to the variant data.
196  TSet& SetSet(void);
197  /// Select the variant and set its data.
198  ///
199  /// @param value
200  /// Reference to the data.
201  void SetSet(TSet& value);
202 
203 
204 private:
205  // copy constructor and assignment operator
208  // choice state
210  // helper methods
211  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
212 
213  static const char* const sm_SelectionNames[];
214  // data
215  NCBI_NS_NCBI::CSerialObject *m_object;
216 };
217 
218 /* @} */
219 
220 
221 
222 
223 
224 ///////////////////////////////////////////////////////////
225 ///////////////////// inline methods //////////////////////
226 ///////////////////////////////////////////////////////////
227 inline
229 {
230  return m_choice;
231 }
232 
233 inline
235 {
236  if ( m_choice != index )
237  ThrowInvalidSelection(index);
238 }
239 
240 inline
241 void CSeq_entry_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
242 {
243  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
244  if ( m_choice != e_not_set )
245  ResetSelection();
246  DoSelect(index, pool);
247  }
248 }
249 
250 inline
251 void CSeq_entry_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
252 {
253  Select(index, reset, 0);
254 }
255 
256 inline
257 bool CSeq_entry_Base::IsSeq(void) const
258 {
259  return m_choice == e_Seq;
260 }
261 
262 inline
263 bool CSeq_entry_Base::IsSet(void) const
264 {
265  return m_choice == e_Set;
266 }
267 
268 ///////////////////////////////////////////////////////////
269 ////////////////// end of inline methods //////////////////
270 ///////////////////////////////////////////////////////////
271 
272 
273 
274 
275 
276 END_objects_SCOPE // namespace ncbi::objects::
277 
279 
280 
281 #endif // OBJECTS_SEQSET_SEQ_ENTRY_BASE_HPP
CSeq_entry_Base –.
Definition: Seq_entry_.hpp:74
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_SEQSET_EXPORT
Definition: ncbi_export.h:793
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Seq_entry_.hpp:93
E_Choice m_choice
Definition: Seq_entry_.hpp:209
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Seq_entry_.hpp:234
E_Choice
Choice variants.
Definition: Seq_entry_.hpp:87
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Seq_entry_.cpp:97
CSeq_entry_Base(const CSeq_entry_Base &)
bool IsSeq(void) const
Check if variant Seq is selected.
Definition: Seq_entry_.hpp:257
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Seq_entry_.cpp:71
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_entry_.hpp:228
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Seq_entry_.hpp:215
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Seq_entry_.cpp:58
CSerialObject Tparent
Definition: Seq_entry_.hpp:75
CSeq_entry_Base & operator=(const CSeq_entry_Base &)
CBioseq_set TSet
Definition: Seq_entry_.hpp:146
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
@ e_not_set
No variant selected.
Definition: Seq_entry_.hpp:88
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Wed Apr 17 13:10:39 2024 by modify_doxy.py rev. 669887