1 #ifndef PSGS_OSGCALLER__HPP 2 #define PSGS_OSGCALLER__HPP 3 4 /* $Id: osg_caller.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: Eugene Vasilchenko 30 * 31 * File Description: class for communication with OSG 32 * 33 */ 34 35 #include <corelib/ncbiobj.hpp> 36 #include <vector> 37 38 BEGIN_NCBI_NAMESPACE; 39 40 class CRequestContext; 41 42 BEGIN_NAMESPACE(objects); 43 44 class CID2_Request; 45 class CID2_Request_Packet; 46 class CID2_Reply; 47 48 END_NAMESPACE(objects); 49 50 BEGIN_NAMESPACE(psg); 51 BEGIN_NAMESPACE(osg); 52 53 class COSGConnectionPool; 54 class COSGConnection; 55 class COSGFetch; 56 class CPSGS_OSGProcessorBase; 57 58 USING_SCOPE(objects); 59 60 61 class COSGCaller : public CObject 62 { 63 public: 64 typedef vector<CRef<COSGFetch>> TFetches; 65 66 COSGCaller(); 67 explicit COSGCaller(const CRef<COSGConnectionPool>& connection_pool, 68 const CRef<CRequestContext>& context, 69 const TFetches& fetches); 70 virtual ~COSGCaller(); 71 72 void AllocateConnection(const CRef<COSGConnectionPool>& connection_pool, 73 const CRef<CRequestContext>& context); 74 void SendRequest(CPSGS_OSGProcessorBase& processor); 75 void WaitForReplies(CPSGS_OSGProcessorBase& processor); 76 GetRequestPacket() const77 const CID2_Request_Packet& GetRequestPacket() const 78 { 79 return *m_RequestPacket; 80 } 81 82 protected: GetConnection() const83 const CRef<COSGConnection>& GetConnection() const 84 { 85 return m_Connection; 86 } 87 88 CRef<CID2_Request> MakeInitRequest(); 89 void SetContext(CID2_Request& req, const CRef<COSGFetch>& fetch); 90 void AddFetch(CID2_Request_Packet& packet, const CRef<COSGFetch>& fetch); 91 CRef<CID2_Request_Packet> MakePacket(const TFetches& fetches); 92 size_t GetRequestIndex(const CID2_Reply& reply) const; 93 94 bool EndOfReplies(const CID2_Reply& reply) const; 95 bool EndOfReplies(size_t index) const; 96 97 private: 98 CRef<COSGConnectionPool> m_ConnectionPool; 99 CRef<COSGConnection> m_Connection; 100 CRef<CRequestContext> m_Context; 101 CRef<CID2_Request_Packet> m_RequestPacket; 102 vector<CRef<COSGFetch>> m_Fetches; 103 }; 104 105 106 END_NAMESPACE(osg); 107 END_NAMESPACE(psg); 108 END_NCBI_NAMESPACE; 109 110 #endif // PSGS_OSGCALLER__HPP 111 112