NCBI C++ ToolKit
Action_choice_.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 Action_choice_.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/macro/macro.asn">macro.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/macro/macro.def">macro.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_MACRO_ACTION_CHOICE_BASE_HPP
42 #define OBJECTS_MACRO_ACTION_CHOICE_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
56 class CAECRParse_action;
57 class CApply_action;
58 class CConvert_action;
59 class CCopy_action;
60 class CEdit_action;
61 class CRemove_action;
63 class CSwap_action;
64 
65 
66 // generated classes
67 
68 
69 /** @addtogroup dataspec_NCBI_Macro
70  *
71  * @{
72  */
73 
74 /////////////////////////////////////////////////////////////////////////////
75 ///
76 /// CAction_choice_Base --
77 ///
78 
80 {
82 public:
83  // constructor
84  CAction_choice_Base(void);
85  // destructor
86  virtual ~CAction_choice_Base(void);
87 
88  // type info
90 
91 
92  /// Choice variants.
93  enum E_Choice {
94  e_not_set = 0, ///< No variant selected
103  };
104  /// Maximum+1 value of the choice variant enumerator.
106  e_MaxChoice = 9 ///< == e_Remove_outside+1
107  };
108 
109  /// Reset the whole object
110  virtual void Reset(void);
111 
112  /// Reset the selection (set it to e_not_set).
113  virtual void ResetSelection(void);
114 
115  /// Which variant is currently selected.
116  ///
117  /// @return
118  /// Choice state enumerator.
119  E_Choice Which(void) const;
120 
121  /// Verify selection, throw exception if it differs from the expected.
122  ///
123  /// @param index
124  /// Expected selection.
125  void CheckSelected(E_Choice index) const;
126 
127  /// Throw 'InvalidSelection' exception.
128  ///
129  /// @param index
130  /// Expected selection.
131  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
132 
133  /// Retrieve selection name (for diagnostic purposes).
134  ///
135  /// @param index
136  /// One of possible selection states.
137  /// @return
138  /// Name string.
139  static string SelectionName(E_Choice index);
140 
141  /// Select the requested variant if needed.
142  ///
143  /// @param index
144  /// New selection state.
145  /// @param reset
146  /// Flag that defines the resetting of the variant data. The data will
147  /// be reset if either the current selection differs from the new one,
148  /// or the flag is set to eDoResetVariant.
150  /// Select the requested variant if needed,
151  /// allocating CObject variants from memory pool.
152  void Select(E_Choice index,
153  EResetVariant reset,
154  CObjectMemoryPool* pool);
155 
156  // types
165 
166  // getters
167  // setters
168 
169 
170  /// Check if variant Apply is selected.
171  ///
172  /// Apply type is defined as 'typedef CApply_action TApply'.
173  /// @return
174  /// - true, if the variant is selected.
175  /// - false, otherwise.
176  bool IsApply(void) const;
177 
178  /// Get the variant data.
179  ///
180  /// @return
181  /// Reference to the data.
182  const TApply& GetApply(void) const;
183 
184  /// Select the variant.
185  ///
186  /// @return
187  /// Reference to the variant data.
188  TApply& SetApply(void);
189  /// Select the variant and set its data.
190  ///
191  /// @param value
192  /// Reference to the data.
193  void SetApply(TApply& value);
194 
195 
196  /// Check if variant Edit is selected.
197  ///
198  /// Edit type is defined as 'typedef CEdit_action TEdit'.
199  /// @return
200  /// - true, if the variant is selected.
201  /// - false, otherwise.
202  bool IsEdit(void) const;
203 
204  /// Get the variant data.
205  ///
206  /// @return
207  /// Reference to the data.
208  const TEdit& GetEdit(void) const;
209 
210  /// Select the variant.
211  ///
212  /// @return
213  /// Reference to the variant data.
214  TEdit& SetEdit(void);
215  /// Select the variant and set its data.
216  ///
217  /// @param value
218  /// Reference to the data.
219  void SetEdit(TEdit& value);
220 
221 
222  /// Check if variant Convert is selected.
223  ///
224  /// Convert type is defined as 'typedef CConvert_action TConvert'.
225  /// @return
226  /// - true, if the variant is selected.
227  /// - false, otherwise.
228  bool IsConvert(void) const;
229 
230  /// Get the variant data.
231  ///
232  /// @return
233  /// Reference to the data.
234  const TConvert& GetConvert(void) const;
235 
236  /// Select the variant.
237  ///
238  /// @return
239  /// Reference to the variant data.
240  TConvert& SetConvert(void);
241  /// Select the variant and set its data.
242  ///
243  /// @param value
244  /// Reference to the data.
245  void SetConvert(TConvert& value);
246 
247 
248  /// Check if variant Copy is selected.
249  ///
250  /// Copy type is defined as 'typedef CCopy_action TCopy'.
251  /// @return
252  /// - true, if the variant is selected.
253  /// - false, otherwise.
254  bool IsCopy(void) const;
255 
256  /// Get the variant data.
257  ///
258  /// @return
259  /// Reference to the data.
260  const TCopy& GetCopy(void) const;
261 
262  /// Select the variant.
263  ///
264  /// @return
265  /// Reference to the variant data.
266  TCopy& SetCopy(void);
267  /// Select the variant and set its data.
268  ///
269  /// @param value
270  /// Reference to the data.
271  void SetCopy(TCopy& value);
272 
273 
274  /// Check if variant Swap is selected.
275  ///
276  /// Swap type is defined as 'typedef CSwap_action TSwap'.
277  /// @return
278  /// - true, if the variant is selected.
279  /// - false, otherwise.
280  bool IsSwap(void) const;
281 
282  /// Get the variant data.
283  ///
284  /// @return
285  /// Reference to the data.
286  const TSwap& GetSwap(void) const;
287 
288  /// Select the variant.
289  ///
290  /// @return
291  /// Reference to the variant data.
292  TSwap& SetSwap(void);
293  /// Select the variant and set its data.
294  ///
295  /// @param value
296  /// Reference to the data.
297  void SetSwap(TSwap& value);
298 
299 
300  /// Check if variant Remove is selected.
301  ///
302  /// Remove type is defined as 'typedef CRemove_action TRemove'.
303  /// @return
304  /// - true, if the variant is selected.
305  /// - false, otherwise.
306  bool IsRemove(void) const;
307 
308  /// Get the variant data.
309  ///
310  /// @return
311  /// Reference to the data.
312  const TRemove& GetRemove(void) const;
313 
314  /// Select the variant.
315  ///
316  /// @return
317  /// Reference to the variant data.
318  TRemove& SetRemove(void);
319  /// Select the variant and set its data.
320  ///
321  /// @param value
322  /// Reference to the data.
323  void SetRemove(TRemove& value);
324 
325 
326  /// Check if variant Parse is selected.
327  ///
328  /// Parse type is defined as 'typedef CAECRParse_action TParse'.
329  /// @return
330  /// - true, if the variant is selected.
331  /// - false, otherwise.
332  bool IsParse(void) const;
333 
334  /// Get the variant data.
335  ///
336  /// @return
337  /// Reference to the data.
338  const TParse& GetParse(void) const;
339 
340  /// Select the variant.
341  ///
342  /// @return
343  /// Reference to the variant data.
344  TParse& SetParse(void);
345  /// Select the variant and set its data.
346  ///
347  /// @param value
348  /// Reference to the data.
349  void SetParse(TParse& value);
350 
351 
352  /// Check if variant Remove_outside is selected.
353  ///
354  /// Remove_outside type is defined as 'typedef CRemove_outside_action TRemove_outside'.
355  /// @return
356  /// - true, if the variant is selected.
357  /// - false, otherwise.
358  bool IsRemove_outside(void) const;
359 
360  /// Get the variant data.
361  ///
362  /// @return
363  /// Reference to the data.
364  const TRemove_outside& GetRemove_outside(void) const;
365 
366  /// Select the variant.
367  ///
368  /// @return
369  /// Reference to the variant data.
371  /// Select the variant and set its data.
372  ///
373  /// @param value
374  /// Reference to the data.
376 
377 
378 private:
379  // copy constructor and assignment operator
382  // choice state
384  // helper methods
385  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
386 
387  static const char* const sm_SelectionNames[];
388  // data
389  NCBI_NS_NCBI::CSerialObject *m_object;
390 };
391 
392 /* @} */
393 
394 
395 
396 
397 
398 ///////////////////////////////////////////////////////////
399 ///////////////////// inline methods //////////////////////
400 ///////////////////////////////////////////////////////////
401 inline
403 {
404  return m_choice;
405 }
406 
407 inline
409 {
410  if ( m_choice != index )
411  ThrowInvalidSelection(index);
412 }
413 
414 inline
415 void CAction_choice_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
416 {
417  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
418  if ( m_choice != e_not_set )
419  ResetSelection();
420  DoSelect(index, pool);
421  }
422 }
423 
424 inline
426 {
427  Select(index, reset, 0);
428 }
429 
430 inline
432 {
433  return m_choice == e_Apply;
434 }
435 
436 inline
438 {
439  return m_choice == e_Edit;
440 }
441 
442 inline
444 {
445  return m_choice == e_Convert;
446 }
447 
448 inline
450 {
451  return m_choice == e_Copy;
452 }
453 
454 inline
456 {
457  return m_choice == e_Swap;
458 }
459 
460 inline
462 {
463  return m_choice == e_Remove;
464 }
465 
466 inline
468 {
469  return m_choice == e_Parse;
470 }
471 
472 inline
474 {
475  return m_choice == e_Remove_outside;
476 }
477 
478 ///////////////////////////////////////////////////////////
479 ////////////////// end of inline methods //////////////////
480 ///////////////////////////////////////////////////////////
481 
482 
483 
484 
485 
486 END_objects_SCOPE // namespace ncbi::objects::
487 
489 
490 
491 #endif // OBJECTS_MACRO_ACTION_CHOICE_BASE_HPP
CAECRParse_action –.
CAction_choice_Base –.
CApply_action –.
CConvert_action –.
CCopy_action –.
Definition: Copy_action.hpp:66
CEdit_action –.
Definition: Edit_action.hpp:66
CRemove_action –.
CRemove_outside_action –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSwap_action –.
Definition: Swap_action.hpp:66
char value[7]
Definition: config.c:431
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsSwap(void) const
Check if variant Swap is selected.
TParse & SetParse(void)
Select the variant.
TEdit & SetEdit(void)
Select the variant.
bool IsRemove_outside(void) const
Check if variant Remove_outside is selected.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
CAction_choice_Base & operator=(const CAction_choice_Base &)
bool IsCopy(void) const
Check if variant Copy is selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
E_Choice Which(void) const
Which variant is currently selected.
const TConvert & GetConvert(void) const
Get the variant data.
bool IsEdit(void) const
Check if variant Edit is selected.
const TRemove & GetRemove(void) const
Get the variant data.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
bool IsRemove(void) const
Check if variant Remove is selected.
virtual ~CAction_choice_Base(void)
TRemove & SetRemove(void)
Select the variant.
TApply & SetApply(void)
Select the variant.
bool IsConvert(void) const
Check if variant Convert is selected.
CRemove_action TRemove
CConvert_action TConvert
CAction_choice_Base(const CAction_choice_Base &)
virtual void Reset(void)
Reset the whole object.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
static const char *const sm_SelectionNames[]
bool IsParse(void) const
Check if variant Parse is selected.
TConvert & SetConvert(void)
Select the variant.
NCBI_NS_NCBI::CSerialObject * m_object
CSerialObject Tparent
const TParse & GetParse(void) const
Get the variant data.
TCopy & SetCopy(void)
Select the variant.
bool IsApply(void) const
Check if variant Apply is selected.
const TCopy & GetCopy(void) const
Get the variant data.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TSwap & SetSwap(void)
Select the variant.
CAECRParse_action TParse
const TRemove_outside & GetRemove_outside(void) const
Get the variant data.
const TEdit & GetEdit(void) const
Get the variant data.
TRemove_outside & SetRemove_outside(void)
Select the variant.
CRemove_outside_action TRemove_outside
E_Choice
Choice variants.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
const TSwap & GetSwap(void) const
Get the variant data.
const TApply & GetApply(void) const
Get the variant data.
@ e_MaxChoice
== e_Remove_outside+1
@ e_not_set
No variant selected.
Modified on Mon Feb 26 04:03:03 2024 by modify_doxy.py rev. 669887