NCBI C++ ToolKit
Region_pntrs_.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 Region_pntrs_.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/mmdb3/mmdb3.asn">mmdb3.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/mmdb3/mmdb3.def">mmdb3.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_MMDB3_REGION_PNTRS_BASE_HPP
42 #define OBJECTS_MMDB3_REGION_PNTRS_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <list>
50 
52 
53 #ifndef BEGIN_objects_SCOPE
54 # define BEGIN_objects_SCOPE BEGIN_SCOPE(objects)
55 # define END_objects_SCOPE END_SCOPE(objects)
56 #endif
57 BEGIN_objects_SCOPE // namespace ncbi::objects::
58 
59 
60 // forward declarations
61 class CRegion_boundary;
63 
64 
65 // generated classes
66 
67 
68 /** @addtogroup dataspec_MMDB_Features
69  *
70  * @{
71  */
72 
73 /////////////////////////////////////////////////////////////////////////////
74 /// Region motifs describe features defined by spatial location, such as the
75 /// site specified by a coordinate value, or a rgeion within a bounding volume.
76 ///
77 /// CRegion_pntrs_Base --
78 ///
79 
81 {
83 public:
84  // constructor
85  CRegion_pntrs_Base(void);
86  // destructor
87  virtual ~CRegion_pntrs_Base(void);
88 
89  // type info
91 
92  /////////////////////////////////////////////////////////////////////////////
93  ///
94  /// C_Region --
95  ///
96 
98  {
100  public:
101  // constructor
102  C_Region(void);
103  // destructor
104  ~C_Region(void);
105 
106  // type info
108 
109 
110  /// Choice variants.
111  enum E_Choice {
112  e_not_set = 0, ///< No variant selected
114  e_Boundary
115  };
116  /// Maximum+1 value of the choice variant enumerator.
118  e_MaxChoice = 3 ///< == e_Boundary+1
119  };
120 
121  /// Reset the whole object
122  void Reset(void);
123 
124  /// Reset the selection (set it to e_not_set).
125  void ResetSelection(void);
126 
127  /// Which variant is currently selected.
128  ///
129  /// @return
130  /// Choice state enumerator.
131  E_Choice Which(void) const;
132 
133  /// Verify selection, throw exception if it differs from the expected.
134  ///
135  /// @param index
136  /// Expected selection.
137  void CheckSelected(E_Choice index) const;
138 
139  /// Throw 'InvalidSelection' exception.
140  ///
141  /// @param index
142  /// Expected selection.
143  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
144 
145  /// Retrieve selection name (for diagnostic purposes).
146  ///
147  /// @param index
148  /// One of possible selection states.
149  /// @return
150  /// Name string.
151  static string SelectionName(E_Choice index);
152 
153  /// Select the requested variant if needed.
154  ///
155  /// @param index
156  /// New selection state.
157  /// @param reset
158  /// Flag that defines the resetting of the variant data. The data will
159  /// be reset if either the current selection differs from the new one,
160  /// or the flag is set to eDoResetVariant.
162  /// Select the requested variant if needed,
163  /// allocating CObject variants from memory pool.
164  void Select(E_Choice index,
165  EResetVariant reset,
166  CObjectMemoryPool* pool);
167 
168  // types
169  typedef list< CRef< CRegion_coordinates > > TSite;
170  typedef list< CRef< CRegion_boundary > > TBoundary;
171 
172  // getters
173  // setters
174 
175 
176  /// Check if variant Site is selected.
177  ///
178  /// Site type is defined as 'typedef list< CRef< CRegion_coordinates > > TSite'.
179  /// @return
180  /// - true, if the variant is selected.
181  /// - false, otherwise.
182  bool IsSite(void) const;
183 
184  /// Get the variant data.
185  ///
186  /// @return
187  /// Reference to the data.
188  const TSite& GetSite(void) const;
189 
190  /// Select the variant.
191  ///
192  /// @return
193  /// Reference to the variant data.
194  TSite& SetSite(void);
195 
196 
197  /// Check if variant Boundary is selected.
198  ///
199  /// Boundary type is defined as 'typedef list< CRef< CRegion_boundary > > TBoundary'.
200  /// @return
201  /// - true, if the variant is selected.
202  /// - false, otherwise.
203  bool IsBoundary(void) const;
204 
205  /// Get the variant data.
206  ///
207  /// @return
208  /// Reference to the data.
209  const TBoundary& GetBoundary(void) const;
210 
211  /// Select the variant.
212  ///
213  /// @return
214  /// Reference to the variant data.
215  TBoundary& SetBoundary(void);
216 
217 
218  private:
219  // copy constructor and assignment operator
220  C_Region(const C_Region& );
222  // choice state
224  // helper methods
225  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
226 
227  static const char* const sm_SelectionNames[];
228  // data
229  union {
230  NCBI_NS_NCBI::CUnionBuffer<TSite> m_Site;
231  NCBI_NS_NCBI::CUnionBuffer<TBoundary> m_Boundary;
233  };
234  };
235  // types
237  typedef C_Region TRegion;
238 
239  // member index
240  enum class E_memberIndex {
241  e__allMandatory = 0,
242  e_model_id,
243  e_region
244  };
246 
247  // getters
248  // setters
249 
250  /// Check if a value has been assigned to Model_id data member.
251  ///
252  /// Data member Model_id is mandatory;
253  /// its type is defined as 'typedef CModel_id TModel_id'
254  /// @return
255  /// - true, if a value has been assigned.
256  /// - false, otherwise.
257  bool IsSetModel_id(void) const;
258 
259  /// Check if it is safe to call GetModel_id method.
260  ///
261  /// @return
262  /// - true, if the data member is getatable.
263  /// - false, otherwise.
264  bool CanGetModel_id(void) const;
265 
266  /// Reset Model_id data member.
267  void ResetModel_id(void);
268 
269  /// Get the Model_id member data.
270  ///
271  /// @return
272  /// Reference to the member data.
273  const TModel_id& GetModel_id(void) const;
274 
275  /// Assign a value to Model_id data member.
276  ///
277  /// @param value
278  /// Value to assign
279  void SetModel_id(const TModel_id& value);
280 
281  /// Assign a value to Model_id data member.
282  ///
283  /// @return
284  /// Reference to the data value.
285  TModel_id& SetModel_id(void);
286 
287  /// Check if a value has been assigned to Region data member.
288  ///
289  /// Data member Region is mandatory;
290  /// its type is defined as 'typedef C_Region TRegion'
291  /// @return
292  /// - true, if a value has been assigned.
293  /// - false, otherwise.
294  bool IsSetRegion(void) const;
295 
296  /// Check if it is safe to call GetRegion method.
297  ///
298  /// @return
299  /// - true, if the data member is getatable.
300  /// - false, otherwise.
301  bool CanGetRegion(void) const;
302 
303  /// Reset Region data member.
304  void ResetRegion(void);
305 
306  /// Get the Region member data.
307  ///
308  /// @return
309  /// Reference to the member data.
310  const TRegion& GetRegion(void) const;
311 
312  /// Assign a value to Region data member.
313  ///
314  /// @param value
315  /// Reference to value.
316  void SetRegion(TRegion& value);
317 
318  /// Assign a value to Region data member.
319  ///
320  /// @return
321  /// Reference to the data value.
322  TRegion& SetRegion(void);
323 
324  /// Reset the whole object
325  virtual void Reset(void);
326 
327 
328 private:
329  // Prohibit copy constructor and assignment operator
332 
333  // data
334  Uint4 m_set_State[1];
337 };
338 
339 /* @} */
340 
341 
342 
343 
344 
345 ///////////////////////////////////////////////////////////
346 ///////////////////// inline methods //////////////////////
347 ///////////////////////////////////////////////////////////
348 inline
350 {
351  return m_choice;
352 }
353 
354 inline
356 {
357  if ( m_choice != index )
358  ThrowInvalidSelection(index);
359 }
360 
361 inline
362 void CRegion_pntrs_Base::C_Region::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
363 {
364  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
365  if ( m_choice != e_not_set )
366  ResetSelection();
367  DoSelect(index, pool);
368  }
369 }
370 
371 inline
373 {
374  Select(index, reset, 0);
375 }
376 
377 inline
379 {
380  return m_choice == e_Site;
381 }
382 
383 inline
385 {
386  CheckSelected(e_Site);
387  return *m_Site;
388 }
389 
390 inline
392 {
393  Select(e_Site, NCBI_NS_NCBI::eDoNotResetVariant);
394  return *m_Site;
395 }
396 
397 inline
399 {
400  return m_choice == e_Boundary;
401 }
402 
403 inline
405 {
406  CheckSelected(e_Boundary);
407  return *m_Boundary;
408 }
409 
410 inline
412 {
413  Select(e_Boundary, NCBI_NS_NCBI::eDoNotResetVariant);
414  return *m_Boundary;
415 }
416 
417 inline
419 {
420  return ((m_set_State[0] & 0x3) != 0);
421 }
422 
423 inline
425 {
426  return IsSetModel_id();
427 }
428 
429 inline
431 {
432  m_Model_id = CModel_id(0);
433  m_set_State[0] &= ~0x3;
434 }
435 
436 inline
438 {
439  if (!CanGetModel_id()) {
440  ThrowUnassigned(0);
441  }
442  return m_Model_id;
443 }
444 
445 inline
447 {
448  m_Model_id = value;
449  m_set_State[0] |= 0x3;
450 }
451 
452 inline
454 {
455  m_set_State[0] |= 0x1;
456  return m_Model_id;
457 }
458 
459 inline
461 {
462  return m_Region.NotEmpty();
463 }
464 
465 inline
467 {
468  return true;
469 }
470 
471 inline
473 {
474  if ( !m_Region ) {
475  const_cast<CRegion_pntrs_Base*>(this)->ResetRegion();
476  }
477  return (*m_Region);
478 }
479 
480 inline
482 {
483  if ( !m_Region ) {
484  ResetRegion();
485  }
486  return (*m_Region);
487 }
488 
489 ///////////////////////////////////////////////////////////
490 ////////////////// end of inline methods //////////////////
491 ///////////////////////////////////////////////////////////
492 
493 
494 
495 
496 
497 END_objects_SCOPE // namespace ncbi::objects::
498 
500 
501 
502 #endif // OBJECTS_MMDB3_REGION_PNTRS_BASE_HPP
User-defined methods of the data storage class.
CModel_id –.
Definition: Model_id.hpp:66
CRef –.
Definition: ncbiobj.hpp:618
CRegion_boundary –.
CRegion_coordinates –.
Region motifs describe features defined by spatial location, such as the site specified by a coordina...
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
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_MMDB3_EXPORT
Definition: ncbi_export.h:640
CRef< TRegion > m_Region
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
bool IsBoundary(void) const
Check if variant Boundary is selected.
void ResetModel_id(void)
Reset Model_id data member.
TSite & SetSite(void)
Select the variant.
void ResetRegion(void)
Reset Region data member.
const TRegion & GetRegion(void) const
Get the Region member data.
const TSite & GetSite(void) const
Get the variant data.
bool CanGetRegion(void) const
Check if it is safe to call GetRegion method.
bool CanGetModel_id(void) const
Check if it is safe to call GetModel_id method.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
TBoundary & SetBoundary(void)
Select the variant.
CSerialObject Tparent
CRegion_pntrs_Base(const CRegion_pntrs_Base &)
const TModel_id & GetModel_id(void) const
Get the Model_id member data.
E_Choice Which(void) const
Which variant is currently selected.
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
C_Region & operator=(const C_Region &)
bool IsSetRegion(void) const
Check if a value has been assigned to Region data member.
C_Region(const C_Region &)
TModel_id & SetModel_id(void)
Assign a value to Model_id data member.
bool IsSetModel_id(void) const
Check if a value has been assigned to Model_id data member.
Tparent::CMemberIndex< E_memberIndex, 3 > TmemberIndex
const TBoundary & GetBoundary(void) const
Get the variant data.
CRegion_pntrs_Base & operator=(const CRegion_pntrs_Base &)
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
list< CRef< CRegion_coordinates > > TSite
NCBI_NS_NCBI::CUnionBuffer< TSite > m_Site
NCBI_NS_NCBI::CUnionBuffer< TBoundary > m_Boundary
bool IsSite(void) const
Check if variant Site is selected.
list< CRef< CRegion_boundary > > TBoundary
TRegion & SetRegion(void)
Assign a value to Region data member.
@ e_not_set
Modified on Mon Feb 26 04:04:34 2024 by modify_doxy.py rev. 669887