NCBI C++ ToolKit
Person_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 Person_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/general/general.asn">general.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/general/general.def">general.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_GENERAL_PERSON_ID_BASE_HPP
42 #define OBJECTS_GENERAL_PERSON_ID_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 class CName_std;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_General
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 /// Person-id is to define a std element for people
74 ///
75 ///
76 /// CPerson_id_Base --
77 ///
78 
80 {
82 public:
83  // constructor
84  CPerson_id_Base(void);
85  // destructor
86  virtual ~CPerson_id_Base(void);
87 
88  // type info
90 
91 
92  /// Choice variants.
93  enum E_Choice {
94  e_not_set = 0, ///< No variant selected
95  e_Dbtag, ///< any defined database tag
96  e_Name, ///< structured name
97  e_Ml, ///< MEDLINE name (semi-structured) eg. "Jones RM"
98  e_Str, ///< unstructured name
99  e_Consortium ///< consortium name
100  };
101  /// Maximum+1 value of the choice variant enumerator.
103  e_MaxChoice = 6 ///< == e_Consortium+1
104  };
105 
106  /// Reset the whole object
107  virtual void Reset(void);
108 
109  /// Reset the selection (set it to e_not_set).
110  virtual void ResetSelection(void);
111 
112  /// Which variant is currently selected.
113  ///
114  /// @return
115  /// Choice state enumerator.
116  E_Choice Which(void) const;
117 
118  /// Verify selection, throw exception if it differs from the expected.
119  ///
120  /// @param index
121  /// Expected selection.
122  void CheckSelected(E_Choice index) const;
123 
124  /// Throw 'InvalidSelection' exception.
125  ///
126  /// @param index
127  /// Expected selection.
128  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
129 
130  /// Retrieve selection name (for diagnostic purposes).
131  ///
132  /// @param index
133  /// One of possible selection states.
134  /// @return
135  /// Name string.
136  static string SelectionName(E_Choice index);
137 
138  /// Select the requested variant if needed.
139  ///
140  /// @param index
141  /// New selection state.
142  /// @param reset
143  /// Flag that defines the resetting of the variant data. The data will
144  /// be reset if either the current selection differs from the new one,
145  /// or the flag is set to eDoResetVariant.
147  /// Select the requested variant if needed,
148  /// allocating CObject variants from memory pool.
149  void Select(E_Choice index,
150  EResetVariant reset,
151  CObjectMemoryPool* pool);
152 
153  // types
154  typedef CDbtag TDbtag;
155  typedef CName_std TName;
156  typedef string TMl;
157  typedef string TStr;
158  typedef string TConsortium;
159 
160  // getters
161  // setters
162 
163 
164  /// Check if variant Dbtag is selected.
165  ///
166  /// Dbtag type is defined as 'typedef CDbtag TDbtag'.
167  /// @return
168  /// - true, if the variant is selected.
169  /// - false, otherwise.
170  bool IsDbtag(void) const;
171 
172  /// Get the variant data.
173  ///
174  /// @return
175  /// Reference to the data.
176  const TDbtag& GetDbtag(void) const;
177 
178  /// Select the variant.
179  ///
180  /// @return
181  /// Reference to the variant data.
182  TDbtag& SetDbtag(void);
183  /// Select the variant and set its data.
184  ///
185  /// @param value
186  /// Reference to the data.
187  void SetDbtag(TDbtag& value);
188 
189 
190  /// Check if variant Name is selected.
191  ///
192  /// Name type is defined as 'typedef CName_std TName'.
193  /// @return
194  /// - true, if the variant is selected.
195  /// - false, otherwise.
196  bool IsName(void) const;
197 
198  /// Get the variant data.
199  ///
200  /// @return
201  /// Reference to the data.
202  const TName& GetName(void) const;
203 
204  /// Select the variant.
205  ///
206  /// @return
207  /// Reference to the variant data.
208  TName& SetName(void);
209  /// Select the variant and set its data.
210  ///
211  /// @param value
212  /// Reference to the data.
213  void SetName(TName& value);
214 
215 
216  /// Check if variant Ml is selected.
217  ///
218  /// Ml type is defined as 'typedef string TMl'.
219  /// @return
220  /// - true, if the variant is selected.
221  /// - false, otherwise.
222  bool IsMl(void) const;
223 
224  /// Get the variant data.
225  ///
226  /// @return
227  /// Reference to the data.
228  const TMl& GetMl(void) const;
229 
230  /// Select the variant.
231  ///
232  /// @return
233  /// Reference to the variant data.
234  TMl& SetMl(void);
235 
236  /// Select the variant and set its data.
237  ///
238  /// @param value
239  /// Variant data.
240  void SetMl(const TMl& value);
241 
242 
243  /// Check if variant Str is selected.
244  ///
245  /// Str type is defined as 'typedef string TStr'.
246  /// @return
247  /// - true, if the variant is selected.
248  /// - false, otherwise.
249  bool IsStr(void) const;
250 
251  /// Get the variant data.
252  ///
253  /// @return
254  /// Reference to the data.
255  const TStr& GetStr(void) const;
256 
257  /// Select the variant.
258  ///
259  /// @return
260  /// Reference to the variant data.
261  TStr& SetStr(void);
262 
263  /// Select the variant and set its data.
264  ///
265  /// @param value
266  /// Variant data.
267  void SetStr(const TStr& value);
268 
269 
270  /// Check if variant Consortium is selected.
271  ///
272  /// Consortium type is defined as 'typedef string TConsortium'.
273  /// @return
274  /// - true, if the variant is selected.
275  /// - false, otherwise.
276  bool IsConsortium(void) const;
277 
278  /// Get the variant data.
279  ///
280  /// @return
281  /// Reference to the data.
282  const TConsortium& GetConsortium(void) const;
283 
284  /// Select the variant.
285  ///
286  /// @return
287  /// Reference to the variant data.
288  TConsortium& SetConsortium(void);
289 
290  /// Select the variant and set its data.
291  ///
292  /// @param value
293  /// Variant data.
294  void SetConsortium(const TConsortium& value);
295 
296 
297 private:
298  // copy constructor and assignment operator
301  // choice state
303  // helper methods
304  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
305 
306  static const char* const sm_SelectionNames[];
307  // data
308  union {
309  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
310  NCBI_NS_NCBI::CSerialObject *m_object;
311  };
312 };
313 
314 /* @} */
315 
316 
317 
318 
319 
320 ///////////////////////////////////////////////////////////
321 ///////////////////// inline methods //////////////////////
322 ///////////////////////////////////////////////////////////
323 inline
325 {
326  return m_choice;
327 }
328 
329 inline
331 {
332  if ( m_choice != index )
333  ThrowInvalidSelection(index);
334 }
335 
336 inline
337 void CPerson_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
338 {
339  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
340  if ( m_choice != e_not_set )
341  ResetSelection();
342  DoSelect(index, pool);
343  }
344 }
345 
346 inline
347 void CPerson_id_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset)
348 {
349  Select(index, reset, 0);
350 }
351 
352 inline
353 bool CPerson_id_Base::IsDbtag(void) const
354 {
355  return m_choice == e_Dbtag;
356 }
357 
358 inline
359 bool CPerson_id_Base::IsName(void) const
360 {
361  return m_choice == e_Name;
362 }
363 
364 inline
365 bool CPerson_id_Base::IsMl(void) const
366 {
367  return m_choice == e_Ml;
368 }
369 
370 inline
372 {
374  return *m_string;
375 }
376 
377 inline
379 {
381  return *m_string;
382 }
383 
384 inline
385 bool CPerson_id_Base::IsStr(void) const
386 {
387  return m_choice == e_Str;
388 }
389 
390 inline
392 {
394  return *m_string;
395 }
396 
397 inline
399 {
401  return *m_string;
402 }
403 
404 inline
406 {
407  return m_choice == e_Consortium;
408 }
409 
410 inline
412 {
414  return *m_string;
415 }
416 
417 inline
419 {
421  return *m_string;
422 }
423 
424 ///////////////////////////////////////////////////////////
425 ////////////////// end of inline methods //////////////////
426 ///////////////////////////////////////////////////////////
427 
428 
429 
430 
431 
432 END_objects_SCOPE // namespace ncbi::objects::
433 
435 
436 
437 #endif // OBJECTS_GENERAL_PERSON_ID_BASE_HPP
Definition: Dbtag.hpp:53
@Name_std.hpp User-defined methods of the data storage class.
Definition: Name_std.hpp:56
Person-id is to define a std element for people.
Definition: Person_id_.hpp:80
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_GENERAL_EXPORT
Definition: ncbi_export.h:512
TMl & SetMl(void)
Select the variant.
Definition: Person_id_.hpp:378
E_Choice Which(void) const
Which variant is currently selected.
Definition: Person_id_.hpp:324
const TStr & GetStr(void) const
Get the variant data.
Definition: Person_id_.hpp:391
bool IsConsortium(void) const
Check if variant Consortium is selected.
Definition: Person_id_.hpp:405
CPerson_id_Base & operator=(const CPerson_id_Base &)
bool IsMl(void) const
Check if variant Ml is selected.
Definition: Person_id_.hpp:365
CSerialObject Tparent
Definition: Person_id_.hpp:81
E_Choice
Choice variants.
Definition: Person_id_.hpp:93
E_Choice m_choice
Definition: Person_id_.hpp:302
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
Definition: Person_id_.cpp:110
bool IsName(void) const
Check if variant Name is selected.
Definition: Person_id_.hpp:359
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
Definition: Person_id_.cpp:58
NCBI_NS_NCBI::CSerialObject * m_object
Definition: Person_id_.hpp:310
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
const TMl & GetMl(void) const
Get the variant data.
Definition: Person_id_.hpp:371
TConsortium & SetConsortium(void)
Select the variant.
Definition: Person_id_.hpp:418
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Person_id_.hpp:309
CPerson_id_Base(const CPerson_id_Base &)
const TConsortium & GetConsortium(void) const
Get the variant data.
Definition: Person_id_.hpp:411
bool IsStr(void) const
Check if variant Str is selected.
Definition: Person_id_.hpp:385
CName_std TName
Definition: Person_id_.hpp:155
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Person_id_.hpp:102
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Person_id_.hpp:330
bool IsDbtag(void) const
Check if variant Dbtag is selected.
Definition: Person_id_.hpp:353
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
Definition: Person_id_.cpp:76
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Person_id_.hpp:309
TStr & SetStr(void)
Select the variant.
Definition: Person_id_.hpp:398
@ e_Dbtag
any defined database tag
Definition: Person_id_.hpp:95
@ e_Ml
MEDLINE name (semi-structured) eg. "Jones RM".
Definition: Person_id_.hpp:97
@ e_Consortium
consortium name
Definition: Person_id_.hpp:99
@ e_Name
structured name
Definition: Person_id_.hpp:96
@ e_Str
unstructured name
Definition: Person_id_.hpp:98
@ e_not_set
No variant selected.
Definition: Person_id_.hpp:94
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sun Jul 21 04:19:22 2024 by modify_doxy.py rev. 669887