NCBI C++ ToolKit
TargetOrImportType_.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 TargetOrImportType_.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/build-system/project_tree_builder/msbuild/msbuild_dataobj.xsd">msbuild_dataobj.xsd</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/build-system/project_tree_builder/msbuild/msbuild_dataobj.def">msbuild_dataobj.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 msbuild__BUILD_SYSTEM_PROJECT_TREE_BUILDER_MSBUILD_TARGETORIMPORTTYPE_BASE_HPP
42 #define msbuild__BUILD_SYSTEM_PROJECT_TREE_BUILDER_MSBUILD_TARGETORIMPORTTYPE_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 #ifndef BEGIN_msbuild_SCOPE
47 # define BEGIN_msbuild_SCOPE BEGIN_SCOPE(msbuild)
48 # define END_msbuild_SCOPE END_SCOPE(msbuild)
49 #endif
50 BEGIN_msbuild_SCOPE // namespace msbuild::
51 
52 
53 // forward declarations
54 class CImport;
55 class CTarget;
56 
57 
58 // generated classes
59 
60 
61 /** @addtogroup dataspec_msbuild_dataobj
62  *
63  * @{
64  */
65 
66 /////////////////////////////////////////////////////////////////////////////
67 ///
68 /// CTargetOrImportType_Base --
69 ///
70 
71 class CTargetOrImportType_Base : public NCBI_NS_NCBI::CSerialObject
72 {
73  typedef NCBI_NS_NCBI::CSerialObject Tparent;
74 public:
75  // constructor
77  // destructor
78  virtual ~CTargetOrImportType_Base(void);
79 
80  // type info
82 
83 
84  /// Choice variants.
85  enum E_Choice {
86  e_not_set = 0, ///< No variant selected
88  e_Import
89  };
90  /// Maximum+1 value of the choice variant enumerator.
92  e_MaxChoice = 3 ///< == e_Import+1
93  };
94 
95  /// Reset the whole object
96  virtual void Reset(void);
97 
98  /// Reset the selection (set it to e_not_set).
99  virtual void ResetSelection(void);
100 
101  /// Which variant is currently selected.
102  ///
103  /// @return
104  /// Choice state enumerator.
105  E_Choice Which(void) const;
106 
107  /// Verify selection, throw exception if it differs from the expected.
108  ///
109  /// @param index
110  /// Expected selection.
111  void CheckSelected(E_Choice index) const;
112 
113  /// Throw 'InvalidSelection' exception.
114  ///
115  /// @param index
116  /// Expected selection.
117  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
118 
119  /// Retrieve selection name (for diagnostic purposes).
120  ///
121  /// @param index
122  /// One of possible selection states.
123  /// @return
124  /// Name string.
126 
127  /// Select the requested variant if needed.
128  ///
129  /// @param index
130  /// New selection state.
131  /// @param reset
132  /// Flag that defines the resetting of the variant data. The data will
133  /// be reset if either the current selection differs from the new one,
134  /// or the flag is set to eDoResetVariant.
136  /// Select the requested variant if needed,
137  /// allocating CObject variants from memory pool.
138  void Select(E_Choice index,
140  NCBI_NS_NCBI::CObjectMemoryPool* pool);
141 
142  // types
143  typedef CTarget TTarget;
144  typedef CImport TImport;
145 
146  // getters
147  // setters
148 
149 
150  /// Check if variant Target is selected.
151  ///
152  /// Target type is defined as 'typedef CTarget TTarget'.
153  /// @return
154  /// - true, if the variant is selected.
155  /// - false, otherwise.
156  bool IsTarget(void) const;
157 
158  /// Get the variant data.
159  ///
160  /// @return
161  /// Reference to the data.
162  const TTarget& GetTarget(void) const;
163 
164  /// Select the variant.
165  ///
166  /// @return
167  /// Reference to the variant data.
168  TTarget& SetTarget(void);
169  /// Select the variant and set its data.
170  ///
171  /// @param value
172  /// Reference to the data.
173  void SetTarget(TTarget& value);
174 
175 
176  /// Check if variant Import is selected.
177  ///
178  /// Import type is defined as 'typedef CImport TImport'.
179  /// @return
180  /// - true, if the variant is selected.
181  /// - false, otherwise.
182  bool IsImport(void) const;
183 
184  /// Get the variant data.
185  ///
186  /// @return
187  /// Reference to the data.
188  const TImport& GetImport(void) const;
189 
190  /// Select the variant.
191  ///
192  /// @return
193  /// Reference to the variant data.
194  TImport& SetImport(void);
195  /// Select the variant and set its data.
196  ///
197  /// @param value
198  /// Reference to the data.
199  void SetImport(TImport& value);
200 
201 
202 private:
203  // copy constructor and assignment operator
206  // choice state
208  // helper methods
209  void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool = 0);
210 
211  static const char* const sm_SelectionNames[];
212  // data
213  NCBI_NS_NCBI::CSerialObject *m_object;
214 };
215 
216 /* @} */
217 
218 
219 
220 
221 
222 ///////////////////////////////////////////////////////////
223 ///////////////////// inline methods //////////////////////
224 ///////////////////////////////////////////////////////////
225 inline
227 {
228  return m_choice;
229 }
230 
231 inline
233 {
234  if ( m_choice != index )
235  ThrowInvalidSelection(index);
236 }
237 
238 inline
239 void CTargetOrImportType_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
240 {
241  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
242  if ( m_choice != e_not_set )
243  ResetSelection();
244  DoSelect(index, pool);
245  }
246 }
247 
248 inline
250 {
251  Select(index, reset, 0);
252 }
253 
254 inline
256 {
257  return m_choice == e_Target;
258 }
259 
260 inline
262 {
263  return m_choice == e_Import;
264 }
265 
266 ///////////////////////////////////////////////////////////
267 ////////////////// end of inline methods //////////////////
268 ///////////////////////////////////////////////////////////
269 
270 
271 
272 
273 
274 END_msbuild_SCOPE // namespace msbuild::
275 
276 
277 #endif // msbuild__BUILD_SYSTEM_PROJECT_TREE_BUILDER_MSBUILD_TARGETORIMPORTTYPE_BASE_HPP
#define END_msbuild_SCOPE
#define BEGIN_msbuild_SCOPE
CImport –.
Definition: Import.hpp:64
CTargetOrImportType_Base –.
CTarget –.
Definition: Target.hpp:64
string
Definition: cgiapp.hpp:687
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
bool IsTarget(void) const
Check if variant Target is selected.
const TImport & GetImport(void) const
Get the variant data.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
static const char *const sm_SelectionNames[]
NCBI_NS_NCBI::CSerialObject * m_object
static NCBI_NS_STD::string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
CTargetOrImportType_Base & operator=(const CTargetOrImportType_Base &)
CTargetOrImportType_Base(const CTargetOrImportType_Base &)
bool IsImport(void) const
Check if variant Import is selected.
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
NCBI_NS_NCBI::CSerialObject Tparent
E_Choice Which(void) const
Which variant is currently selected.
virtual void Reset(void)
Reset the whole object.
void Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset=NCBI_NS_NCBI::eDoResetVariant)
Select the requested variant if needed.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
TImport & SetImport(void)
Select the variant.
TTarget & SetTarget(void)
Select the variant.
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
void DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool *pool=0)
const TTarget & GetTarget(void) const
Get the variant data.
@ e_not_set
No variant selected.
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Mon May 06 04:47:00 2024 by modify_doxy.py rev. 669887