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

Go to the SVN repository for this file.

1 #ifndef NCBI_TAXON3_HPP
2 #define NCBI_TAXON3_HPP
3 
4 /* $Id: taxon3.hpp 94762 2021-09-09 12:30:08Z stakhovv $
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  * Author: Colleen Bollin, based on work by Vladimir Soussov, Michael Domrachev
30  *
31  * File Description:
32  * NCBI Taxonomy information retreival library
33  *
34  */
35 
36 
40 #include <serial/serialdef.hpp>
41 #include <connect/ncbi_types.h>
42 #include <corelib/ncbi_limits.hpp>
43 
44 #include <list>
45 #include <vector>
46 #include <map>
47 
48 
50 
51 class CObjectOStream;
53 
54 
55 BEGIN_objects_SCOPE
56 
58 public:
59 
60  enum class initialize { yes, no };
61  CTaxon3(initialize = initialize::no);
62  CTaxon3(const STimeout& timeout, unsigned reconnect_attempts=5, bool exponential=false);
63  virtual ~CTaxon3();
64 
65  //---------------------------------------------
66  // Taxon1 server init
67  // Returns: TRUE - OK
68  // FALSE - Can't open connection to taxonomy service
69  ///
70  virtual void Init(); // default: 20 sec timeout, 5 reconnect attempts,
71 
72  virtual void Init(const STimeout* timeout, unsigned reconnect_attempts=5);
73 
74  // submit a list of org_refs
75  virtual CRef< CTaxon3_reply > SendOrgRefList(const vector< CRef< COrg_ref > >& list,
77  fT3reply_parts t3result_parts = eT3reply_default);
78 
79  // Name list lookup all the names (including common names) regardless of their lookup flag
80  virtual CRef< CTaxon3_reply > SendNameList(const vector<std::string>& list,
83  fT3reply_parts t3parts = (eT3reply_org|eT3reply_status));
84 
85  virtual CRef< CTaxon3_reply > SendTaxidList(const vector<TTaxId>& list,
88  fT3reply_parts t3parts = eT3reply_org);
89 
90  virtual CRef< CTaxon3_reply > SendRequest(const CTaxon3_request& request);
91 
92  //--------------------------------------------------
93  // Get error message after latest erroneous operation
94  // Returns: error message, or empty string if no error occurred
95  ///
96  virtual const string& GetLastError() const { return m_sLastError; }
97 
98 private:
99 
101  string m_sService;
102  const STimeout* m_timeout; // NULL, or points to "m_timeout_value"
104 
106  bool m_exponential{ false }; // double the timeout with each attempt
107 
108  string m_sLastError;
109 
110  void SetLastError(const char* err_msg);
111 };
112 
113 
114 END_objects_SCOPE
116 
117 #endif //NCBI_TAXON1_HPP
This stream exchanges data with a named service, in a constraint that the service is implemented as o...
CObjectOStream –.
Definition: objostr.hpp:83
unsigned int fOrgref_parts
Definition: Org_ref.hpp:94
@ eOrgref_default
Definition: Org_ref.hpp:92
@ eOrgref_taxname
Definition: Org_ref.hpp:56
@ eOrgref_db_taxid
Definition: Org_ref.hpp:61
CRef –.
Definition: ncbiobj.hpp:618
CTaxon3_request –.
unsigned m_nReconnectAttempts
Definition: taxon3.hpp:105
STimeout m_timeout_value
Definition: taxon3.hpp:103
const STimeout * m_timeout
Definition: taxon3.hpp:102
string m_sLastError
Definition: taxon3.hpp:108
initialize
Definition: taxon3.hpp:60
string m_sService
Definition: taxon3.hpp:101
virtual const string & GetLastError() const
Definition: taxon3.hpp:96
ESerialDataFormat m_eDataFormat
Definition: taxon3.hpp:100
virtual CRef< CTaxon3_reply > SendNameList(const vector< std::string > &list, COrg_ref::fOrgref_parts parts=(COrg_ref::eOrgref_taxname|COrg_ref::eOrgref_db_taxid), fT3reply_parts t3parts=(eT3reply_org|eT3reply_status))=0
virtual CRef< CTaxon3_reply > SendRequest(const CTaxon3_request &request)=0
virtual CRef< CTaxon3_reply > SendTaxidList(const vector< TTaxId > &list, COrg_ref::fOrgref_parts parts=(COrg_ref::eOrgref_taxname|COrg_ref::eOrgref_db_taxid), fT3reply_parts t3parts=eT3reply_org)=0
virtual CRef< CTaxon3_reply > SendOrgRefList(const vector< CRef< COrg_ref > > &list, COrg_ref::fOrgref_parts result_parts=COrg_ref::eOrgref_default, fT3reply_parts t3result_parts=eT3reply_default)=0
virtual void Init()=0
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_TAXON3_EXPORT
Definition: ncbi_export.h:865
fallback to Cassandra storage</td > n</tr > n</table > n</td > n< td > yes
Timeout structure.
Definition: ncbi_types.h:76
Modified on Sun Jun 23 05:22:33 2024 by modify_doxy.py rev. 669887