NCBI C++ ToolKit
ViewDataLink_.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 ViewDataLink_.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/gbproj/gbproj.asn">gbproj.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/gbproj/gbproj.def">gbproj.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_GBPROJ_VIEWDATALINK_BASE_HPP
42 #define OBJECTS_GBPROJ_VIEWDATALINK_BASE_HPP
43 
44 // extra headers
46 
47 // standard includes
48 #include <serial/serialbase.hpp>
49 
50 // generated includes
51 #include <string>
52 #include <vector>
53 
55 
56 #ifndef BEGIN_objects_SCOPE
57 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
58 # define END_objects_SCOPE END_SCOPE(objects)
59 #endif
60 BEGIN_objects_SCOPE // namespace ncbi::objects::
61 
62 
63 // generated classes
64 
65 
66 /** @addtogroup dataspec_NCBI_GBProject
67  *
68  * @{
69  */
70 
71 /////////////////////////////////////////////////////////////////////////////
72 ///
73 /// CViewDataLink_Base --
74 ///
75 
77 {
79 public:
80  // constructor
81  CViewDataLink_Base(void);
82  // destructor
83  virtual ~CViewDataLink_Base(void);
84 
85  // type info
87 
88  /////////////////////////////////////////////////////////////////////////////
89  ///- fingerprint of object to show in view
90  ///
91  /// C_Fingerprint --
92  ///
93 
95  {
97  public:
98  // constructor
99  C_Fingerprint(void);
100  // destructor
101  ~C_Fingerprint(void);
102 
103  // type info
105 
106 
107  /// Choice variants.
108  enum E_Choice {
109  e_not_set = 0, ///< No variant selected
111  e_Md5
112  };
113  /// Maximum+1 value of the choice variant enumerator.
115  e_MaxChoice = 3 ///< == e_Md5+1
116  };
117 
118  /// Reset the whole object
119  void Reset(void);
120 
121  /// Reset the selection (set it to e_not_set).
122  void ResetSelection(void);
123 
124  /// Which variant is currently selected.
125  ///
126  /// @return
127  /// Choice state enumerator.
128  E_Choice Which(void) const;
129 
130  /// Verify selection, throw exception if it differs from the expected.
131  ///
132  /// @param index
133  /// Expected selection.
134  void CheckSelected(E_Choice index) const;
135 
136  /// Throw 'InvalidSelection' exception.
137  ///
138  /// @param index
139  /// Expected selection.
140  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
141 
142  /// Retrieve selection name (for diagnostic purposes).
143  ///
144  /// @param index
145  /// One of possible selection states.
146  /// @return
147  /// Name string.
148  static string SelectionName(E_Choice index);
149 
150  /// Select the requested variant if needed.
151  ///
152  /// @param index
153  /// New selection state.
154  /// @param reset
155  /// Flag that defines the resetting of the variant data. The data will
156  /// be reset if either the current selection differs from the new one,
157  /// or the flag is set to eDoResetVariant.
159  /// Select the requested variant if needed,
160  /// allocating CObject variants from memory pool.
161  void Select(E_Choice index,
162  EResetVariant reset,
163  CObjectMemoryPool* pool);
164 
165  // types
166  typedef int TCrc32;
167  typedef vector< char > TMd5;
168 
169  // getters
170  // setters
171 
172 
173  /// Check if variant Crc32 is selected.
174  ///
175  /// Crc32 type is defined as 'typedef int TCrc32'.
176  /// @return
177  /// - true, if the variant is selected.
178  /// - false, otherwise.
179  bool IsCrc32(void) const;
180 
181  /// Get the variant data.
182  ///
183  /// @return
184  /// Copy of the variant data.
185  TCrc32 GetCrc32(void) const;
186 
187  /// Select the variant.
188  ///
189  /// @return
190  /// Reference to the variant data.
191  TCrc32& SetCrc32(void);
192 
193  /// Select the variant and set its data.
194  ///
195  /// @param value
196  /// Variant data.
197  void SetCrc32(TCrc32 value);
198 
199 
200  /// Check if variant Md5 is selected.
201  ///
202  /// Md5 type is defined as 'typedef vector< char > TMd5'.
203  /// @return
204  /// - true, if the variant is selected.
205  /// - false, otherwise.
206  bool IsMd5(void) const;
207 
208  /// Get the variant data.
209  ///
210  /// @return
211  /// Reference to the data.
212  const TMd5& GetMd5(void) const;
213 
214  /// Select the variant.
215  ///
216  /// @return
217  /// Reference to the variant data.
218  TMd5& SetMd5(void);
219 
220 
221  private:
222  // copy constructor and assignment operator
225  // choice state
227  // helper methods
228  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
229 
230  static const char* const sm_SelectionNames[];
231  // data
232  union {
234  NCBI_NS_NCBI::CUnionBuffer<TMd5> m_Md5;
236  };
237  };
238  // types
239  typedef int TProject_item_id;
241  typedef string TType;
242 
243  // member index
244  enum class E_memberIndex {
245  e__allMandatory = 0,
246  e_project_item_id,
247  e_fingerprint,
248  e_type
249  };
251 
252  // getters
253  // setters
254 
255  ///- if both are absent - link goes to project
256  ///- if both present - fingerprinted object inside project item
257  ///- if only project-item-id present - link goes to project item
258  ///- project item id
259  /// Check if a value has been assigned to Project_item_id data member.
260  ///
261  /// Data member Project_item_id is optional;
262  /// its type is defined as 'typedef int TProject_item_id'
263  /// @return
264  /// - true, if a value has been assigned.
265  /// - false, otherwise.
266  bool IsSetProject_item_id(void) const;
267 
268  /// Check if it is safe to call GetProject_item_id method.
269  ///
270  /// @return
271  /// - true, if the data member is getatable.
272  /// - false, otherwise.
273  bool CanGetProject_item_id(void) const;
274 
275  /// Reset Project_item_id data member.
276  void ResetProject_item_id(void);
277 
278  /// Get the Project_item_id member data.
279  ///
280  /// @return
281  /// Copy of the member data.
282  TProject_item_id GetProject_item_id(void) const;
283 
284  /// Assign a value to Project_item_id data member.
285  ///
286  /// @param value
287  /// Value to assign
288  void SetProject_item_id(TProject_item_id value);
289 
290  /// Assign a value to Project_item_id data member.
291  ///
292  /// @return
293  /// Reference to the data value.
294  TProject_item_id& SetProject_item_id(void);
295 
296  /// Check if a value has been assigned to Fingerprint data member.
297  ///
298  /// Data member Fingerprint is optional;
299  /// its type is defined as 'typedef C_Fingerprint TFingerprint'
300  /// @return
301  /// - true, if a value has been assigned.
302  /// - false, otherwise.
303  bool IsSetFingerprint(void) const;
304 
305  /// Check if it is safe to call GetFingerprint method.
306  ///
307  /// @return
308  /// - true, if the data member is getatable.
309  /// - false, otherwise.
310  bool CanGetFingerprint(void) const;
311 
312  /// Reset Fingerprint data member.
313  void ResetFingerprint(void);
314 
315  /// Get the Fingerprint member data.
316  ///
317  /// @return
318  /// Reference to the member data.
319  const TFingerprint& GetFingerprint(void) const;
320 
321  /// Assign a value to Fingerprint data member.
322  ///
323  /// @param value
324  /// Reference to value.
325  void SetFingerprint(TFingerprint& value);
326 
327  /// Assign a value to Fingerprint data member.
328  ///
329  /// @return
330  /// Reference to the data value.
331  TFingerprint& SetFingerprint(void);
332 
333  /// Check if a value has been assigned to Type data member.
334  ///
335  /// Data member Type is mandatory;
336  /// its type is defined as 'typedef string TType'
337  /// @return
338  /// - true, if a value has been assigned.
339  /// - false, otherwise.
340  bool IsSetType(void) const;
341 
342  /// Check if it is safe to call GetType method.
343  ///
344  /// @return
345  /// - true, if the data member is getatable.
346  /// - false, otherwise.
347  bool CanGetType(void) const;
348 
349  /// Reset Type data member.
350  void ResetType(void);
351 
352  /// Get the Type member data.
353  ///
354  /// @return
355  /// Reference to the member data.
356  const TType& GetType(void) const;
357 
358  /// Assign a value to Type data member.
359  ///
360  /// @param value
361  /// Value to assign
362  void SetType(const TType& value);
363  void SetType(TType&& value);
364 
365  /// Assign a value to Type data member.
366  ///
367  /// @return
368  /// Reference to the data value.
369  TType& SetType(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];
384  string 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 CViewDataLink_Base::C_Fingerprint::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_Crc32;
429 }
430 
431 inline
433 {
434  CheckSelected(e_Crc32);
435  return m_Crc32;
436 }
437 
438 inline
440 {
441  Select(e_Crc32, NCBI_NS_NCBI::eDoNotResetVariant);
442  return m_Crc32;
443 }
444 
445 inline
447 {
448  Select(e_Crc32, NCBI_NS_NCBI::eDoNotResetVariant);
449  m_Crc32 = value;
450 }
451 
452 inline
454 {
455  return m_choice == e_Md5;
456 }
457 
458 inline
460 {
461  CheckSelected(e_Md5);
462  return *m_Md5;
463 }
464 
465 inline
467 {
468  Select(e_Md5, NCBI_NS_NCBI::eDoNotResetVariant);
469  return *m_Md5;
470 }
471 
472 inline
474 {
475  return ((m_set_State[0] & 0x3) != 0);
476 }
477 
478 inline
480 {
481  return IsSetProject_item_id();
482 }
483 
484 inline
486 {
487  m_Project_item_id = 0;
488  m_set_State[0] &= ~0x3;
489 }
490 
491 inline
493 {
494  if (!CanGetProject_item_id()) {
495  ThrowUnassigned(0);
496  }
497  return m_Project_item_id;
498 }
499 
500 inline
502 {
504  m_set_State[0] |= 0x3;
505 }
506 
507 inline
509 {
510 #ifdef _DEBUG
511  if (!IsSetProject_item_id()) {
513  }
514 #endif
515  m_set_State[0] |= 0x1;
516  return m_Project_item_id;
517 }
518 
519 inline
521 {
522  return m_Fingerprint.NotEmpty();
523 }
524 
525 inline
527 {
528  return IsSetFingerprint();
529 }
530 
531 inline
533 {
534  if (!CanGetFingerprint()) {
535  ThrowUnassigned(1);
536  }
537  return (*m_Fingerprint);
538 }
539 
540 inline
542 {
543  return ((m_set_State[0] & 0x30) != 0);
544 }
545 
546 inline
548 {
549  return IsSetType();
550 }
551 
552 inline
554 {
555  if (!CanGetType()) {
556  ThrowUnassigned(2);
557  }
558  return m_Type;
559 }
560 
561 inline
563 {
564  m_Type = value;
565  m_set_State[0] |= 0x30;
566 }
567 
568 inline
570 {
571  m_Type = std::forward<CViewDataLink_Base::TType>(value);
572  m_set_State[0] |= 0x30;
573 }
574 
575 inline
577 {
578 #ifdef _DEBUG
579  if (!IsSetType()) {
581  }
582 #endif
583  m_set_State[0] |= 0x10;
584  return m_Type;
585 }
586 
587 ///////////////////////////////////////////////////////////
588 ////////////////// end of inline methods //////////////////
589 ///////////////////////////////////////////////////////////
590 
591 
592 
593 
594 
595 END_objects_SCOPE // namespace ncbi::objects::
596 
598 
599 
600 #endif // OBJECTS_GBPROJ_VIEWDATALINK_BASE_HPP
CRef –.
Definition: ncbiobj.hpp:618
Base class for all serializable objects.
Definition: serialbase.hpp:150
Defines to provide correct exporting from DLLs in Windows.
#define NCBI_GBPROJ_EXPORT
Definition: gbproj_export.h:69
static char UnassignedByte(void)
Definition: serialbase.hpp:181
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
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
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
bool CanGetType(void) const
Check if it is safe to call GetType method.
CSerialObject Tparent
NCBI_NS_NCBI::CUnionBuffer< TMd5 > m_Md5
bool IsSetType(void) const
Check if a value has been assigned to Type data member.
const TMd5 & GetMd5(void) const
Get the variant data.
CViewDataLink_Base(const CViewDataLink_Base &)
C_Fingerprint(const C_Fingerprint &)
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TProject_item_id & SetProject_item_id(void)
Assign a value to Project_item_id data member.
bool IsCrc32(void) const
Check if variant Crc32 is selected.
TCrc32 & SetCrc32(void)
Select the variant.
bool IsSetFingerprint(void) const
Check if a value has been assigned to Fingerprint data member.
bool IsMd5(void) const
Check if variant Md5 is selected.
TProject_item_id GetProject_item_id(void) const
Get the Project_item_id member data.
bool CanGetFingerprint(void) const
Check if it is safe to call GetFingerprint method.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool CanGetProject_item_id(void) const
Check if it is safe to call GetProject_item_id method.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void ResetProject_item_id(void)
Reset Project_item_id data member.
const TType & GetType(void) const
Get the Type member data.
TType & SetType(void)
Assign a value to Type data member.
TMd5 & SetMd5(void)
Select the variant.
const TFingerprint & GetFingerprint(void) const
Get the Fingerprint member data.
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
C_Fingerprint & operator=(const C_Fingerprint &)
CViewDataLink_Base & operator=(const CViewDataLink_Base &)
E_Choice Which(void) const
Which variant is currently selected.
CRef< TFingerprint > m_Fingerprint
bool IsSetProject_item_id(void) const
TCrc32 GetCrc32(void) const
Get the variant data.
C_Fingerprint TFingerprint
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Thu May 23 12:30:26 2024 by modify_doxy.py rev. 669887