NCBI C++ ToolKit
Id_pat_.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 Id_pat_.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/biblio/biblio.asn">biblio.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/biblio/biblio.def">biblio.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_BIBLIO_ID_PAT_BASE_HPP
42 #define OBJECTS_BIBLIO_ID_PAT_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 // generated classes
60 
61 
62 /** @addtogroup dataspec_NCBI_Biblio
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 /// just to identify a patent
69 ///
70 /// CId_pat_Base --
71 ///
72 
74 {
76 public:
77  // constructor
78  CId_pat_Base(void);
79  // destructor
80  virtual ~CId_pat_Base(void);
81 
82  // type info
84 
85  /////////////////////////////////////////////////////////////////////////////
86  ///
87  /// C_Id --
88  ///
89 
91  {
93  public:
94  // constructor
95  C_Id(void);
96  // destructor
97  ~C_Id(void);
98 
99  // type info
101 
102 
103  /// Choice variants.
104  enum E_Choice {
105  e_not_set = 0, ///< No variant selected
106  e_Number, ///< Patent Document Number
107  e_App_number ///< Patent Doc Appl Number
108  };
109  /// Maximum+1 value of the choice variant enumerator.
111  e_MaxChoice = 3 ///< == e_App_number+1
112  };
113 
114  /// Reset the whole object
115  void Reset(void);
116 
117  /// Reset the selection (set it to e_not_set).
118  void ResetSelection(void);
119 
120  /// Which variant is currently selected.
121  ///
122  /// @return
123  /// Choice state enumerator.
124  E_Choice Which(void) const;
125 
126  /// Verify selection, throw exception if it differs from the expected.
127  ///
128  /// @param index
129  /// Expected selection.
130  void CheckSelected(E_Choice index) const;
131 
132  /// Throw 'InvalidSelection' exception.
133  ///
134  /// @param index
135  /// Expected selection.
136  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
137 
138  /// Retrieve selection name (for diagnostic purposes).
139  ///
140  /// @param index
141  /// One of possible selection states.
142  /// @return
143  /// Name string.
144  static string SelectionName(E_Choice index);
145 
146  /// Select the requested variant if needed.
147  ///
148  /// @param index
149  /// New selection state.
150  /// @param reset
151  /// Flag that defines the resetting of the variant data. The data will
152  /// be reset if either the current selection differs from the new one,
153  /// or the flag is set to eDoResetVariant.
155  /// Select the requested variant if needed,
156  /// allocating CObject variants from memory pool.
157  void Select(E_Choice index,
158  EResetVariant reset,
159  CObjectMemoryPool* pool);
160 
161  // types
162  typedef string TNumber;
163  typedef string TApp_number;
164 
165  // getters
166  // setters
167 
168 
169  /// Check if variant Number is selected.
170  ///
171  /// Number type is defined as 'typedef string TNumber'.
172  /// @return
173  /// - true, if the variant is selected.
174  /// - false, otherwise.
175  bool IsNumber(void) const;
176 
177  /// Get the variant data.
178  ///
179  /// @return
180  /// Reference to the data.
181  const TNumber& GetNumber(void) const;
182 
183  /// Select the variant.
184  ///
185  /// @return
186  /// Reference to the variant data.
187  TNumber& SetNumber(void);
188 
189  /// Select the variant and set its data.
190  ///
191  /// @param value
192  /// Variant data.
193  void SetNumber(const TNumber& value);
194 
195 
196  /// Check if variant App_number is selected.
197  ///
198  /// App_number type is defined as 'typedef string TApp_number'.
199  /// @return
200  /// - true, if the variant is selected.
201  /// - false, otherwise.
202  bool IsApp_number(void) const;
203 
204  /// Get the variant data.
205  ///
206  /// @return
207  /// Reference to the data.
208  const TApp_number& GetApp_number(void) const;
209 
210  /// Select the variant.
211  ///
212  /// @return
213  /// Reference to the variant data.
214  TApp_number& SetApp_number(void);
215 
216  /// Select the variant and set its data.
217  ///
218  /// @param value
219  /// Variant data.
220  void SetApp_number(const TApp_number& value);
221 
222 
223  private:
224  // copy constructor and assignment operator
225  C_Id(const C_Id& );
226  C_Id& operator=(const C_Id& );
227  // choice state
229  // helper methods
230  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
231 
232  static const char* const sm_SelectionNames[];
233  // data
234  union {
235  NCBI_NS_NCBI::CUnionBuffer<NCBI_NS_STD::string> m_string;
237  };
238  };
239  // types
240  typedef string TCountry;
241  typedef C_Id TId;
242  typedef string TDoc_type;
243 
244  // member index
245  enum class E_memberIndex {
246  e__allMandatory = 0,
247  e_country,
248  e_id,
249  e_doc_type
250  };
252 
253  // getters
254  // setters
255 
256  /// Patent Document Country
257  /// Check if a value has been assigned to Country data member.
258  ///
259  /// Data member Country is mandatory;
260  /// its type is defined as 'typedef string TCountry'
261  /// @return
262  /// - true, if a value has been assigned.
263  /// - false, otherwise.
264  bool IsSetCountry(void) const;
265 
266  /// Check if it is safe to call GetCountry method.
267  ///
268  /// @return
269  /// - true, if the data member is getatable.
270  /// - false, otherwise.
271  bool CanGetCountry(void) const;
272 
273  /// Reset Country data member.
274  void ResetCountry(void);
275 
276  /// Get the Country member data.
277  ///
278  /// @return
279  /// Reference to the member data.
280  const TCountry& GetCountry(void) const;
281 
282  /// Assign a value to Country data member.
283  ///
284  /// @param value
285  /// Value to assign
286  void SetCountry(const TCountry& value);
287  void SetCountry(TCountry&& value);
288 
289  /// Assign a value to Country data member.
290  ///
291  /// @return
292  /// Reference to the data value.
293  TCountry& SetCountry(void);
294 
295  /// Check if a value has been assigned to Id data member.
296  ///
297  /// Data member Id is mandatory;
298  /// its type is defined as 'typedef C_Id TId'
299  /// @return
300  /// - true, if a value has been assigned.
301  /// - false, otherwise.
302  bool IsSetId(void) const;
303 
304  /// Check if it is safe to call GetId method.
305  ///
306  /// @return
307  /// - true, if the data member is getatable.
308  /// - false, otherwise.
309  bool CanGetId(void) const;
310 
311  /// Reset Id data member.
312  void ResetId(void);
313 
314  /// Get the Id member data.
315  ///
316  /// @return
317  /// Reference to the member data.
318  const TId& GetId(void) const;
319 
320  /// Assign a value to Id data member.
321  ///
322  /// @param value
323  /// Reference to value.
324  void SetId(TId& value);
325 
326  /// Assign a value to Id data member.
327  ///
328  /// @return
329  /// Reference to the data value.
330  TId& SetId(void);
331 
332  /// Patent Doc Type
333  /// Check if a value has been assigned to Doc_type data member.
334  ///
335  /// Data member Doc_type is optional;
336  /// its type is defined as 'typedef string TDoc_type'
337  /// @return
338  /// - true, if a value has been assigned.
339  /// - false, otherwise.
340  bool IsSetDoc_type(void) const;
341 
342  /// Check if it is safe to call GetDoc_type method.
343  ///
344  /// @return
345  /// - true, if the data member is getatable.
346  /// - false, otherwise.
347  bool CanGetDoc_type(void) const;
348 
349  /// Reset Doc_type data member.
350  void ResetDoc_type(void);
351 
352  /// Get the Doc_type member data.
353  ///
354  /// @return
355  /// Reference to the member data.
356  const TDoc_type& GetDoc_type(void) const;
357 
358  /// Assign a value to Doc_type data member.
359  ///
360  /// @param value
361  /// Value to assign
362  void SetDoc_type(const TDoc_type& value);
363  void SetDoc_type(TDoc_type&& value);
364 
365  /// Assign a value to Doc_type data member.
366  ///
367  /// @return
368  /// Reference to the data value.
369  TDoc_type& SetDoc_type(void);
370 
371  /// Reset the whole object
372  virtual void Reset(void);
373 
374 
375 private:
376  // Prohibit copy constructor and assignment operator
379 
380  // data
381  Uint4 m_set_State[1];
382  string m_Country;
384  string m_Doc_type;
385 };
386 
387 /* @} */
388 
389 
390 
391 
392 
393 ///////////////////////////////////////////////////////////
394 ///////////////////// inline methods //////////////////////
395 ///////////////////////////////////////////////////////////
396 inline
398 {
399  return m_choice;
400 }
401 
402 inline
404 {
405  if ( m_choice != index )
406  ThrowInvalidSelection(index);
407 }
408 
409 inline
410 void CId_pat_Base::C_Id::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
411 {
412  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
413  if ( m_choice != e_not_set )
414  ResetSelection();
415  DoSelect(index, pool);
416  }
417 }
418 
419 inline
421 {
422  Select(index, reset, 0);
423 }
424 
425 inline
427 {
428  return m_choice == e_Number;
429 }
430 
431 inline
433 {
434  CheckSelected(e_Number);
435  return *m_string;
436 }
437 
438 inline
440 {
441  Select(e_Number, NCBI_NS_NCBI::eDoNotResetVariant);
442  return *m_string;
443 }
444 
445 inline
447 {
448  return m_choice == e_App_number;
449 }
450 
451 inline
453 {
454  CheckSelected(e_App_number);
455  return *m_string;
456 }
457 
458 inline
460 {
461  Select(e_App_number, NCBI_NS_NCBI::eDoNotResetVariant);
462  return *m_string;
463 }
464 
465 inline
467 {
468  return ((m_set_State[0] & 0x3) != 0);
469 }
470 
471 inline
473 {
474  return IsSetCountry();
475 }
476 
477 inline
479 {
480  if (!CanGetCountry()) {
481  ThrowUnassigned(0);
482  }
483  return m_Country;
484 }
485 
486 inline
488 {
489  m_Country = value;
490  m_set_State[0] |= 0x3;
491 }
492 
493 inline
495 {
496  m_Country = std::forward<CId_pat_Base::TCountry>(value);
497  m_set_State[0] |= 0x3;
498 }
499 
500 inline
502 {
503 #ifdef _DEBUG
504  if (!IsSetCountry()) {
506  }
507 #endif
508  m_set_State[0] |= 0x1;
509  return m_Country;
510 }
511 
512 inline
513 bool CId_pat_Base::IsSetId(void) const
514 {
515  return m_Id.NotEmpty();
516 }
517 
518 inline
519 bool CId_pat_Base::CanGetId(void) const
520 {
521  return true;
522 }
523 
524 inline
526 {
527  if ( !m_Id ) {
528  const_cast<CId_pat_Base*>(this)->ResetId();
529  }
530  return (*m_Id);
531 }
532 
533 inline
535 {
536  if ( !m_Id ) {
537  ResetId();
538  }
539  return (*m_Id);
540 }
541 
542 inline
544 {
545  return ((m_set_State[0] & 0x30) != 0);
546 }
547 
548 inline
550 {
551  return IsSetDoc_type();
552 }
553 
554 inline
556 {
557  if (!CanGetDoc_type()) {
558  ThrowUnassigned(2);
559  }
560  return m_Doc_type;
561 }
562 
563 inline
565 {
566  m_Doc_type = value;
567  m_set_State[0] |= 0x30;
568 }
569 
570 inline
572 {
573  m_Doc_type = std::forward<CId_pat_Base::TDoc_type>(value);
574  m_set_State[0] |= 0x30;
575 }
576 
577 inline
579 {
580 #ifdef _DEBUG
581  if (!IsSetDoc_type()) {
583  }
584 #endif
585  m_set_State[0] |= 0x10;
586  return m_Doc_type;
587 }
588 
589 ///////////////////////////////////////////////////////////
590 ////////////////// end of inline methods //////////////////
591 ///////////////////////////////////////////////////////////
592 
593 
594 
595 
596 
597 END_objects_SCOPE // namespace ncbi::objects::
598 
600 
601 
602 #endif // OBJECTS_BIBLIO_ID_PAT_BASE_HPP
just to identify a patent
Definition: Id_pat_.hpp:74
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
static string UnassignedString(void)
Definition: serialbase.hpp:175
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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_BIBLIO_EXPORT
Definition: ncbi_export.h:312
void ResetId(void)
Reset Id data member.
Definition: Id_pat_.cpp:143
E_Choice m_choice
Definition: Id_pat_.hpp:228
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
Definition: Id_pat_.hpp:251
CRef< TId > m_Id
Definition: Id_pat_.hpp:383
bool IsApp_number(void) const
Check if variant App_number is selected.
Definition: Id_pat_.hpp:446
bool IsNumber(void) const
Check if variant Number is selected.
Definition: Id_pat_.hpp:426
bool IsSetCountry(void) const
Patent Document Country Check if a value has been assigned to Country data member.
Definition: Id_pat_.hpp:466
TApp_number & SetApp_number(void)
Select the variant.
Definition: Id_pat_.hpp:459
string m_Doc_type
Definition: Id_pat_.hpp:384
E_Choice Which(void) const
Which variant is currently selected.
Definition: Id_pat_.hpp:397
string TCountry
Definition: Id_pat_.hpp:240
DECLARE_INTERNAL_TYPE_INFO()
TNumber & SetNumber(void)
Select the variant.
Definition: Id_pat_.hpp:439
E_Choice
Choice variants.
Definition: Id_pat_.hpp:104
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
Definition: Id_pat_.hpp:513
bool IsSetDoc_type(void) const
Patent Doc Type Check if a value has been assigned to Doc_type data member.
Definition: Id_pat_.hpp:543
const TDoc_type & GetDoc_type(void) const
Get the Doc_type member data.
Definition: Id_pat_.hpp:555
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
Definition: Id_pat_.hpp:110
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool CanGetId(void) const
Check if it is safe to call GetId method.
Definition: Id_pat_.hpp:519
bool CanGetCountry(void) const
Check if it is safe to call GetCountry method.
Definition: Id_pat_.hpp:472
bool CanGetDoc_type(void) const
Check if it is safe to call GetDoc_type method.
Definition: Id_pat_.hpp:549
const TId & GetId(void) const
Get the Id member data.
Definition: Id_pat_.hpp:525
CSerialObject Tparent
Definition: Id_pat_.hpp:92
CId_pat_Base & operator=(const CId_pat_Base &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TCountry & SetCountry(void)
Assign a value to Country data member.
Definition: Id_pat_.hpp:501
C_Id(const C_Id &)
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Definition: Id_pat_.hpp:403
TId & SetId(void)
Assign a value to Id data member.
Definition: Id_pat_.hpp:534
string TDoc_type
Definition: Id_pat_.hpp:242
const TNumber & GetNumber(void) const
Get the variant data.
Definition: Id_pat_.hpp:432
const TApp_number & GetApp_number(void) const
Get the variant data.
Definition: Id_pat_.hpp:452
C_Id & operator=(const C_Id &)
CSerialObject Tparent
Definition: Id_pat_.hpp:75
string m_Country
Definition: Id_pat_.hpp:382
Uint4 m_set_State[1]
Definition: Id_pat_.hpp:381
CId_pat_Base(const CId_pat_Base &)
const TCountry & GetCountry(void) const
Get the Country member data.
Definition: Id_pat_.hpp:478
NCBI_NS_NCBI::CUnionBuffer< NCBI_NS_STD::string > m_string
Definition: Id_pat_.hpp:235
void * m_dummy_pointer_for_alignment
Definition: Id_pat_.hpp:236
TDoc_type & SetDoc_type(void)
Assign a value to Doc_type data member.
Definition: Id_pat_.hpp:578
@ e_Number
Patent Document Number.
Definition: Id_pat_.hpp:106
@ e_not_set
Modified on Fri Dec 01 04:44:34 2023 by modify_doxy.py rev. 669887