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

Go to the SVN repository for this file.

1 #ifndef ACC_VER_HIST_CALLBACK__HPP
2 #define ACC_VER_HIST_CALLBACK__HPP
3 
4 /* $Id: acc_ver_hist_callback.hpp 100131 2023-06-22 15:40:36Z satskyse $
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  * ===========================================================================
28  *
29  * Authors: Sergey Satskiy
30  *
31  * File Description:
32  *
33  */
34 
35 #include "http_daemon.hpp"
36 #include "pending_operation.hpp"
37 #include "cass_fetch.hpp"
38 
39 #include <functional>
40 
41 using TAccVerHistCB = function<
42  bool(SAccVerHistRec && acc_ver_hist_record,
43  bool last,
44  CCassAccVerHistoryFetch * fetch_details)>;
45 using TAccVerHistErrorCB = function<
46  void(CCassAccVerHistoryFetch * fetch_details,
47  CRequestStatus::ECode status,
48  int code,
49  EDiagSev severity,
50  const string & message)>;
51 
52 class IPSGS_Processor;
53 
54 
56 {
57  public:
59  IPSGS_Processor * processor,
60  TAccVerHistCB acc_ver_hist_cb,
61  CCassAccVerHistoryFetch * fetch_details) :
62  m_Processor(processor),
63  m_AccVerHistCB(acc_ver_hist_cb),
64  m_FetchDetails(fetch_details),
65  m_Count(0),
67  {}
68 
69  bool operator()(SAccVerHistRec && acc_ver_hist_record, bool last)
70  {
71  if (last) {
72  auto app = CPubseqGatewayApp::GetInstance();
73  if (m_Count == 0) {
74  app->GetTiming().Register(m_Processor, eAccVerHistRetrieve,
76  app->GetCounters().Increment(m_Processor,
78  } else {
79  app->GetTiming().Register(m_Processor, eAccVerHistRetrieve,
81  }
82  }
83 
84  ++m_Count;
85  return m_AccVerHistCB(move(acc_ver_hist_record), last, m_FetchDetails);
86  }
87 
88  private:
92 
93  size_t m_Count;
95 };
96 
97 
99 {
100  public:
102  TAccVerHistErrorCB error_cb,
103  CCassAccVerHistoryFetch * fetch_details) :
104  m_ErrorCB(error_cb),
105  m_FetchDetails(fetch_details)
106  {}
107 
109  int code,
110  EDiagSev severity,
111  const string & message)
112  {
113  m_ErrorCB(m_FetchDetails, status, code, severity, message);
114  }
115 
116  private:
119 };
120 
121 
122 #endif
function< void(CCassAccVerHistoryFetch *fetch_details, CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)> TAccVerHistErrorCB
function< bool(SAccVerHistRec &&acc_ver_hist_record, bool last, CCassAccVerHistoryFetch *fetch_details)> TAccVerHistCB
bool operator()(SAccVerHistRec &&acc_ver_hist_record, bool last)
CAccVerHistCallback(IPSGS_Processor *processor, TAccVerHistCB acc_ver_hist_cb, CCassAccVerHistoryFetch *fetch_details)
IPSGS_Processor * m_Processor
psg_time_point_t m_RetrieveTiming
CCassAccVerHistoryFetch * m_FetchDetails
CCassAccVerHistoryFetch * m_FetchDetails
CAccVerHistErrorCallback(TAccVerHistErrorCB error_cb, CCassAccVerHistoryFetch *fetch_details)
void operator()(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)
static CPubseqGatewayApp * GetInstance(void)
Interface class (and self-factory) for request processor objects that can retrieve data from a given ...
#define bool
Definition: bool.h:34
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:51
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
chrono::steady_clock psg_clock_t
psg_clock_t::time_point psg_time_point_t
Definition: inftrees.h:24
@ eOpStatusFound
Definition: timing.hpp:61
@ eOpStatusNotFound
Definition: timing.hpp:62
@ eAccVerHistRetrieve
Definition: timing.hpp:84
Modified on Mon Apr 22 04:05:43 2024 by modify_doxy.py rev. 669887