NCBI C++ ToolKit
ID2_Request_.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 ID2_Request_.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/id2/id2.asn">id2.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/id2/id2.def">id2.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_ID2_ID2_REQUEST_BASE_HPP
42 #define OBJECTS_ID2_ID2_REQUEST_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 // forward declarations
57 class CID2_Params;
63 
64 
65 // generated classes
66 
67 
68 /** @addtogroup dataspec_NCBI_ID2Access
69  *
70  * @{
71  */
72 
73 /////////////////////////////////////////////////////////////////////////////
74 ///
75 /// CID2_Request_Base --
76 ///
77 
79 {
81 public:
82  // constructor
83  CID2_Request_Base(void);
84  // destructor
85  virtual ~CID2_Request_Base(void);
86 
87  // type info
89 
90  /////////////////////////////////////////////////////////////////////////////
91  ///
92  /// C_Request --
93  ///
94 
96  {
98  public:
99  // constructor
100  C_Request(void);
101  // destructor
102  ~C_Request(void);
103 
104  // type info
106 
107 
108  /// Choice variants.
109  enum E_Choice {
110  e_not_set = 0, ///< No variant selected
117  e_Get_chunks
118  };
119  /// Maximum+1 value of the choice variant enumerator.
121  e_MaxChoice = 8 ///< == e_Get_chunks+1
122  };
123 
124  /// Reset the whole object
125  void Reset(void);
126 
127  /// Reset the selection (set it to e_not_set).
128  void ResetSelection(void);
129 
130  /// Which variant is currently selected.
131  ///
132  /// @return
133  /// Choice state enumerator.
134  E_Choice Which(void) const;
135 
136  /// Verify selection, throw exception if it differs from the expected.
137  ///
138  /// @param index
139  /// Expected selection.
140  void CheckSelected(E_Choice index) const;
141 
142  /// Throw 'InvalidSelection' exception.
143  ///
144  /// @param index
145  /// Expected selection.
146  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
147 
148  /// Retrieve selection name (for diagnostic purposes).
149  ///
150  /// @param index
151  /// One of possible selection states.
152  /// @return
153  /// Name string.
154  static string SelectionName(E_Choice index);
155 
156  /// Select the requested variant if needed.
157  ///
158  /// @param index
159  /// New selection state.
160  /// @param reset
161  /// Flag that defines the resetting of the variant data. The data will
162  /// be reset if either the current selection differs from the new one,
163  /// or the flag is set to eDoResetVariant.
165  /// Select the requested variant if needed,
166  /// allocating CObject variants from memory pool.
167  void Select(E_Choice index,
168  EResetVariant reset,
169  CObjectMemoryPool* pool);
170 
171  // types
178 
179  // getters
180  // setters
181 
182 
183  /// Check if variant Init is selected.
184  ///
185  /// @return
186  /// - true, if the variant is selected.
187  /// - false, otherwise.
188  bool IsInit(void) const;
189 
190  /// Select the variant.
191  void SetInit(void);
192 
193 
194  /// Check if variant Get_packages is selected.
195  ///
196  /// Get_packages type is defined as 'typedef CID2_Request_Get_Packages TGet_packages'.
197  /// @return
198  /// - true, if the variant is selected.
199  /// - false, otherwise.
200  bool IsGet_packages(void) const;
201 
202  /// Get the variant data.
203  ///
204  /// @return
205  /// Reference to the data.
206  const TGet_packages& GetGet_packages(void) const;
207 
208  /// Select the variant.
209  ///
210  /// @return
211  /// Reference to the variant data.
212  TGet_packages& SetGet_packages(void);
213  /// Select the variant and set its data.
214  ///
215  /// @param value
216  /// Reference to the data.
217  void SetGet_packages(TGet_packages& value);
218 
219 
220  /// Check if variant Get_seq_id is selected.
221  ///
222  /// Get_seq_id type is defined as 'typedef CID2_Request_Get_Seq_id TGet_seq_id'.
223  /// @return
224  /// - true, if the variant is selected.
225  /// - false, otherwise.
226  bool IsGet_seq_id(void) const;
227 
228  /// Get the variant data.
229  ///
230  /// @return
231  /// Reference to the data.
232  const TGet_seq_id& GetGet_seq_id(void) const;
233 
234  /// Select the variant.
235  ///
236  /// @return
237  /// Reference to the variant data.
238  TGet_seq_id& SetGet_seq_id(void);
239  /// Select the variant and set its data.
240  ///
241  /// @param value
242  /// Reference to the data.
243  void SetGet_seq_id(TGet_seq_id& value);
244 
245 
246  /// Check if variant Get_blob_id is selected.
247  ///
248  /// Get_blob_id type is defined as 'typedef CID2_Request_Get_Blob_Id TGet_blob_id'.
249  /// @return
250  /// - true, if the variant is selected.
251  /// - false, otherwise.
252  bool IsGet_blob_id(void) const;
253 
254  /// Get the variant data.
255  ///
256  /// @return
257  /// Reference to the data.
258  const TGet_blob_id& GetGet_blob_id(void) const;
259 
260  /// Select the variant.
261  ///
262  /// @return
263  /// Reference to the variant data.
264  TGet_blob_id& SetGet_blob_id(void);
265  /// Select the variant and set its data.
266  ///
267  /// @param value
268  /// Reference to the data.
269  void SetGet_blob_id(TGet_blob_id& value);
270 
271 
272  /// Check if variant Get_blob_info is selected.
273  ///
274  /// Get_blob_info type is defined as 'typedef CID2_Request_Get_Blob_Info TGet_blob_info'.
275  /// @return
276  /// - true, if the variant is selected.
277  /// - false, otherwise.
278  bool IsGet_blob_info(void) const;
279 
280  /// Get the variant data.
281  ///
282  /// @return
283  /// Reference to the data.
284  const TGet_blob_info& GetGet_blob_info(void) const;
285 
286  /// Select the variant.
287  ///
288  /// @return
289  /// Reference to the variant data.
290  TGet_blob_info& SetGet_blob_info(void);
291  /// Select the variant and set its data.
292  ///
293  /// @param value
294  /// Reference to the data.
295  void SetGet_blob_info(TGet_blob_info& value);
296 
297 
298  /// Check if variant Reget_blob is selected.
299  ///
300  /// Reget_blob type is defined as 'typedef CID2_Request_ReGet_Blob TReget_blob'.
301  /// @return
302  /// - true, if the variant is selected.
303  /// - false, otherwise.
304  bool IsReget_blob(void) const;
305 
306  /// Get the variant data.
307  ///
308  /// @return
309  /// Reference to the data.
310  const TReget_blob& GetReget_blob(void) const;
311 
312  /// Select the variant.
313  ///
314  /// @return
315  /// Reference to the variant data.
316  TReget_blob& SetReget_blob(void);
317  /// Select the variant and set its data.
318  ///
319  /// @param value
320  /// Reference to the data.
321  void SetReget_blob(TReget_blob& value);
322 
323 
324  /// Check if variant Get_chunks is selected.
325  ///
326  /// Get_chunks type is defined as 'typedef CID2S_Request_Get_Chunks TGet_chunks'.
327  /// @return
328  /// - true, if the variant is selected.
329  /// - false, otherwise.
330  bool IsGet_chunks(void) const;
331 
332  /// Get the variant data.
333  ///
334  /// @return
335  /// Reference to the data.
336  const TGet_chunks& GetGet_chunks(void) const;
337 
338  /// Select the variant.
339  ///
340  /// @return
341  /// Reference to the variant data.
342  TGet_chunks& SetGet_chunks(void);
343  /// Select the variant and set its data.
344  ///
345  /// @param value
346  /// Reference to the data.
347  void SetGet_chunks(TGet_chunks& value);
348 
349 
350  private:
351  // copy constructor and assignment operator
354  // choice state
356  // helper methods
357  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
358 
359  static const char* const sm_SelectionNames[];
360  // data
361  union {
362  NCBI_NS_NCBI::CSerialObject *m_object;
363  };
364  };
365  // types
366  typedef int TSerial_number;
369 
370  // member index
371  enum class E_memberIndex {
372  e__allMandatory = 0,
373  e_serial_number,
374  e_params,
375  e_request
376  };
378 
379  // getters
380  // setters
381 
382  /// request's serial number, can be used in asynchronic clients
383  /// server should copy it to corresponding field in reply
384  /// Check if a value has been assigned to Serial_number data member.
385  ///
386  /// Data member Serial_number is optional;
387  /// its type is defined as 'typedef int TSerial_number'
388  /// @return
389  /// - true, if a value has been assigned.
390  /// - false, otherwise.
391  bool IsSetSerial_number(void) const;
392 
393  /// Check if it is safe to call GetSerial_number method.
394  ///
395  /// @return
396  /// - true, if the data member is getatable.
397  /// - false, otherwise.
398  bool CanGetSerial_number(void) const;
399 
400  /// Reset Serial_number data member.
401  void ResetSerial_number(void);
402 
403  /// Get the Serial_number member data.
404  ///
405  /// @return
406  /// Copy of the member data.
407  TSerial_number GetSerial_number(void) const;
408 
409  /// Assign a value to Serial_number data member.
410  ///
411  /// @param value
412  /// Value to assign
413  void SetSerial_number(TSerial_number value);
414 
415  /// Assign a value to Serial_number data member.
416  ///
417  /// @return
418  /// Reference to the data value.
419  TSerial_number& SetSerial_number(void);
420 
421  /// Check if a value has been assigned to Params data member.
422  ///
423  /// Data member Params is optional;
424  /// its type is defined as 'typedef CID2_Params TParams'
425  /// @return
426  /// - true, if a value has been assigned.
427  /// - false, otherwise.
428  bool IsSetParams(void) const;
429 
430  /// Check if it is safe to call GetParams method.
431  ///
432  /// @return
433  /// - true, if the data member is getatable.
434  /// - false, otherwise.
435  bool CanGetParams(void) const;
436 
437  /// Reset Params data member.
438  void ResetParams(void);
439 
440  /// Get the Params member data.
441  ///
442  /// @return
443  /// Reference to the member data.
444  const TParams& GetParams(void) const;
445 
446  /// Assign a value to Params data member.
447  ///
448  /// @param value
449  /// Reference to value.
450  void SetParams(TParams& value);
451 
452  /// Assign a value to Params data member.
453  ///
454  /// @return
455  /// Reference to the data value.
456  TParams& SetParams(void);
457 
458  /// Check if a value has been assigned to Request data member.
459  ///
460  /// Data member Request is mandatory;
461  /// its type is defined as 'typedef C_Request TRequest'
462  /// @return
463  /// - true, if a value has been assigned.
464  /// - false, otherwise.
465  bool IsSetRequest(void) const;
466 
467  /// Check if it is safe to call GetRequest method.
468  ///
469  /// @return
470  /// - true, if the data member is getatable.
471  /// - false, otherwise.
472  bool CanGetRequest(void) const;
473 
474  /// Reset Request data member.
475  void ResetRequest(void);
476 
477  /// Get the Request member data.
478  ///
479  /// @return
480  /// Reference to the member data.
481  const TRequest& GetRequest(void) const;
482 
483  /// Assign a value to Request data member.
484  ///
485  /// @param value
486  /// Reference to value.
487  void SetRequest(TRequest& value);
488 
489  /// Assign a value to Request data member.
490  ///
491  /// @return
492  /// Reference to the data value.
493  TRequest& SetRequest(void);
494 
495  /// Reset the whole object
496  virtual void Reset(void);
497 
498 
499 private:
500  // Prohibit copy constructor and assignment operator
503 
504  // data
505  Uint4 m_set_State[1];
509 };
510 
511 /* @} */
512 
513 
514 
515 
516 
517 ///////////////////////////////////////////////////////////
518 ///////////////////// inline methods //////////////////////
519 ///////////////////////////////////////////////////////////
520 inline
522 {
523  return m_choice;
524 }
525 
526 inline
528 {
529  if ( m_choice != index )
530  ThrowInvalidSelection(index);
531 }
532 
533 inline
534 void CID2_Request_Base::C_Request::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
535 {
536  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
537  if ( m_choice != e_not_set )
538  ResetSelection();
539  DoSelect(index, pool);
540  }
541 }
542 
543 inline
545 {
546  Select(index, reset, 0);
547 }
548 
549 inline
551 {
552  return m_choice == e_Init;
553 }
554 
555 inline
557 {
558  Select(e_Init, NCBI_NS_NCBI::eDoNotResetVariant);
559 }
560 
561 inline
563 {
564  return m_choice == e_Get_packages;
565 }
566 
567 inline
569 {
570  return m_choice == e_Get_seq_id;
571 }
572 
573 inline
575 {
576  return m_choice == e_Get_blob_id;
577 }
578 
579 inline
581 {
582  return m_choice == e_Get_blob_info;
583 }
584 
585 inline
587 {
588  return m_choice == e_Reget_blob;
589 }
590 
591 inline
593 {
594  return m_choice == e_Get_chunks;
595 }
596 
597 inline
599 {
600  return ((m_set_State[0] & 0x3) != 0);
601 }
602 
603 inline
605 {
606  return IsSetSerial_number();
607 }
608 
609 inline
611 {
612  m_Serial_number = 0;
613  m_set_State[0] &= ~0x3;
614 }
615 
616 inline
618 {
619  if (!CanGetSerial_number()) {
620  ThrowUnassigned(0);
621  }
622  return m_Serial_number;
623 }
624 
625 inline
627 {
629  m_set_State[0] |= 0x3;
630 }
631 
632 inline
634 {
635 #ifdef _DEBUG
636  if (!IsSetSerial_number()) {
638  }
639 #endif
640  m_set_State[0] |= 0x1;
641  return m_Serial_number;
642 }
643 
644 inline
646 {
647  return m_Params.NotEmpty();
648 }
649 
650 inline
652 {
653  return IsSetParams();
654 }
655 
656 inline
658 {
659  if (!CanGetParams()) {
660  ThrowUnassigned(1);
661  }
662  return (*m_Params);
663 }
664 
665 inline
667 {
668  return m_Request.NotEmpty();
669 }
670 
671 inline
673 {
674  return true;
675 }
676 
677 inline
679 {
680  if ( !m_Request ) {
681  const_cast<CID2_Request_Base*>(this)->ResetRequest();
682  }
683  return (*m_Request);
684 }
685 
686 inline
688 {
689  if ( !m_Request ) {
690  ResetRequest();
691  }
692  return (*m_Request);
693 }
694 
695 ///////////////////////////////////////////////////////////
696 ////////////////// end of inline methods //////////////////
697 ///////////////////////////////////////////////////////////
698 
699 
700 
701 
702 
703 END_objects_SCOPE // namespace ncbi::objects::
704 
706 
707 
708 #endif // OBJECTS_ID2_ID2_REQUEST_BASE_HPP
CID2S_Request_Get_Chunks –.
CID2_Params –.
Definition: ID2_Params.hpp:66
CID2_Request_Base –.
CID2_Request_Get_Blob_Id –.
CID2_Request_Get_Blob_Info –.
CID2_Request_Get_Packages –.
CID2_Request_Get_Seq_id –.
CID2_Request_ReGet_Blob –.
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
@ 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
virtual void SetParams()
Called at the beginning of Run, before creating thread pool.
#define NCBI_ID2_EXPORT
Definition: ncbi_export.h:552
NCBI_NS_NCBI::CSerialObject * m_object
CID2_Params TParams
void SetInit(void)
Select the variant.
bool IsGet_blob_info(void) const
Check if variant Get_blob_info is selected.
C_Request(const C_Request &)
CRef< TParams > m_Params
TRequest & SetRequest(void)
Assign a value to Request data member.
bool IsGet_packages(void) const
Check if variant Get_packages is selected.
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
TSerial_number & SetSerial_number(void)
Assign a value to Serial_number data member.
void ResetRequest(void)
Reset Request data member.
void ResetSerial_number(void)
Reset Serial_number data member.
CSerialObject Tparent
bool IsReget_blob(void) const
Check if variant Reget_blob is selected.
CID2S_Request_Get_Chunks TGet_chunks
CRef< TRequest > m_Request
bool CanGetSerial_number(void) const
Check if it is safe to call GetSerial_number method.
CID2_Request_Base & operator=(const CID2_Request_Base &)
bool IsSetRequest(void) const
Check if a value has been assigned to Request data member.
bool IsSetSerial_number(void) const
request's serial number, can be used in asynchronic clients server should copy it to corresponding fi...
CID2_Request_Get_Seq_id TGet_seq_id
E_Choice Which(void) const
Which variant is currently selected.
CID2_Request_Get_Packages TGet_packages
CID2_Request_Get_Blob_Info TGet_blob_info
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool CanGetParams(void) const
Check if it is safe to call GetParams method.
bool IsSetParams(void) const
Check if a value has been assigned to Params data member.
C_Request & operator=(const C_Request &)
CID2_Request_Get_Blob_Id TGet_blob_id
const TRequest & GetRequest(void) const
Get the Request member data.
bool IsInit(void) const
Check if variant Init is selected.
bool IsGet_seq_id(void) const
Check if variant Get_seq_id is selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
const TParams & GetParams(void) const
Get the Params member data.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
bool CanGetRequest(void) const
Check if it is safe to call GetRequest method.
CID2_Request_Base(const CID2_Request_Base &)
CID2_Request_ReGet_Blob TReget_blob
bool IsGet_blob_id(void) const
Check if variant Get_blob_id is selected.
bool IsGet_chunks(void) const
Check if variant Get_chunks is selected.
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static CRef< CUser_object > GetParams()
Modified on Tue Jun 18 13:41:07 2024 by modify_doxy.py rev. 669887