NCBI C++ ToolKit
PC_CompoundType_.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 PC_CompoundType_.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/pcsubstance/pcsubstance.asn">pcsubstance.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/pcsubstance/pcsubstance.def">pcsubstance.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_PCSUBSTANCE_PC_COMPOUNDTYPE_BASE_HPP
42 #define OBJECTS_PCSUBSTANCE_PC_COMPOUNDTYPE_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 // generated classes
56 
57 
58 /** @addtogroup dataspec_NCBI_PCSubstance
59  *
60  * @{
61  */
62 
63 /////////////////////////////////////////////////////////////////////////////
64 /// Qualification used to describe the type of Compound deposited, standardized, or derived.
65 /// Please note that mixtures/cocktails may be specified using previously deposited substances.
66 ///
67 /// CPC_CompoundType_Base --
68 ///
69 
71 {
73 public:
74  // constructor
76  // destructor
77  virtual ~CPC_CompoundType_Base(void);
78 
79  // type info
81 
82  /// Compound Qualifier or Type
83  /// For Compound Depositions
84  enum EType {
85  eType_deposited = 0, ///< Original Deposited Compound For Standardized Compounds
86  eType_standardized = 1, ///< Standardized Form of a Deposited Compound
87  eType_component = 2, ///< Component of a Standardized Compound
88  eType_neutralized = 3, ///< Neutralized Form of a Standardized Compound For Mixture/Cocktail Depositions
89  eType_mixture = 4, ///< Substance that is a component of a mixture For Theoretical Compounds
90  eType_tautomer = 5, ///< Predicted Tautomer Form
91  eType_pka_state = 6, ///< Predicted Ionized pKa Form
92  eType_unknown = 255 ///< Unknown Compound Type
93  };
94 
95  /// Access to EType's attributes (values, names) as defined in spec
96  static const NCBI_NS_NCBI::CEnumeratedTypeValues* ENUM_METHOD_NAME(EType)(void);
97 
98  /////////////////////////////////////////////////////////////////////////////
99  /// Compound Namespace and ID (absent for "deposited" type compounds)
100  ///
101  /// C_Id --
102  ///
103 
105  {
107  public:
108  // constructor
109  C_Id(void);
110  // destructor
111  ~C_Id(void);
112 
113  // type info
115 
116 
117  /// Choice variants.
118  enum E_Choice {
119  e_not_set = 0, ///< No variant selected
120  e_Cid, ///< Standardized Compound
121  e_Sid, ///< PubChem Substance (for "mixture" type compounds)
122  e_Xid ///< PubChem Theoretical Compound
123  };
124  /// Maximum+1 value of the choice variant enumerator.
126  e_MaxChoice = 4 ///< == e_Xid+1
127  };
128 
129  /// Reset the whole object
130  void Reset(void);
131 
132  /// Reset the selection (set it to e_not_set).
133  void ResetSelection(void);
134 
135  /// Which variant is currently selected.
136  ///
137  /// @return
138  /// Choice state enumerator.
139  E_Choice Which(void) const;
140 
141  /// Verify selection, throw exception if it differs from the expected.
142  ///
143  /// @param index
144  /// Expected selection.
145  void CheckSelected(E_Choice index) const;
146 
147  /// Throw 'InvalidSelection' exception.
148  ///
149  /// @param index
150  /// Expected selection.
151  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
152 
153  /// Retrieve selection name (for diagnostic purposes).
154  ///
155  /// @param index
156  /// One of possible selection states.
157  /// @return
158  /// Name string.
159  static string SelectionName(E_Choice index);
160 
161  /// Select the requested variant if needed.
162  ///
163  /// @param index
164  /// New selection state.
165  /// @param reset
166  /// Flag that defines the resetting of the variant data. The data will
167  /// be reset if either the current selection differs from the new one,
168  /// or the flag is set to eDoResetVariant.
170  /// Select the requested variant if needed,
171  /// allocating CObject variants from memory pool.
172  void Select(E_Choice index,
173  EResetVariant reset,
174  CObjectMemoryPool* pool);
175 
176  // types
177  typedef int TCid;
178  typedef int TSid;
179  typedef int TXid;
180 
181  // getters
182  // setters
183 
184 
185  /// Check if variant Cid is selected.
186  ///
187  /// Cid type is defined as 'typedef int TCid'.
188  /// @return
189  /// - true, if the variant is selected.
190  /// - false, otherwise.
191  bool IsCid(void) const;
192 
193  /// Get the variant data.
194  ///
195  /// @return
196  /// Copy of the variant data.
197  TCid GetCid(void) const;
198 
199  /// Select the variant.
200  ///
201  /// @return
202  /// Reference to the variant data.
203  TCid& SetCid(void);
204 
205  /// Select the variant and set its data.
206  ///
207  /// @param value
208  /// Variant data.
209  void SetCid(TCid value);
210 
211 
212  /// Check if variant Sid is selected.
213  ///
214  /// Sid type is defined as 'typedef int TSid'.
215  /// @return
216  /// - true, if the variant is selected.
217  /// - false, otherwise.
218  bool IsSid(void) const;
219 
220  /// Get the variant data.
221  ///
222  /// @return
223  /// Copy of the variant data.
224  TSid GetSid(void) const;
225 
226  /// Select the variant.
227  ///
228  /// @return
229  /// Reference to the variant data.
230  TSid& SetSid(void);
231 
232  /// Select the variant and set its data.
233  ///
234  /// @param value
235  /// Variant data.
236  void SetSid(TSid value);
237 
238 
239  /// Check if variant Xid is selected.
240  ///
241  /// Xid type is defined as 'typedef int TXid'.
242  /// @return
243  /// - true, if the variant is selected.
244  /// - false, otherwise.
245  bool IsXid(void) const;
246 
247  /// Get the variant data.
248  ///
249  /// @return
250  /// Copy of the variant data.
251  TXid GetXid(void) const;
252 
253  /// Select the variant.
254  ///
255  /// @return
256  /// Reference to the variant data.
257  TXid& SetXid(void);
258 
259  /// Select the variant and set its data.
260  ///
261  /// @param value
262  /// Variant data.
263  void SetXid(TXid value);
264 
265 
266  private:
267  // copy constructor and assignment operator
268  C_Id(const C_Id& );
269  C_Id& operator=(const C_Id& );
270  // choice state
272  // helper methods
273  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
274 
275  static const char* const sm_SelectionNames[];
276  // data
277  union {
281  };
282  };
283  // types
284  typedef int TType;
285  typedef C_Id TId;
286 
287  // member index
288  enum class E_memberIndex {
289  e__allMandatory = 0,
290  e_type,
291  e_id
292  };
294 
295  // getters
296  // setters
297 
298  /// Check if a value has been assigned to Type data member.
299  ///
300  /// Data member Type is optional;
301  /// its type is defined as 'typedef int TType'
302  /// @return
303  /// - true, if a value has been assigned.
304  /// - false, otherwise.
305  bool IsSetType(void) const;
306 
307  /// Check if it is safe to call GetType method.
308  ///
309  /// @return
310  /// - true, if the data member is getatable.
311  /// - false, otherwise.
312  bool CanGetType(void) const;
313 
314  /// Reset Type data member.
315  void ResetType(void);
316 
317  /// Get the Type member data.
318  ///
319  /// @return
320  /// Copy of the member data.
321  TType GetType(void) const;
322 
323  /// Assign a value to Type data member.
324  ///
325  /// @param value
326  /// Value to assign
327  void SetType(TType value);
328 
329  /// Assign a value to Type data member.
330  ///
331  /// @return
332  /// Reference to the data value.
333  TType& SetType(void);
334 
335  /// Check if a value has been assigned to Id data member.
336  ///
337  /// Data member Id is optional;
338  /// its type is defined as 'typedef C_Id TId'
339  /// @return
340  /// - true, if a value has been assigned.
341  /// - false, otherwise.
342  bool IsSetId(void) const;
343 
344  /// Check if it is safe to call GetId method.
345  ///
346  /// @return
347  /// - true, if the data member is getatable.
348  /// - false, otherwise.
349  bool CanGetId(void) const;
350 
351  /// Reset Id data member.
352  void ResetId(void);
353 
354  /// Get the Id member data.
355  ///
356  /// @return
357  /// Reference to the member data.
358  const TId& GetId(void) const;
359 
360  /// Assign a value to Id data member.
361  ///
362  /// @param value
363  /// Reference to value.
364  void SetId(TId& value);
365 
366  /// Assign a value to Id data member.
367  ///
368  /// @return
369  /// Reference to the data value.
370  TId& SetId(void);
371 
372  /// Reset the whole object
373  virtual void Reset(void);
374 
375 
376 private:
377  // Prohibit copy constructor and assignment operator
380 
381  // data
382  Uint4 m_set_State[1];
383  int m_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 CPC_CompoundType_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_Cid;
429 }
430 
431 inline
433 {
434  CheckSelected(e_Cid);
435  return m_Cid;
436 }
437 
438 inline
440 {
441  Select(e_Cid, NCBI_NS_NCBI::eDoNotResetVariant);
442  return m_Cid;
443 }
444 
445 inline
447 {
448  Select(e_Cid, NCBI_NS_NCBI::eDoNotResetVariant);
449  m_Cid = value;
450 }
451 
452 inline
454 {
455  return m_choice == e_Sid;
456 }
457 
458 inline
460 {
461  CheckSelected(e_Sid);
462  return m_Sid;
463 }
464 
465 inline
467 {
468  Select(e_Sid, NCBI_NS_NCBI::eDoNotResetVariant);
469  return m_Sid;
470 }
471 
472 inline
474 {
475  Select(e_Sid, NCBI_NS_NCBI::eDoNotResetVariant);
476  m_Sid = value;
477 }
478 
479 inline
481 {
482  return m_choice == e_Xid;
483 }
484 
485 inline
487 {
488  CheckSelected(e_Xid);
489  return m_Xid;
490 }
491 
492 inline
494 {
495  Select(e_Xid, NCBI_NS_NCBI::eDoNotResetVariant);
496  return m_Xid;
497 }
498 
499 inline
501 {
502  Select(e_Xid, NCBI_NS_NCBI::eDoNotResetVariant);
503  m_Xid = value;
504 }
505 
506 inline
508 {
509  return ((m_set_State[0] & 0x3) != 0);
510 }
511 
512 inline
514 {
515  return IsSetType();
516 }
517 
518 inline
520 {
521  m_Type = (EType)(0);
522  m_set_State[0] &= ~0x3;
523 }
524 
525 inline
527 {
528  if (!CanGetType()) {
529  ThrowUnassigned(0);
530  }
531  return m_Type;
532 }
533 
534 inline
536 {
537  m_Type = value;
538  m_set_State[0] |= 0x3;
539 }
540 
541 inline
543 {
544 #ifdef _DEBUG
545  if (!IsSetType()) {
546  memset(&m_Type,UnassignedByte(),sizeof(m_Type));
547  }
548 #endif
549  m_set_State[0] |= 0x1;
550  return m_Type;
551 }
552 
553 inline
555 {
556  return m_Id.NotEmpty();
557 }
558 
559 inline
561 {
562  return IsSetId();
563 }
564 
565 inline
567 {
568  if (!CanGetId()) {
569  ThrowUnassigned(1);
570  }
571  return (*m_Id);
572 }
573 
574 ///////////////////////////////////////////////////////////
575 ////////////////// end of inline methods //////////////////
576 ///////////////////////////////////////////////////////////
577 
578 
579 
580 
581 
582 END_objects_SCOPE // namespace ncbi::objects::
583 
585 
586 
587 #endif // OBJECTS_PCSUBSTANCE_PC_COMPOUNDTYPE_BASE_HPP
Compound Namespace and ID (absent for "deposited" type compounds)
Qualification used to describe the type of Compound deposited, standardized, or derived.
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
static char UnassignedByte(void)
Definition: serialbase.hpp:181
void ThrowUnassigned(TMemberIndex index) const
EResetVariant
Definition: serialbase.hpp:76
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
@ 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_PCSUBSTANCE_EXPORT
Definition: ncbi_export.h:688
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
TType GetType(void) const
Get the Type member data.
TXid GetXid(void) const
Get the variant data.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
bool CanGetType(void) const
Check if it is safe to call GetType method.
E_Choice Which(void) const
Which variant is currently selected.
bool IsCid(void) const
Check if variant Cid is selected.
TSid & SetSid(void)
Select the variant.
TXid & SetXid(void)
Select the variant.
void ResetType(void)
Reset Type data member.
TCid & SetCid(void)
Select the variant.
CPC_CompoundType_Base(const CPC_CompoundType_Base &)
bool IsSetId(void) const
Check if a value has been assigned to Id data member.
TCid GetCid(void) const
Get the variant data.
TSid GetSid(void) const
Get the variant data.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
C_Id & operator=(const C_Id &)
bool IsXid(void) const
Check if variant Xid is selected.
EType
Compound Qualifier or Type For Compound Depositions.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
const TId & GetId(void) const
Get the Id member data.
TType & SetType(void)
Assign a value to Type data member.
CPC_CompoundType_Base & operator=(const CPC_CompoundType_Base &)
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsSid(void) const
Check if variant Sid is selected.
bool CanGetId(void) const
Check if it is safe to call GetId method.
bool IsSetType(void) const
Check if a value has been assigned to Type data member.
@ e_Sid
PubChem Substance (for "mixture" type compounds)
@ e_Cid
Standardized Compound.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Sun Apr 21 03:37:57 2024 by modify_doxy.py rev. 669887