NCBI C++ ToolKit
SeqTable_multi_data.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: SeqTable_multi_data.hpp 66087 2015-01-29 19:26:03Z vasilche $
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_multi_data.hpp
29 /// User-defined methods of the data storage class.
30 ///
31 /// This file was originally generated by application DATATOOL
32 /// using the following specifications:
33 /// 'seqtable.asn'.
34 ///
35 /// New methods or data members can be added to it if needed.
36 /// See also: SeqTable_multi_data_.hpp
37 
38 
39 #ifndef OBJECTS_SEQTABLE_SEQTABLE_MULTI_DATA_HPP
40 #define OBJECTS_SEQTABLE_SEQTABLE_MULTI_DATA_HPP
41 
42 
43 // generated includes
45 
46 #include <serial/objhook.hpp>
47 
48 // generated classes
49 
51 
52 BEGIN_objects_SCOPE // namespace ncbi::objects::
53 
54 
55 class CIntDeltaSumCache;
56 
57 
58 /////////////////////////////////////////////////////////////////////////////
60 {
62 public:
63  // constructor
65  // destructor
66  ~CSeqTable_multi_data(void);
67 
68  size_t GetSize(void) const;
69 
70  // return true if there is a value at the row
71  bool IsSet(size_t row_index) const {
72  return row_index < GetSize();
73  }
74 
75  // return equivalent simpler variant:
76  // e_Bit - bool
77  // e_Int - any integer that fits in Int4
78  // e_Int8 - integer that fits in Int8
79  // e_Real - floating point value
80  // e_String - string
81  // e_Bytes - char/byte vector
82  // e_Loc - CSeq_loc
83  // e_Id - CSeq_id
84  // e_Interval - CSeq_interval
85  // e_notset - no data
86  E_Choice GetValueType(void) const;
87 
88  // return true if the value is convertible to integer value (any size).
89  // Bool, Int, Int1, Int2, Int8 are all integer types.
90  // This includes special representations:
91  // bvector for 1-bit values, scaled integers, delta encoding.
92  bool CanGetInt(void) const;
93 
94  // return true if the value is convertible to double value.
95  // This includes special representation: scaled values.
96  bool CanGetReal(void) const;
97 
98  // return size (sizeof) of integer value to store data from any row,
99  // or zero if the data is not convertible to integer value.
100  // Bool, Int, Int1, Int2, Int8 are all integer types.
101  // This includes special representations:
102  // bvector for 1-bit values, scaled integers, delta encoding.
103  size_t GetIntSize(void) const;
104 
105  // get bool value for the row, return false if there is no a value
106  bool TryGetBool(size_t row, bool& v) const;
107 
108  // get double value for the row, return false if there is no a value
109  bool TryGetReal(size_t row, double& v) const;
110 
111  // get Int1 value for the row, return false if there is no a value
112  bool TryGetInt1(size_t row, Int1& v) const;
113  bool TryGetInt1WithRounding(size_t row, Int1& v) const;
114  // get Int2 value for the row, return false if there is no a value
115  bool TryGetInt2(size_t row, Int2& v) const;
116  bool TryGetInt2WithRounding(size_t row, Int2& v) const;
117  // get Int4 value for the row, return false if there is no a value
118  bool TryGetInt4(size_t row, Int4& v) const;
119  bool TryGetInt4WithRounding(size_t row, Int4& v) const;
120  // get Int8 value for the row, return false if there is no a value
121  bool TryGetInt8(size_t row, Int8& v) const;
122  bool TryGetInt8WithRounding(size_t row, Int8& v) const;
123 
124  // for plain int (=Int4)
125  bool TryGetInt(size_t row, int& v) const {
126  return TryGetInt4(row, v);
127  }
128  bool TryGetIntWithRounding(size_t row, int& v) const {
129  return TryGetInt4WithRounding(row, v);
130  }
131 
132  // get pointer to a string value for the row, or null if there is none
133  const string* GetStringPtr(size_t row) const;
134  // get pointer to a byte vector value for the row, or null if there is none
135  typedef vector<char> TBytesValue;
136  const TBytesValue* GetBytesPtr(size_t row) const;
137 
138  // overloaded methods for use in templates
139  bool TryGetValue(size_t row, Int1& v) const {
140  return TryGetInt1(row, v);
141  }
142  bool TryGetValue(size_t row, Int2& v) const {
143  return TryGetInt2(row, v);
144  }
145  bool TryGetValue(size_t row, Int4& v) const {
146  return TryGetInt4(row, v);
147  }
148  bool TryGetValue(size_t row, Int8& v) const {
149  return TryGetInt8(row, v);
150  }
151  bool TryGetValue(size_t row, bool& v) const {
152  return TryGetBool(row, v);
153  }
154  bool TryGetValue(size_t row, double& v) const {
155  return TryGetReal(row, v);
156  }
157  bool TryGetValue(size_t row, string& v) const {
158  if ( const string* ptr = GetStringPtr(row) ) {
159  v = *ptr;
160  return true;
161  }
162  return false;
163  }
164  bool TryGetValue(size_t row, TBytesValue& v) const {
165  if ( const TBytesValue* ptr = GetBytesPtr(row) ) {
166  v = *ptr;
167  return true;
168  }
169  return false;
170  }
171 
172  // reserve memory for multi-row data vectors
174  {
175  virtual void PreReadChoiceVariant(CObjectIStream& in,
176  const CObjectInfoCV& variant);
177  };
178 
179  // change the representation of data
180  void ChangeTo(E_Choice type);
181  void ChangeToBit(void); // convert int data with values 0/1 to bits
182  void ChangeToBit_bvector(void);
183  void ChangeToInt1(void);
184  void ChangeToInt2(void);
185  void ChangeToInt4(void);
186  void ChangeToInt8(void);
187  void ChangeToInt(void) {
188  ChangeToInt4();
189  }
190  void ChangeToInt_delta(void);
191  void ChangeToInt_scaled(int mul, int add);
192  void ChangeToReal(void);
193  void ChangeToReal_scaled(double mul, double add);
194  void ChangeToString(const string* omitted_value = 0);
195  void ChangeToCommon_string(const string* omit_value = 0);
196  void ChangeToBytes(const TBytesValue* omitted_value = 0);
197  void ChangeToCommon_bytes(const TBytesValue* omit_value = 0);
198 
199  // Overload base ResetSelection() to reset extra data fields
200  void ResetSelection(void) {
201  x_ResetCache();
202  Tparent::ResetSelection();
203  }
204 
205  void PostRead(void) {
206  x_ResetCache();
207  }
208 
209 protected:
210 
211  bool x_TryGetInt8(size_t row, Int8& v, const char* type_name) const;
212 
213  void x_ResetCache(void);
214 
215  CIntDeltaSumCache& x_GetIntDeltaCache(void) const;
216 
218 
219 private:
220  // Prohibit copy constructor and assignment operator
223 
224 };
225 
226 /////////////////// CSeqTable_multi_data inline methods
227 
228 /////////////////// end of CSeqTable_multi_data inline methods
229 
230 
233 
235 
236 
237 END_objects_SCOPE // namespace ncbi::objects::
238 
240 
241 
242 #endif // OBJECTS_SEQTABLE_SEQTABLE_MULTI_DATA_HPP
Data storage class.
CObjectIStream –.
Definition: objistr.hpp:93
CObjectInfoCV –.
Definition: objectiter.hpp:588
Read hook for a choice variant (CHOICE)
Definition: objhook.hpp:134
CSeqTable_multi_data_Base –.
bool TryGetValue(size_t row, Int8 &v) const
void ResetSelection(void)
Reset the selection (set it to e_not_set).
bool TryGetInt(size_t row, int &v) const
bool TryGetValue(size_t row, bool &v) const
bool TryGetValue(size_t row, double &v) const
CSeqTable_multi_data(const CSeqTable_multi_data &value)
bool TryGetValue(size_t row, Int4 &v) const
CRef< CIntDeltaSumCache > m_Cache
bool TryGetIntWithRounding(size_t row, int &v) const
bool TryGetValue(size_t row, TBytesValue &v) const
bool TryGetValue(size_t row, Int1 &v) const
bool TryGetValue(size_t row, Int2 &v) const
bool TryGetValue(size_t row, string &v) const
bool IsSet(size_t row_index) const
CSeqTable_multi_data_Base Tparent
CSeqTable_multi_data & operator=(const CSeqTable_multi_data &value)
#define NCBISER_HAVE_GLOBAL_READ_VARIANT_HOOK(Class, Name, Hook)
Definition: serialbase.hpp:979
#define NCBISER_HAVE_POST_READ(Class)
Definition: serialbase.hpp:943
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
int8_t Int1
1-byte (8-bit) signed integer
Definition: ncbitype.h:98
#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
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
std::istream & in(std::istream &in_, double &x_)
#define row(bind, expected)
Definition: string_bind.c:73
Definition: type.c:6
static const char * type_name(CS_INT value)
Definition: will_convert.c:122
Modified on Sun Apr 21 03:40:46 2024 by modify_doxy.py rev. 669887