NCBI C++ ToolKit
SeqTable_sparse_index_.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 SeqTable_sparse_index_.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/seqtable/seqtable.asn">seqtable.asn</a>
34 /// and additional tune-up parameters:
35 /// <a href="/IEB/ToolBox/CPP_DOC/lxr/source/src/objects/seqtable/seqtable.def">seqtable.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_SEQTABLE_SEQTABLE_SPARSE_INDEX_BASE_HPP
42 #define OBJECTS_SEQTABLE_SEQTABLE_SPARSE_INDEX_BASE_HPP
43 
44 // standard includes
45 #include <serial/serialbase.hpp>
46 
47 // generated includes
48 #include <vector>
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 CBVector_data;
61 
62 
63 // generated classes
64 
65 
66 /** @addtogroup dataspec_NCBI_SeqTable
67  *
68  * @{
69  */
70 
71 /////////////////////////////////////////////////////////////////////////////
72 ///
73 /// CSeqTable_sparse_index_Base --
74 ///
75 
77 {
79 public:
80  // constructor
82  // destructor
83  virtual ~CSeqTable_sparse_index_Base(void);
84 
85  // type info
87 
88 
89  /// Choice variants.
90  enum E_Choice {
91  e_not_set = 0, ///< No variant selected
92  e_Indexes, ///< Indexes of rows with values
93  e_Bit_set, ///< Bitset of rows with values, set bit means the row has value. Most-significant bit in each octet comes first.
94  e_Indexes_delta, ///< Indexes of rows with values, delta-encoded
95  e_Bit_set_bvector ///< Bitset of rows with values, as serialized bvector<>, see include/util/bitset/bm.h
96  };
97  /// Maximum+1 value of the choice variant enumerator.
99  e_MaxChoice = 5 ///< == e_Bit_set_bvector+1
100  };
101 
102  /// Reset the whole object
103  virtual void Reset(void);
104 
105  /// Reset the selection (set it to e_not_set).
106  virtual void ResetSelection(void);
107 
108  /// Which variant is currently selected.
109  ///
110  /// @return
111  /// Choice state enumerator.
112  E_Choice Which(void) const;
113 
114  /// Verify selection, throw exception if it differs from the expected.
115  ///
116  /// @param index
117  /// Expected selection.
118  void CheckSelected(E_Choice index) const;
119 
120  /// Throw 'InvalidSelection' exception.
121  ///
122  /// @param index
123  /// Expected selection.
124  NCBI_NORETURN void ThrowInvalidSelection(E_Choice index) const;
125 
126  /// Retrieve selection name (for diagnostic purposes).
127  ///
128  /// @param index
129  /// One of possible selection states.
130  /// @return
131  /// Name string.
132  static string SelectionName(E_Choice index);
133 
134  /// Select the requested variant if needed.
135  ///
136  /// @param index
137  /// New selection state.
138  /// @param reset
139  /// Flag that defines the resetting of the variant data. The data will
140  /// be reset if either the current selection differs from the new one,
141  /// or the flag is set to eDoResetVariant.
143  /// Select the requested variant if needed,
144  /// allocating CObject variants from memory pool.
145  void Select(E_Choice index,
146  EResetVariant reset,
147  CObjectMemoryPool* pool);
148 
149  // types
150  typedef vector< unsigned > TIndexes;
151  typedef vector< char > TBit_set;
152  typedef vector< unsigned > TIndexes_delta;
154 
155  // getters
156  // setters
157 
158 
159  /// Check if variant Indexes is selected.
160  ///
161  /// Indexes type is defined as 'typedef vector< unsigned > TIndexes'.
162  /// @return
163  /// - true, if the variant is selected.
164  /// - false, otherwise.
165  bool IsIndexes(void) const;
166 
167  /// Get the variant data.
168  ///
169  /// @return
170  /// Reference to the data.
171  const TIndexes& GetIndexes(void) const;
172 
173  /// Select the variant.
174  ///
175  /// @return
176  /// Reference to the variant data.
177  TIndexes& SetIndexes(void);
178 
179 
180  /// Check if variant Bit_set is selected.
181  ///
182  /// Bit_set type is defined as 'typedef vector< char > TBit_set'.
183  /// @return
184  /// - true, if the variant is selected.
185  /// - false, otherwise.
186  bool IsBit_set(void) const;
187 
188  /// Get the variant data.
189  ///
190  /// @return
191  /// Reference to the data.
192  const TBit_set& GetBit_set(void) const;
193 
194  /// Select the variant.
195  ///
196  /// @return
197  /// Reference to the variant data.
198  TBit_set& SetBit_set(void);
199 
200 
201  /// Check if variant Indexes_delta is selected.
202  ///
203  /// Indexes_delta type is defined as 'typedef vector< unsigned > TIndexes_delta'.
204  /// @return
205  /// - true, if the variant is selected.
206  /// - false, otherwise.
207  bool IsIndexes_delta(void) const;
208 
209  /// Get the variant data.
210  ///
211  /// @return
212  /// Reference to the data.
213  const TIndexes_delta& GetIndexes_delta(void) const;
214 
215  /// Select the variant.
216  ///
217  /// @return
218  /// Reference to the variant data.
219  TIndexes_delta& SetIndexes_delta(void);
220 
221 
222  /// Check if variant Bit_set_bvector is selected.
223  ///
224  /// Bit_set_bvector type is defined as 'typedef CBVector_data TBit_set_bvector'.
225  /// @return
226  /// - true, if the variant is selected.
227  /// - false, otherwise.
228  bool IsBit_set_bvector(void) const;
229 
230  /// Get the variant data.
231  ///
232  /// @return
233  /// Reference to the data.
234  const TBit_set_bvector& GetBit_set_bvector(void) const;
235 
236  /// Select the variant.
237  ///
238  /// @return
239  /// Reference to the variant data.
240  TBit_set_bvector& SetBit_set_bvector(void);
241  /// Select the variant and set its data.
242  ///
243  /// @param value
244  /// Reference to the data.
245  void SetBit_set_bvector(TBit_set_bvector& value);
246 
247 
248 private:
249  // copy constructor and assignment operator
252  // choice state
254  // helper methods
255  void DoSelect(E_Choice index, CObjectMemoryPool* pool = 0);
256 
257  static const char* const sm_SelectionNames[];
258  // data
259  union {
260  NCBI_NS_NCBI::CUnionBuffer<TIndexes> m_Indexes;
261  NCBI_NS_NCBI::CUnionBuffer<TBit_set> m_Bit_set;
262  NCBI_NS_NCBI::CUnionBuffer<TIndexes_delta> m_Indexes_delta;
263  NCBI_NS_NCBI::CSerialObject *m_object;
264  };
265 };
266 
267 /* @} */
268 
269 
270 
271 
272 
273 ///////////////////////////////////////////////////////////
274 ///////////////////// inline methods //////////////////////
275 ///////////////////////////////////////////////////////////
276 inline
278 {
279  return m_choice;
280 }
281 
282 inline
284 {
285  if ( m_choice != index )
286  ThrowInvalidSelection(index);
287 }
288 
289 inline
290 void CSeqTable_sparse_index_Base::Select(E_Choice index, NCBI_NS_NCBI::EResetVariant reset, NCBI_NS_NCBI::CObjectMemoryPool* pool)
291 {
292  if ( reset == NCBI_NS_NCBI::eDoResetVariant || m_choice != index ) {
293  if ( m_choice != e_not_set )
294  ResetSelection();
295  DoSelect(index, pool);
296  }
297 }
298 
299 inline
301 {
302  Select(index, reset, 0);
303 }
304 
305 inline
307 {
308  return m_choice == e_Indexes;
309 }
310 
311 inline
313 {
315  return *m_Indexes;
316 }
317 
318 inline
320 {
322  return *m_Indexes;
323 }
324 
325 inline
327 {
328  return m_choice == e_Bit_set;
329 }
330 
331 inline
333 {
335  return *m_Bit_set;
336 }
337 
338 inline
340 {
342  return *m_Bit_set;
343 }
344 
345 inline
347 {
348  return m_choice == e_Indexes_delta;
349 }
350 
351 inline
353 {
355  return *m_Indexes_delta;
356 }
357 
358 inline
360 {
362  return *m_Indexes_delta;
363 }
364 
365 inline
367 {
368  return m_choice == e_Bit_set_bvector;
369 }
370 
371 ///////////////////////////////////////////////////////////
372 ////////////////// end of inline methods //////////////////
373 ///////////////////////////////////////////////////////////
374 
375 
376 
377 
378 
379 END_objects_SCOPE // namespace ncbi::objects::
380 
382 
383 
384 #endif // OBJECTS_SEQTABLE_SEQTABLE_SPARSE_INDEX_BASE_HPP
CSeqTable_sparse_index_Base –.
Base class for all serializable objects.
Definition: serialbase.hpp:150
char value[7]
Definition: config.c:431
EResetVariant
Definition: serialbase.hpp:76
@ eDoResetVariant
Definition: serialbase.hpp:77
@ eDoNotResetVariant
Definition: serialbase.hpp:78
#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_SEQ_EXPORT
Definition: ncbi_export.h:825
virtual void ResetSelection(void)
Reset the selection (set it to e_not_set).
NCBI_NS_NCBI::CUnionBuffer< TIndexes_delta > m_Indexes_delta
void CheckSelected(E_Choice index) const
Verify selection, throw exception if it differs from the expected.
bool IsBit_set_bvector(void) const
Check if variant Bit_set_bvector is selected.
NCBI_NS_NCBI::CUnionBuffer< TIndexes > m_Indexes
E_Choice Which(void) const
Which variant is currently selected.
CSeqTable_sparse_index_Base(const CSeqTable_sparse_index_Base &)
const TIndexes & GetIndexes(void) const
Get the variant data.
E_ChoiceStopper
Maximum+1 value of the choice variant enumerator.
TBit_set & SetBit_set(void)
Select the variant.
NCBI_NS_NCBI::CUnionBuffer< TBit_set > m_Bit_set
TIndexes_delta & SetIndexes_delta(void)
Select the variant.
TIndexes & SetIndexes(void)
Select the variant.
void DoSelect(E_Choice index, CObjectMemoryPool *pool=0)
bool IsIndexes_delta(void) const
Check if variant Indexes_delta is selected.
const TBit_set & GetBit_set(void) const
Get the variant data.
NCBI_NS_NCBI::CUnionBuffer< TIndexes > m_Indexes
NCBI_NS_NCBI::CUnionBuffer< TIndexes_delta > m_Indexes_delta
bool IsBit_set(void) const
Check if variant Bit_set is selected.
NCBI_NS_NCBI::CSerialObject * m_object
CSeqTable_sparse_index_Base & operator=(const CSeqTable_sparse_index_Base &)
const TIndexes_delta & GetIndexes_delta(void) const
Get the variant data.
NCBI_NS_NCBI::CUnionBuffer< TBit_set > m_Bit_set
void Select(E_Choice index, EResetVariant reset=eDoResetVariant)
Select the requested variant if needed.
void ThrowInvalidSelection(E_Choice index) const
Throw 'InvalidSelection' exception.
void Select(E_Choice index, EResetVariant reset, CObjectMemoryPool *pool)
Select the requested variant if needed, allocating CObject variants from memory pool.
bool IsIndexes(void) const
Check if variant Indexes is selected.
@ e_Bit_set
Bitset of rows with values, set bit means the row has value. Most-significant bit in each octet comes...
@ e_Bit_set_bvector
Bitset of rows with values, as serialized bvector<>, see include/util/bitset/bm.h.
@ e_Indexes_delta
Indexes of rows with values, delta-encoded.
@ e_Indexes
Indexes of rows with values.
@ e_not_set
Modified on Thu Dec 07 10:12:16 2023 by modify_doxy.py rev. 669887