1 #ifndef OBJECTS_TRACKMGR_GRIDCLI__DISPLAY_TRACK_CLIENT_HPP
2 #define OBJECTS_TRACKMGR_GRIDCLI__DISPLAY_TRACK_CLIENT_HPP
3 
4 /* $Id: displaytrack_client.hpp 506052 2016-06-30 21:39:40Z ucko $
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: Peter Meric
30  *
31  * File Description:  NetSchedule grid client for TrackManager display-track request/reply
32  *
33  */
34 
35 /// @file tmgr_displaytrack_client.hpp
36 /// NetSchedule grid client for TrackManager display-track request/reply
37 
38 #include <objects/trackmgr/gridrpcclient.hpp>
39 #include <connect/ncbi_http_session.hpp>
40 #include <serial/rpcbase.hpp>
41 
42 
43 BEGIN_NCBI_SCOPE
44 
45 BEGIN_SCOPE(objects)
46 class CTMgr_DisplayTrackRequest;
47 class CTMgr_DisplayTrackReply;
48 END_SCOPE(objects)
49 
50 
51 class CTMS_DisplayTrack_Client : private CGridRPCBaseClient<CAsnBinCompressed>
52 {
53 private:
54     using TBaseClient = CGridRPCBaseClient<ncbi::CAsnBinCompressed>;
55 
56     struct HttpService
57     {
HttpServiceCTMS_DisplayTrack_Client::HttpService58         explicit HttpService(const string& svc)
59             : service(svc)
60         {
61         }
62         string service;
63     };
64 
65 
66 public:
67     using TRequest = objects::CTMgr_DisplayTrackRequest;
68     using TReply = objects::CTMgr_DisplayTrackReply;
69     using TRequestCRef = CConstRef<TRequest>;
70     using TReplyRef = CRef<TReply>;
71 
72 public:
73     CTMS_DisplayTrack_Client(const string& NS_service,
74                              const string& NS_queue,
75                              const string& client_name,
76                              const string& NC_registry_section
77                             );
78 
79     CTMS_DisplayTrack_Client(const string& NS_registry_section = "netschedule_api",
80                              const string& NC_registry_section = kEmptyStr
81                             );
CTMS_DisplayTrack_Client(CTMS_DisplayTrack_Client && c)82     CTMS_DisplayTrack_Client(CTMS_DisplayTrack_Client&& c)
83         : TBaseClient(move(c)),
84           m_Http_svc(move(c.m_Http_svc)),
85           m_Http_session(move(c.m_Http_session)),
86           m_Rpc_client(move(c.m_Rpc_client))
87     {
88     }
89     virtual ~CTMS_DisplayTrack_Client() = default;
90 
91     static CTMS_DisplayTrack_Client CreateServiceClient(const string& http_svc = "TMS_DisplayTracks");
92 
93     TReplyRef Fetch(const TRequest& request) const;
94     bool FetchRawStream(CNcbiIstream& requeststr, CNcbiOstream& replystr) const;
95 
96 protected:
97     CTMS_DisplayTrack_Client(CTMS_DisplayTrack_Client&) = delete;
98     CTMS_DisplayTrack_Client(const HttpService&& http_svc);
99     TReplyRef x_HttpFetch(const TRequest& request) const;
100 
101 
102 protected:
103     CUrl m_Http_svc;
104     mutable CRef<CHttpSession> m_Http_session;
105     using TRPCBaseClient = CGridRPCHttpClient<TRequest, TReply>;
106     mutable CRef<TRPCBaseClient> m_Rpc_client;
107 };
108 
109 
110 END_NCBI_SCOPE
111 
112 #endif // OBJECTS_TRACKMGR_GRIDCLI__DISPLAY_TRACK_CLIENT_HPP
113 
114