NCBI C++ ToolKit
Pagination_.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 Pagination_.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/eutils/efetch/efetch.xsd">efetch.xsd</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objtools/eutils/efetch/efetch.def">efetch.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 eutils__OBJTOOLS_EUTILS_EFETCH_PAGINATION_BASE_HPP
42 #define eutils__OBJTOOLS_EUTILS_EFETCH_PAGINATION_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 #ifndef BEGIN_eutils_SCOPE
47 # define BEGIN_eutils_SCOPE BEGIN_SCOPE(eutils)
48 # define END_eutils_SCOPE END_SCOPE(eutils)
49 #endif
50 BEGIN_eutils_SCOPE // namespace eutils::
51 
52 
53 // forward declarations
54 class CEndPage;
55 class CMedlinePgn;
56 class CStartPage;
57 
58 
59 // generated classes
60 
61 
62 /** @addtogroup dataspec_efetch
63  *
64  * @{
65  */
66 
67 /////////////////////////////////////////////////////////////////////////////
68 ///
69 /// CPagination_Base --
70 ///
71 
72 class CPagination_Base : public NCBI_NS_NCBI::CSerialObject
73 {
74  typedef NCBI_NS_NCBI::CSerialObject Tparent;
75 public:
76  // constructor
77  CPagination_Base(void);
78  // destructor
79  virtual ~CPagination_Base(void);
80 
81  // type info
83 
84  /////////////////////////////////////////////////////////////////////////////
85  ///
86  /// C_SEM --
87  ///
88 
89  class C_SEM : public NCBI_NS_NCBI::CSerialObject
90  {
91  typedef NCBI_NS_NCBI::CSerialObject Tparent;
92  public:
93  // constructor
94  C_SEM(void);
95  // destructor
96  ~C_SEM(void);
97 
98  // type info
100 
101  // types
105 
106  // member index
107  enum class E_memberIndex {
108  e__allMandatory = 0,
109  e_StartPage,
110  e_EndPage,
112  };
113  typedef Tparent::CMemberIndex<E_memberIndex, 4> TmemberIndex;
114 
115  // getters
116  // setters
117 
118  /// Check if a value has been assigned to StartPage data member.
119  ///
120  /// Data member StartPage is mandatory;
121  /// its type is defined as 'typedef CStartPage TStartPage'
122  /// @return
123  /// - true, if a value has been assigned.
124  /// - false, otherwise.
125  bool IsSetStartPage(void) const;
126 
127  /// Check if it is safe to call GetStartPage method.
128  ///
129  /// @return
130  /// - true, if the data member is getatable.
131  /// - false, otherwise.
132  bool CanGetStartPage(void) const;
133 
134  /// Reset StartPage data member.
135  void ResetStartPage(void);
136 
137  /// Get the StartPage member data.
138  ///
139  /// @return
140  /// Reference to the member data.
141  const TStartPage& GetStartPage(void) const;
142 
143  /// Assign a value to StartPage data member.
144  ///
145  /// @param value
146  /// Reference to value.
148 
149  /// Assign a value to StartPage data member.
150  ///
151  /// @return
152  /// Reference to the data value.
153  TStartPage& SetStartPage(void);
154 
155  /// Check if a value has been assigned to EndPage data member.
156  ///
157  /// Data member EndPage is optional;
158  /// its type is defined as 'typedef CEndPage TEndPage'
159  /// @return
160  /// - true, if a value has been assigned.
161  /// - false, otherwise.
162  bool IsSetEndPage(void) const;
163 
164  /// Check if it is safe to call GetEndPage method.
165  ///
166  /// @return
167  /// - true, if the data member is getatable.
168  /// - false, otherwise.
169  bool CanGetEndPage(void) const;
170 
171  /// Reset EndPage data member.
172  void ResetEndPage(void);
173 
174  /// Get the EndPage member data.
175  ///
176  /// @return
177  /// Reference to the member data.
178  const TEndPage& GetEndPage(void) const;
179 
180  /// Assign a value to EndPage data member.
181  ///
182  /// @param value
183  /// Reference to value.
184  void SetEndPage(TEndPage& value);
185 
186  /// Assign a value to EndPage data member.
187  ///
188  /// @return
189  /// Reference to the data value.
190  TEndPage& SetEndPage(void);
191 
192  /// Check if a value has been assigned to MedlinePgn data member.
193  ///
194  /// Data member MedlinePgn is optional;
195  /// its type is defined as 'typedef CMedlinePgn TMedlinePgn'
196  /// @return
197  /// - true, if a value has been assigned.
198  /// - false, otherwise.
199  bool IsSetMedlinePgn(void) const;
200 
201  /// Check if it is safe to call GetMedlinePgn method.
202  ///
203  /// @return
204  /// - true, if the data member is getatable.
205  /// - false, otherwise.
206  bool CanGetMedlinePgn(void) const;
207 
208  /// Reset MedlinePgn data member.
209  void ResetMedlinePgn(void);
210 
211  /// Get the MedlinePgn member data.
212  ///
213  /// @return
214  /// Reference to the member data.
215  const TMedlinePgn& GetMedlinePgn(void) const;
216 
217  /// Assign a value to MedlinePgn data member.
218  ///
219  /// @param value
220  /// Reference to value.
222 
223  /// Assign a value to MedlinePgn data member.
224  ///
225  /// @return
226  /// Reference to the data value.
227  TMedlinePgn& SetMedlinePgn(void);
228 
229  /// Reset the whole object
230  void Reset(void);
231 
232 
233  private:
234  // Prohibit copy constructor and assignment operator
235  C_SEM(const C_SEM&);
237 
238  // data
240  NCBI_NS_NCBI::CRef< TStartPage > m_StartPage;
241  NCBI_NS_NCBI::CRef< TEndPage > m_EndPage;
242  NCBI_NS_NCBI::CRef< TMedlinePgn > m_MedlinePgn;
243  };
244 
245  /// Choice variants.
246  enum E_Choice {
247  e_not_set = 0, ///< No variant selected
250  };
251  /// Maximum+1 value of the choice variant enumerator.
253  e_MaxChoice = 3 ///< == e_MedlinePgn+1
254  };
255 
256  /// Reset the whole object
257  virtual void Reset(void);
258 
259  /// Reset the selection (set it to e_not_set).
260  virtual void ResetSelection(void);
261 
262  /// Which variant is currently selected.
263  ///
264  /// @return
265  /// Choice state enumerator.
266  E_Choice Which(void) const;
267 
268  /// Verify selection, throw exception if it differs from the expected.
269  ///
270  /// @param index
271  /// Expected selection.
272  void CheckSelected(E_Choice index) const;
273 
274  /// Throw 'InvalidSelection' exception.
275  ///
276  /// @param index
277  /// Expected selection.
278  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
279 
280  /// Retrieve selection name (for diagnostic purposes).
281  ///
282  /// @param index
283  /// One of possible selection states.
284  /// @return
285  /// Name string.
287 
288  /// Select the requested variant if needed.
289  ///
290  /// @param index
291  /// New selection state.
292  /// @param reset
293  /// Flag that defines the resetting of the variant data. The data will
294  /// be reset if either the current selection differs from the new one,
295  /// or the flag is set to eDoResetVariant.
297  /// Select the requested variant if needed,
298  /// allocating CObject variants from memory pool.
299  void Select(E_Choice index,
301  NCBI_NS_NCBI::CObjectMemoryPool* pool);
302 
303  // types
304  typedef C_SEM TSEM;
306 
307  // getters
308  // setters
309 
310 
311  /// Check if variant SEM is selected.
312  ///
313  /// SEM type is defined as 'typedef C_SEM TSEM'.
314  /// @return
315  /// - true, if the variant is selected.
316  /// - false, otherwise.
317  bool IsSEM(void) const;
318 
319  /// Get the variant data.
320  ///
321  /// @return
322  /// Reference to the data.
323  const TSEM& GetSEM(void) const;
324 
325  /// Select the variant.
326  ///
327  /// @return
328  /// Reference to the variant data.
329  TSEM& SetSEM(void);
330  /// Select the variant and set its data.
331  ///
332  /// @param value
333  /// Reference to the data.
334  void SetSEM(TSEM& value);
335 
336 
337  /// Check if variant MedlinePgn is selected.
338  ///
339  /// MedlinePgn type is defined as 'typedef CMedlinePgn TMedlinePgn'.
340  /// @return
341  /// - true, if the variant is selected.
342  /// - false, otherwise.
343  bool IsMedlinePgn(void) const;
344 
345  /// Get the variant data.
346  ///
347  /// @return
348  /// Reference to the data.
349  const TMedlinePgn& GetMedlinePgn(void) const;
350 
351  /// Select the variant.
352  ///
353  /// @return
354  /// Reference to the variant data.
355  TMedlinePgn& SetMedlinePgn(void);
356  /// Select the variant and set its data.
357  ///
358  /// @param value
359  /// Reference to the data.
361 
362 
363 private:
364  // copy constructor and assignment operator
367  // choice state
369  // helper methods
370  void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool = 0);
371 
372  static const char* const sm_SelectionNames[];
373  // data
374  NCBI_NS_NCBI::CSerialObject *m_object;
375 };
376 
377 /* @} */
378 
379 
380 
381 
382 
383 ///////////////////////////////////////////////////////////
384 ///////////////////// inline methods //////////////////////
385 ///////////////////////////////////////////////////////////
386 inline
388 {
389  return m_StartPage.NotEmpty();
390 }
391 
392 inline
394 {
395  return true;
396 }
397 
398 inline
400 {
401  if ( !m_StartPage ) {
402  const_cast<C_SEM*>(this)->ResetStartPage();
403  }
404  return (*m_StartPage);
405 }
406 
407 inline
409 {
410  if ( !m_StartPage ) {
411  ResetStartPage();
412  }
413  return (*m_StartPage);
414 }
415 
416 inline
418 {
419  return m_EndPage.NotEmpty();
420 }
421 
422 inline
424 {
425  return IsSetEndPage();
426 }
427 
428 inline
430 {
431  if (!CanGetEndPage()) {
432  ThrowUnassigned(1);
433  }
434  return (*m_EndPage);
435 }
436 
437 inline
439 {
440  return m_MedlinePgn.NotEmpty();
441 }
442 
443 inline
445 {
446  return IsSetMedlinePgn();
447 }
448 
449 inline
451 {
452  if (!CanGetMedlinePgn()) {
453  ThrowUnassigned(2);
454  }
455  return (*m_MedlinePgn);
456 }
457 
458 inline
460 {
461  return m_choice;
462 }
463 
464 inline
466 {
467  if ( m_choice != index )
468  ThrowInvalidSelection(index);
469 }
470 
471 inline
472 void CPagination_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
473 {
474  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
475  if ( m_choice != e_not_set )
476  ResetSelection();
477  DoSelect(index, pool);
478  }
479 }
480 
481 inline
483 {
484  Select(index, reset, 0);
485 }
486 
487 inline
488 bool CPagination_Base::IsSEM(void) const
489 {
490  return m_choice == e_SEM;
491 }
492 
493 inline
495 {
496  return m_choice == e_MedlinePgn;
497 }
498 
499 ///////////////////////////////////////////////////////////
500 ////////////////// end of inline methods //////////////////
501 ///////////////////////////////////////////////////////////
502 
503 
504 
505 
506 
507 END_eutils_SCOPE // namespace eutils::
508 
509 
510 #endif // eutils__OBJTOOLS_EUTILS_EFETCH_PAGINATION_BASE_HPP
#define BEGIN_eutils_SCOPE
Definition: Pagination_.hpp:47
#define END_eutils_SCOPE
Definition: Pagination_.hpp:48
CEndPage –.
Definition: EndPage.hpp:64
CMedlinePgn –.
Definition: MedlinePgn.hpp:64
CPagination_Base –.
Definition: Pagination_.hpp:73
CStartPage –.
Definition: StartPage.hpp:64
char value[7]
Definition: config.c:431
string
Definition: cgiapp.hpp:687
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
TEndPage & SetEndPage(void)
Assign a value to EndPage data member.
Definition: Pagination_.cpp:75
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
bool IsSetEndPage(void) const
Check if a value has been assigned to EndPage data member.
TMedlinePgn & SetMedlinePgn(void)
Select the variant.
const TEndPage & GetEndPage(void) const
Get the EndPage member data.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
C_SEM & operator=(const C_SEM &)
TStartPage & SetStartPage(void)
Assign a value to StartPage data member.
NCBI_NS_NCBI::CSerialObject Tparent
Definition: Pagination_.hpp:91
NCBI_NS_NCBI::CRef< TMedlinePgn > m_MedlinePgn
void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool *pool=0)
E_Choice Which(void) const
Which variant is currently selected.
CMedlinePgn TMedlinePgn
bool CanGetEndPage(void) const
Check if it is safe to call GetEndPage method.
CPagination_Base(const CPagination_Base &)
const TMedlinePgn & GetMedlinePgn(void) const
Get the variant data.
static NCBI_NS_STD::string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
C_SEM(const C_SEM &)
const TSEM & GetSEM(void) const
Get the variant data.
bool CanGetStartPage(void) const
Check if it is safe to call GetStartPage method.
bool IsSetStartPage(void) const
Check if a value has been assigned to StartPage data member.
void Reset(void)
Reset the whole object.
Definition: Pagination_.cpp:99
NCBI_NS_NCBI::CRef< TEndPage > m_EndPage
static const char *const sm_SelectionNames[]
bool CanGetMedlinePgn(void) const
Check if it is safe to call GetMedlinePgn method.
bool IsSetMedlinePgn(void) const
Check if a value has been assigned to MedlinePgn data member.
const TMedlinePgn & GetMedlinePgn(void) const
Get the MedlinePgn member data.
TMedlinePgn & SetMedlinePgn(void)
Assign a value to MedlinePgn data member.
Definition: Pagination_.cpp:92
void ResetEndPage(void)
Reset EndPage data member.
Definition: Pagination_.cpp:65
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
const TStartPage & GetStartPage(void) const
Get the StartPage member data.
virtual ~CPagination_Base(void)
Tparent::CMemberIndex< E_memberIndex, 4 > TmemberIndex
TSEM & SetSEM(void)
Select the variant.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
E_Choice
Choice variants.
bool IsMedlinePgn(void) const
Check if variant MedlinePgn is selected.
void ResetStartPage(void)
Reset StartPage data member.
Definition: Pagination_.cpp:51
void ResetMedlinePgn(void)
Reset MedlinePgn data member.
Definition: Pagination_.cpp:82
NCBI_NS_NCBI::CSerialObject Tparent
Definition: Pagination_.hpp:74
bool IsSEM(void) const
Check if variant SEM is selected.
void Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset=NCBI_NS_NCBI::eDoResetVariant)
Select the requested variant if needed.
NCBI_NS_NCBI::CRef< TStartPage > m_StartPage
virtual void Reset(void)
Reset the whole object.
CPagination_Base & operator=(const CPagination_Base &)
NCBI_NS_NCBI::CSerialObject * m_object
@ e_MaxChoice
== e_MedlinePgn+1
@ e_not_set
No variant selected.
Modified on Mon Feb 26 04:02:26 2024 by modify_doxy.py rev. 669887