1 /*****************************************************************************
2  *  $Id: record.hpp 611109 2020-06-29 16:34:42Z saprykin $
3  * ===========================================================================
4  *
5  *                            PUBLIC DOMAIN NOTICE
6  *               National Center for Biotechnology Information
7  *
8  *  This software/database is a "United States Government Work" under the
9  *  terms of the United States Copyright Act.  It was written as part of
10  *  the author's official duties as a United States Government employee and
11  *  thus cannot be copyrighted.  This software/database is freely available
12  *  to the public for use. The National Library of Medicine and the U.S.
13  *  Government have not placed any restriction on its use or reproduction.
14  *
15  *  Although all reasonable efforts have been taken to ensure the accuracy
16  *  and reliability of the software and data, the NLM and the U.S.
17  *  Government do not and cannot warrant the performance or results that
18  *  may be obtained by using this software or data. The NLM and the U.S.
19  *  Government disclaim all warranties, express or implied, including
20  *  warranties of performance, merchantability or fitness for any particular
21  *  purpose.
22  *
23  *  Please cite the author in any work or product based on this material.
24  *
25  *  Blob storage: bioseq_info record
26  *
27  *****************************************************************************/
28 
29 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__BIOSEQ_INFO__RECORD_HPP
30 #define OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__BIOSEQ_INFO__RECORD_HPP
31 
32 #include <corelib/ncbistd.hpp>
33 #include <corelib/request_status.hpp>
34 
35 #include <algorithm>
36 #include <memory>
37 #include <set>
38 #include <string>
39 #include <tuple>
40 #include <utility>
41 #include <vector>
42 
43 #include <objtools/pubseq_gateway/impl/cassandra/IdCassScope.hpp>
44 
45 BEGIN_IDBLOB_SCOPE
46 USING_NCBI_SCOPE;
47 
48 class CBioseqInfoRecord
49 {
50  public:
51     using TAccession = string;
52     using TName = string;
53     using TVersion = int16_t;
54     using TSeqIdType = int16_t;
55     using TDateChanged = int64_t;
56     using THash = int32_t;
57     using TGI = int64_t;
58     using TLength = int32_t;
59     using TMol = int8_t;
60     using TSat = int16_t;
61     using TSatKey = int32_t;
62     using TSeqIds = set<tuple<int16_t, string>>;
63     using TSeqState = int8_t;
64     using TState = int8_t;
65     using TTaxId = int32_t;
66     using TWritetime = int64_t;
67 
68     static const TState kStateAlive = 10;
69 
70  public:
CBioseqInfoRecord()71     CBioseqInfoRecord()
72         : m_Version(-1)
73         , m_SeqIdType(-1)
74         , m_GI(-1)
75         , m_DateChanged(0)
76         , m_Hash(-1)
77         , m_Length(-1)
78         , m_Mol(-1)
79         , m_Sat(-1)
80         , m_SatKey(-1)
81         , m_SeqState(-1)
82         , m_State(-1)
83         , m_TaxId(-1)
84         , m_Writetime(-1)
85     {}
86 
87     void Reset(void);
88 
89     CBioseqInfoRecord(CBioseqInfoRecord const &) = default;
90     CBioseqInfoRecord & operator=(CBioseqInfoRecord const &) = default;
91     CBioseqInfoRecord & operator=(CBioseqInfoRecord &&) = default;
92 
93     // Setters
SetAccession(const TAccession & value)94     CBioseqInfoRecord & SetAccession(const TAccession &  value)
95     {
96         m_Accession = value;
97         return *this;
98     }
99 
SetVersion(TVersion value)100     CBioseqInfoRecord & SetVersion(TVersion  value)
101     {
102         m_Version = value;
103         return *this;
104     }
105 
SetSeqIdType(TSeqIdType value)106     CBioseqInfoRecord & SetSeqIdType(TSeqIdType  value)
107     {
108         m_SeqIdType = value;
109         return *this;
110     }
111 
SetDateChanged(TDateChanged value)112     CBioseqInfoRecord & SetDateChanged(TDateChanged  value)
113     {
114         m_DateChanged = value;
115         return *this;
116     }
117 
SetHash(THash value)118     CBioseqInfoRecord & SetHash(THash  value)
119     {
120         m_Hash = value;
121         return *this;
122     }
123 
SetGI(TGI value)124     CBioseqInfoRecord & SetGI(TGI value)
125     {
126         m_GI = value;
127         return *this;
128     }
129 
SetLength(TLength value)130     CBioseqInfoRecord & SetLength(TLength  value)
131     {
132         m_Length = value;
133         return *this;
134     }
135 
SetMol(TMol value)136     CBioseqInfoRecord & SetMol(TMol  value)
137     {
138         m_Mol = value;
139         return *this;
140     }
141 
SetSat(TSat value)142     CBioseqInfoRecord & SetSat(TSat  value)
143     {
144         m_Sat = value;
145         return *this;
146     }
147 
SetSatKey(TSatKey value)148     CBioseqInfoRecord & SetSatKey(TSatKey  value)
149     {
150         m_SatKey = value;
151         return *this;
152     }
153 
SetSeqIds(TSeqIds const & value)154     CBioseqInfoRecord & SetSeqIds(TSeqIds const &  value)
155     {
156         m_SeqIds = value;
157         return *this;
158     }
159 
SetSeqIds(TSeqIds && value)160     CBioseqInfoRecord & SetSeqIds(TSeqIds&& value)
161     {
162         m_SeqIds = move(value);
163         return *this;
164     }
165 
SetSeqState(TSeqState value)166     CBioseqInfoRecord & SetSeqState(TSeqState  value)
167     {
168         m_SeqState = value;
169         return *this;
170     }
171 
SetState(TState value)172     CBioseqInfoRecord & SetState(TState  value)
173     {
174         m_State = value;
175         return *this;
176     }
177 
SetTaxId(TTaxId value)178     CBioseqInfoRecord & SetTaxId(TTaxId  value)
179     {
180         m_TaxId = value;
181         return *this;
182     }
183 
SetName(TName value)184     CBioseqInfoRecord & SetName(TName  value)
185     {
186         m_Name = value;
187         return *this;
188     }
189 
SetWritetime(TWritetime value)190     CBioseqInfoRecord & SetWritetime(TWritetime  value)
191     {
192         m_Writetime = value;
193         return *this;
194     }
195 
196 
197     // Getters
GetAccession(void) const198     TAccession const & GetAccession(void) const
199     {
200         return m_Accession;
201     }
202 
GetVersion(void) const203     TVersion  GetVersion(void) const
204     {
205         return m_Version;
206     }
207 
GetSeqIdType(void) const208     TSeqIdType GetSeqIdType(void) const
209     {
210         return m_SeqIdType;
211     }
212 
GetDateChanged(void) const213     TDateChanged GetDateChanged(void) const
214     {
215         return m_DateChanged;
216     }
217 
GetHash(void) const218     THash GetHash(void) const
219     {
220         return m_Hash;
221     }
222 
GetGI(void) const223     TGI GetGI(void) const
224     {
225         return m_GI;
226     }
227 
GetLength(void) const228     TLength GetLength(void) const
229     {
230         return m_Length;
231     }
232 
GetMol(void) const233     TMol GetMol(void) const
234     {
235         return m_Mol;
236     }
237 
GetSat(void) const238     TSat GetSat(void) const
239     {
240         return m_Sat;
241     }
242 
GetSatKey(void) const243     TSatKey GetSatKey(void) const
244     {
245         return m_SatKey;
246     }
247 
GetSeqIds(void)248     TSeqIds & GetSeqIds(void)
249     {
250         return m_SeqIds;
251     }
252 
GetSeqIds(void) const253     TSeqIds const & GetSeqIds(void) const
254     {
255         return m_SeqIds;
256     }
257 
GetSeqState(void) const258     TSeqState GetSeqState(void) const
259     {
260         return m_SeqState;
261     }
262 
GetState(void) const263     TState GetState(void) const
264     {
265         return m_State;
266     }
267 
GetTaxId(void) const268     TTaxId GetTaxId(void) const
269     {
270         return m_TaxId;
271     }
272 
GetName(void) const273     TName GetName(void) const
274     {
275         return m_Name;
276     }
277 
GetWritetime(void) const278     TWritetime GetWritetime(void) const
279     {
280         return m_Writetime;
281     }
282 
283     string ToString(void) const;
284 
285  private:
286     TAccession m_Accession;
287     TVersion m_Version;
288     TSeqIdType m_SeqIdType;
289     TGI m_GI;
290 
291     TName               m_Name;
292     TDateChanged        m_DateChanged;
293     THash               m_Hash;
294     TLength             m_Length;
295     TMol                m_Mol;
296     TSat                m_Sat;
297     TSatKey             m_SatKey;
298     TSeqIds             m_SeqIds;
299     TSeqState           m_SeqState;
300     TState              m_State;
301     TTaxId              m_TaxId;
302     TWritetime          m_Writetime;
303 };
304 
305 using TBioseqInfoConsumeCallback = function<void(vector<CBioseqInfoRecord> &&)>;
306 
307 END_IDBLOB_SCOPE
308 
309 #endif  // OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__BIOSEQ_INFO__RECORD_HPP
310