NCBI C++ ToolKit
CDD_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 CDD_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/objtools/data_loaders/cdd/cdd_access/cdd_access.asn">cdd_access.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objtools/data_loaders/cdd/cdd_access/cdd_access.def">cdd_access.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 OBJTOOLS_DATA_LOADERS_CDD_CDD_ACCESS_CDD_REQUEST_BASE_HPP
42 #define OBJTOOLS_DATA_LOADERS_CDD_CDD_ACCESS_CDD_REQUEST_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
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 CID2_Blob_Id;
61 class CSeq_id;
62 
63 
64 // generated classes
65 
66 
67 /** @addtogroup dataspec_NCBI_CDDAccess
68  *
69  * @{
70  */
71 
72 /////////////////////////////////////////////////////////////////////////////
73 ///
74 /// CCDD_Request_Base --
75 ///
76 
78 {
80 public:
81  // constructor
82  CCDD_Request_Base(void);
83  // destructor
84  virtual ~CCDD_Request_Base(void);
85 
86  // type info
88 
89  /////////////////////////////////////////////////////////////////////////////
90  ///
91  /// C_Request --
92  ///
93 
95  {
97  public:
98  // constructor
99  C_Request(void);
100  // destructor
101  ~C_Request(void);
102 
103  // type info
105 
106 
107  /// Choice variants.
108  enum E_Choice {
109  e_not_set = 0, ///< No variant selected
110  e_Get_blob_id, ///< get blob-id for the seq-id
111  e_Get_blob, ///< get data for the blob-id
112  e_Get_blob_by_seq_id, ///< get one blob for one seq-id
113  e_Get_blob_by_seq_ids ///< get one blob for multiple seq-ids
114  };
115  /// Maximum+1 value of the choice variant enumerator.
117  e_MaxChoice = 5 ///< == e_Get_blob_by_seq_ids+1
118  };
119 
120  /// Reset the whole object
121  void Reset(void);
122 
123  /// Reset the selection (set it to e_not_set).
124  void ResetSelection(void);
125 
126  /// Which variant is currently selected.
127  ///
128  /// @return
129  /// Choice state enumerator.
130  E_Choice Which(void) const;
131 
132  /// Verify selection, throw exception if it differs from the expected.
133  ///
134  /// @param index
135  /// Expected selection.
136  void CheckSelected(E_Choice index) const;
137 
138  /// Throw 'InvalidSelection' exception.
139  ///
140  /// @param index
141  /// Expected selection.
142  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
143 
144  /// Retrieve selection name (for diagnostic purposes).
145  ///
146  /// @param index
147  /// One of possible selection states.
148  /// @return
149  /// Name string.
150  static string SelectionName(E_Choice index);
151 
152  /// Select the requested variant if needed.
153  ///
154  /// @param index
155  /// New selection state.
156  /// @param reset
157  /// Flag that defines the resetting of the variant data. The data will
158  /// be reset if either the current selection differs from the new one,
159  /// or the flag is set to eDoResetVariant.
161  /// Select the requested variant if needed,
162  /// allocating CObject variants from memory pool.
163  void Select(E_Choice index,
164  EResetVariant reset,
165  CObjectMemoryPool* pool);
166 
167  // types
171  typedef list< CRef< CSeq_id > > TGet_blob_by_seq_ids;
172 
173  // getters
174  // setters
175 
176 
177  /// Check if variant Get_blob_id is selected.
178  ///
179  /// Get_blob_id type is defined as 'typedef CSeq_id TGet_blob_id'.
180  /// @return
181  /// - true, if the variant is selected.
182  /// - false, otherwise.
183  bool IsGet_blob_id(void) const;
184 
185  /// Get the variant data.
186  ///
187  /// @return
188  /// Reference to the data.
189  const TGet_blob_id& GetGet_blob_id(void) const;
190 
191  /// Select the variant.
192  ///
193  /// @return
194  /// Reference to the variant data.
195  TGet_blob_id& SetGet_blob_id(void);
196  /// Select the variant and set its data.
197  ///
198  /// @param value
199  /// Reference to the data.
200  void SetGet_blob_id(TGet_blob_id& value);
201 
202 
203  /// Check if variant Get_blob is selected.
204  ///
205  /// Get_blob type is defined as 'typedef CID2_Blob_Id TGet_blob'.
206  /// @return
207  /// - true, if the variant is selected.
208  /// - false, otherwise.
209  bool IsGet_blob(void) const;
210 
211  /// Get the variant data.
212  ///
213  /// @return
214  /// Reference to the data.
215  const TGet_blob& GetGet_blob(void) const;
216 
217  /// Select the variant.
218  ///
219  /// @return
220  /// Reference to the variant data.
221  TGet_blob& SetGet_blob(void);
222  /// Select the variant and set its data.
223  ///
224  /// @param value
225  /// Reference to the data.
226  void SetGet_blob(TGet_blob& value);
227 
228 
229  /// Check if variant Get_blob_by_seq_id is selected.
230  ///
231  /// Get_blob_by_seq_id type is defined as 'typedef CSeq_id TGet_blob_by_seq_id'.
232  /// @return
233  /// - true, if the variant is selected.
234  /// - false, otherwise.
235  bool IsGet_blob_by_seq_id(void) const;
236 
237  /// Get the variant data.
238  ///
239  /// @return
240  /// Reference to the data.
241  const TGet_blob_by_seq_id& GetGet_blob_by_seq_id(void) const;
242 
243  /// Select the variant.
244  ///
245  /// @return
246  /// Reference to the variant data.
247  TGet_blob_by_seq_id& SetGet_blob_by_seq_id(void);
248  /// Select the variant and set its data.
249  ///
250  /// @param value
251  /// Reference to the data.
252  void SetGet_blob_by_seq_id(TGet_blob_by_seq_id& value);
253 
254 
255  /// Check if variant Get_blob_by_seq_ids is selected.
256  ///
257  /// Get_blob_by_seq_ids type is defined as 'typedef list< CRef< CSeq_id > > TGet_blob_by_seq_ids'.
258  /// @return
259  /// - true, if the variant is selected.
260  /// - false, otherwise.
261  bool IsGet_blob_by_seq_ids(void) const;
262 
263  /// Get the variant data.
264  ///
265  /// @return
266  /// Reference to the data.
267  const TGet_blob_by_seq_ids& GetGet_blob_by_seq_ids(void) const;
268 
269  /// Select the variant.
270  ///
271  /// @return
272  /// Reference to the variant data.
273  TGet_blob_by_seq_ids& SetGet_blob_by_seq_ids(void);
274 
275 
276  private:
277  // copy constructor and assignment operator
280  // choice state
282  // helper methods
283  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
284 
285  static const char* const sm_SelectionNames[];
286  // data
287  union {
288  NCBI_NS_NCBI::CUnionBuffer<TGet_blob_by_seq_ids> m_Get_blob_by_seq_ids;
289  NCBI_NS_NCBI::CSerialObject *m_object;
290  };
291  };
292  // types
293  typedef int TSerial_number;
295 
296  // member index
297  enum class E_memberIndex {
298  e__allMandatory = 0,
299  e_serial_number,
300  e_request
301  };
303 
304  // getters
305  // setters
306 
307  /// request's serial number, can be used in asynchronous clients
308  /// server should copy it to corresponding field in reply
309  /// Check if a value has been assigned to Serial_number data member.
310  ///
311  /// Data member Serial_number is optional;
312  /// its type is defined as 'typedef int TSerial_number'
313  /// @return
314  /// - true, if a value has been assigned.
315  /// - false, otherwise.
316  bool IsSetSerial_number(void) const;
317 
318  /// Check if it is safe to call GetSerial_number method.
319  ///
320  /// @return
321  /// - true, if the data member is getatable.
322  /// - false, otherwise.
323  bool CanGetSerial_number(void) const;
324 
325  /// Reset Serial_number data member.
326  void ResetSerial_number(void);
327 
328  /// Get the Serial_number member data.
329  ///
330  /// @return
331  /// Copy of the member data.
332  TSerial_number GetSerial_number(void) const;
333 
334  /// Assign a value to Serial_number data member.
335  ///
336  /// @param value
337  /// Value to assign
338  void SetSerial_number(TSerial_number value);
339 
340  /// Assign a value to Serial_number data member.
341  ///
342  /// @return
343  /// Reference to the data value.
344  TSerial_number& SetSerial_number(void);
345 
346  /// Check if a value has been assigned to Request data member.
347  ///
348  /// Data member Request is mandatory;
349  /// its type is defined as 'typedef C_Request TRequest'
350  /// @return
351  /// - true, if a value has been assigned.
352  /// - false, otherwise.
353  bool IsSetRequest(void) const;
354 
355  /// Check if it is safe to call GetRequest method.
356  ///
357  /// @return
358  /// - true, if the data member is getatable.
359  /// - false, otherwise.
360  bool CanGetRequest(void) const;
361 
362  /// Reset Request data member.
363  void ResetRequest(void);
364 
365  /// Get the Request member data.
366  ///
367  /// @return
368  /// Reference to the member data.
369  const TRequest& GetRequest(void) const;
370 
371  /// Assign a value to Request data member.
372  ///
373  /// @param value
374  /// Reference to value.
375  void SetRequest(TRequest& value);
376 
377  /// Assign a value to Request data member.
378  ///
379  /// @return
380  /// Reference to the data value.
381  TRequest& SetRequest(void);
382 
383  /// Reset the whole object
384  virtual void Reset(void);
385 
386 
387 private:
388  // Prohibit copy constructor and assignment operator
391 
392  // data
393  Uint4 m_set_State[1];
396 };
397 
398 /* @} */
399 
400 
401 
402 
403 
404 ///////////////////////////////////////////////////////////
405 ///////////////////// inline methods //////////////////////
406 ///////////////////////////////////////////////////////////
407 inline
409 {
410  return m_choice;
411 }
412 
413 inline
415 {
416  if ( m_choice != index )
417  ThrowInvalidSelection(index);
418 }
419 
420 inline
421 void CCDD_Request_Base::C_Request::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
422 {
423  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
424  if ( m_choice != e_not_set )
425  ResetSelection();
426  DoSelect(index, pool);
427  }
428 }
429 
430 inline
432 {
433  Select(index, reset, 0);
434 }
435 
436 inline
438 {
439  return m_choice == e_Get_blob_id;
440 }
441 
442 inline
444 {
445  return m_choice == e_Get_blob;
446 }
447 
448 inline
450 {
451  return m_choice == e_Get_blob_by_seq_id;
452 }
453 
454 inline
456 {
457  return m_choice == e_Get_blob_by_seq_ids;
458 }
459 
460 inline
462 {
463  CheckSelected(e_Get_blob_by_seq_ids);
464  return *m_Get_blob_by_seq_ids;
465 }
466 
467 inline
469 {
470  Select(e_Get_blob_by_seq_ids, NCBI_NS_NCBI::eDoNotResetVariant);
471  return *m_Get_blob_by_seq_ids;
472 }
473 
474 inline
476 {
477  return ((m_set_State[0] & 0x3) != 0);
478 }
479 
480 inline
482 {
483  return IsSetSerial_number();
484 }
485 
486 inline
488 {
489  m_Serial_number = 0;
490  m_set_State[0] &= ~0x3;
491 }
492 
493 inline
495 {
496  if (!CanGetSerial_number()) {
497  ThrowUnassigned(0);
498  }
499  return m_Serial_number;
500 }
501 
502 inline
504 {
506  m_set_State[0] |= 0x3;
507 }
508 
509 inline
511 {
512 #ifdef _DEBUG
513  if (!IsSetSerial_number()) {
515  }
516 #endif
517  m_set_State[0] |= 0x1;
518  return m_Serial_number;
519 }
520 
521 inline
523 {
524  return m_Request.NotEmpty();
525 }
526 
527 inline
529 {
530  return true;
531 }
532 
533 inline
535 {
536  if ( !m_Request ) {
537  const_cast<CCDD_Request_Base*>(this)->ResetRequest();
538  }
539  return (*m_Request);
540 }
541 
542 inline
544 {
545  if ( !m_Request ) {
546  ResetRequest();
547  }
548  return (*m_Request);
549 }
550 
551 ///////////////////////////////////////////////////////////
552 ////////////////// end of inline methods //////////////////
553 ///////////////////////////////////////////////////////////
554 
555 
556 
557 
558 
559 END_objects_SCOPE // namespace ncbi::objects::
560 
562 
563 
564 #endif // OBJTOOLS_DATA_LOADERS_CDD_CDD_ACCESS_CDD_REQUEST_BASE_HPP
CCDD_Request_Base –.
CID2_Blob_Id –.
Definition: ID2_Blob_Id.hpp:66
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
#define NCBI_CDD_ACCESS_EXPORT
Definition: ncbi_export.h:1505
bool CanGetRequest(void) const
Check if it is safe to call GetRequest method.
bool IsSetRequest(void) const
Check if a value has been assigned to Request data member.
const TGet_blob_by_seq_ids & GetGet_blob_by_seq_ids(void) const
Get the variant data.
CCDD_Request_Base(const CCDD_Request_Base &)
CRef< TRequest > m_Request
NCBI_NS_NCBI::CSerialObject * m_object
E_Choice Which(void) const
Which variant is currently selected.
C_Request(const C_Request &)
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
bool IsGet_blob_by_seq_ids(void) const
Check if variant Get_blob_by_seq_ids is selected.
bool IsGet_blob_by_seq_id(void) const
Check if variant Get_blob_by_seq_id is selected.
TSerial_number & SetSerial_number(void)
Assign a value to Serial_number data member.
void ResetSerial_number(void)
Reset Serial_number data member.
C_Request & operator=(const C_Request &)
list< CRef< CSeq_id > > TGet_blob_by_seq_ids
bool IsGet_blob_id(void) const
Check if variant Get_blob_id is selected.
bool IsSetSerial_number(void) const
request's serial number, can be used in asynchronous clients server should copy it to corresponding f...
bool IsGet_blob(void) const
Check if variant Get_blob is selected.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
TRequest & SetRequest(void)
Assign a value to Request data member.
NCBI_NS_NCBI::CUnionBuffer< TGet_blob_by_seq_ids > m_Get_blob_by_seq_ids
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
const TRequest & GetRequest(void) const
Get the Request member data.
bool CanGetSerial_number(void) const
Check if it is safe to call GetSerial_number method.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
TGet_blob_by_seq_ids & SetGet_blob_by_seq_ids(void)
Select the variant.
void ResetRequest(void)
Reset Request data member.
CCDD_Request_Base & operator=(const CCDD_Request_Base &)
CSerialObject Tparent
@ e_Get_blob_by_seq_id
get one blob for one seq-id
@ e_Get_blob
get data for the blob-id
@ e_Get_blob_id
get blob-id for the seq-id
@ e_not_set
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:21 2024 by modify_doxy.py rev. 669887