1 #ifndef PSGS_GETPROCESSOR__HPP
2 #define PSGS_GETPROCESSOR__HPP
3 
4 /*  $Id: get_processor.hpp 629837 2021-04-22 12:47:49Z ivanov $
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: get processor
32  *
33  */
34 
35 #include "cass_blob_base.hpp"
36 #include "resolve_base.hpp"
37 
38 USING_NCBI_SCOPE;
39 USING_IDBLOB_SCOPE;
40 
41 // Forward declaration
42 class CCassFetch;
43 
44 
45 class CPSGS_GetProcessor : public CPSGS_ResolveBase,
46                            public CPSGS_CassBlobBase
47 {
48 public:
49     virtual IPSGS_Processor* CreateProcessor(shared_ptr<CPSGS_Request> request,
50                                              shared_ptr<CPSGS_Reply> reply,
51                                              TProcessorPriority  priority) const;
52     virtual void Process(void);
53     virtual void Cancel(void);
54     virtual EPSGS_Status GetStatus(void);
55     virtual string GetName(void) const;
56     virtual void ProcessEvent(void);
57 
58 public:
59     CPSGS_GetProcessor();
60     CPSGS_GetProcessor(shared_ptr<CPSGS_Request> request,
61                        shared_ptr<CPSGS_Reply> reply,
62                        TProcessorPriority  priority);
63     virtual ~CPSGS_GetProcessor();
64 
65 private:
66     void x_OnResolutionGoodData(void);
67     void x_OnSeqIdResolveError(
68                         CRequestStatus::ECode  status,
69                         int  code,
70                         EDiagSev  severity,
71                         const string &  message);
72     void x_OnSeqIdResolveFinished(
73                         SBioseqResolution &&  bioseq_resolution);
74     void x_SendBioseqInfo(SBioseqResolution &  bioseq_resolution);
75     void x_GetBlob(void);
76     bool x_IsExcludedBlob(void) const;
77 
78 private:
79     void OnGetBlobProp(CCassBlobFetch *  fetch_details,
80                        CBlobRecord const &  blob, bool is_found);
81     void OnGetBlobError(CCassBlobFetch *  fetch_details,
82                         CRequestStatus::ECode  status, int  code,
83                         EDiagSev  severity, const string &  message);
84     void OnGetBlobChunk(CCassBlobFetch *  fetch_details,
85                         CBlobRecord const &  blob,
86                         const unsigned char *  chunk_data,
87                         unsigned int  data_size, int  chunk_no);
88 
89 private:
90     void x_Peek(bool  need_wait);
91     bool x_Peek(unique_ptr<CCassFetch> &  fetch_details,
92                 bool  need_wait);
93 
94 private:
95     SPSGS_BlobBySeqIdRequest *      m_BlobRequest;
96     vector<SCass_BlobId>            m_ExcludeBlobs;
97 };
98 
99 #endif  // PSGS_GETPROCESSOR__HPP
100 
101