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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__IPG__FETCH_IPG_REPORT_HPP_
2 #define OBJTOOLS__PUBSEQ_GATEWAY__IPG__FETCH_IPG_REPORT_HPP_
3 /*****************************************************************************
4  * $Id: fetch_ipg_report.hpp 100309 2023-07-19 16:07:24Z saprykin $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * IPG storage library
28  *
29  *****************************************************************************/
30 
31 #include <corelib/ncbistd.hpp>
32 
33 #include <optional>
34 
38 
40 BEGIN_SCOPE(ipg)
42 
44 {
45  public:
51 
53  {
54  m_ProteinAccession = accession;
55  return *this;
56  }
57 
59  {
60  m_NucAccession = accession;
61  return *this;
62  }
63 
65  {
66  if (value > 0) {
67  m_Ipg = value;
68  }
69  else {
70  m_Ipg = nullopt;
71  }
72  return *this;
73  }
74 
76  {
77  m_ResolvedIpg = value;
78  return *this;
79  }
80 
81  TIpg GetIpg() const
82  {
83  if (m_Ipg) {
84  return m_Ipg.value();
85  }
86  return TIpg();
87  }
88 
89  string GetProtein() const
90  {
91  if (m_ProteinAccession) {
92  return m_ProteinAccession.value();
93  }
94  return {};
95  }
96 
97  string GetNucleotide() const
98  {
99  if (m_NucAccession) {
100  return m_NucAccession.value();
101  }
102  return {};
103  }
104 
106  {
107  if (m_ResolvedIpg) {
108  return m_ResolvedIpg.value();
109  }
110  return TIpg();
111  }
112 
114  {
115  if (m_Ipg) {
116  return m_Ipg.value();
117  }
118  if (m_ResolvedIpg) {
119  return m_ResolvedIpg.value();
120  }
121  return TIpg();
122  }
123 
124  bool HasIpg() const
125  {
126  return m_Ipg.has_value();
127  }
128 
129  bool HasProtein() const
130  {
131  return m_ProteinAccession.has_value();
132  }
133 
134  bool HasNucleotide() const
135  {
136  return m_NucAccession.has_value();
137  }
138 
139  bool HasResolvedIpg() const
140  {
141  return m_ResolvedIpg.has_value();
142  }
143 
145  {
146  return m_Ipg.has_value() || m_ResolvedIpg.has_value();
147  }
148 
149  private:
150  optional<TIpg> m_Ipg;
151  optional<string> m_ProteinAccession;
152  optional<string> m_NucAccession;
153  optional<TIpg> m_ResolvedIpg;
154 };
155 
157  : public CCassBlobWaiter
158 {
159  enum ETaskState {
169  };
170 
171  const static size_t kReadBufferReserveDefault;
172 
173 public:
175  shared_ptr<CCassConnection> connection,
176  const string & keyspace,
179  TDataErrorCallback data_error_cb,
180  bool async = true
181  );
183 
186 
189 
190  void SetDataReadyCB(shared_ptr<CCassDataCallbackReceiver> callback);
192 
193  void SetConsistency(CassConsistency value);
194  void SetPageSize(unsigned int value);
195 
196  unsigned int GetPageSize() const
197  {
198  return m_PageSize;
199  }
200 
202  {
203  return m_Request;
204  }
205 
206  // For testing only
208  {
209  return m_Subgroups;
210  }
211 
212  // For testing only
214  {
216  }
217 
218 private:
219  void Wait1() override;
220 
226 
227  vector<CIpgStorageReportEntry> m_Container;
230 
231  CassConsistency m_Consistency{CassConsistency::CASS_CONSISTENCY_LOCAL_QUORUM};
233  unsigned int m_RestartCounter{0};
234 };
235 
236 END_SCOPE(ipg)
238 
239 #endif // OBJTOOLS__PUBSEQ_GATEWAY__IPG__FETCH_IPG_REPORT_HPP_
function< void(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)> TDataErrorCallback
static const unsigned int DEFAULT_PAGE_SIZE
CPubseqGatewayFetchIpgReportRequest & SetNucleotide(string const &accession)
CPubseqGatewayFetchIpgReportRequest & operator=(CPubseqGatewayFetchIpgReportRequest const &)=default
CPubseqGatewayFetchIpgReportRequest(CPubseqGatewayFetchIpgReportRequest &&)=default
CPubseqGatewayFetchIpgReportRequest & operator=(CPubseqGatewayFetchIpgReportRequest &&)=default
CPubseqGatewayFetchIpgReportRequest(CPubseqGatewayFetchIpgReportRequest const &)=default
CPubseqGatewayFetchIpgReportRequest & SetIpg(TIpg value)
CPubseqGatewayFetchIpgReportRequest & SetProtein(string const &accession)
CPubseqGatewayFetchIpgReportRequest & SetResolvedIpg(TIpg value)
CPubseqGatewayFetchIpgReportRequest GetRequest() const
void SetConsumeCallback(CPubseqGatewayIpgReportConsumeCallback callback)
CPubseqGatewayIpgReportConsumeCallback m_ConsumeCallback
void SetPageSize(unsigned int value)
vector< CIpgStorageReportEntry > m_Container
static const size_t kReadBufferReserveDefault
CPubseqGatewayFetchIpgReport & operator=(CPubseqGatewayFetchIpgReport &&)=default
void SetSubgrupsStatusOverride(EIpgSubgroupsStatus value)
unsigned int GetPageSize() const
CPubseqGatewayFetchIpgReport & operator=(const CPubseqGatewayFetchIpgReport &)=delete
CPubseqGatewayFetchIpgReport(CPubseqGatewayFetchIpgReport &&)=default
CPubseqGatewayFetchIpgReport(shared_ptr< CCassConnection > connection, const string &keyspace, CPubseqGatewayFetchIpgReportRequest const &request, CPubseqGatewayIpgReportConsumeCallback consume_callback, TDataErrorCallback data_error_cb, bool async=true)
CPubseqGatewayFetchIpgReportRequest m_Request
EIpgSubgroupsStatus m_SubgroupsStatusOverride
void SetDataReadyCB(shared_ptr< CCassDataCallbackReceiver > callback)
SIpgSubgroupsConfig::TCIterator m_SubgroupItr
CPubseqGatewayFetchIpgReport(const CPubseqGatewayFetchIpgReport &)=delete
void SetConsistency(CassConsistency value)
SIpgSubgroupsConfig GetSubgroupsConfig() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
USING_IDBLOB_SCOPE
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
function< bool(vector< CIpgStorageReportEntry > &&, bool is_last)> CPubseqGatewayIpgReportConsumeCallback
EIpgSubgroupsStatus
Definition: ipg_types.hpp:65
Int8 TIpg
Definition: ipg_types.hpp:43
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
vector< int32_t >::const_iterator TCIterator
Definition: ipg_types.hpp:75
Modified on Wed Sep 04 15:03:40 2024 by modify_doxy.py rev. 669887