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