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

Go to the SVN repository for this file.

1 #ifndef DBAPI_DRIVER___DBAPI_DRIVER_CONN_PARAMS__HPP
2 #define DBAPI_DRIVER___DBAPI_DRIVER_CONN_PARAMS__HPP
3 
4 /* $Id: dbapi_driver_conn_params.hpp 61181 2014-01-02 17:57:22Z 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  * Author: Sergey Sikorskiy
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbienv.hpp>
38 
40 
41 
43 typedef NCBI_PARAM_TYPE(dbapi, can_use_kerberos) TDbapi_CanUseKerberos;
44 
45 
46 namespace impl
47 {
48 
49 /////////////////////////////////////////////////////////////////////////////
50 ///
51 /// impl::CDBConnParamsBase::
52 ///
53 
55  public CDBConnParams
56 {
57 public:
58  CDBConnParamsBase(void);
59  virtual ~CDBConnParamsBase(void);
60 
61 public:
62  virtual string GetDriverName(void) const;
63  virtual Uint4 GetProtocolVersion(void) const;
64  virtual EEncoding GetEncoding(void) const;
65 
66  virtual string GetServerName(void) const;
67  virtual string GetDatabaseName(void) const;
68  virtual string GetUserName(void) const;
69  virtual string GetPassword(void) const;
70 
71  virtual EServerType GetServerType(void) const;
72  virtual Uint4 GetHost(void) const;
73  virtual Uint2 GetPort(void) const;
74 
75  virtual CRef<IConnValidator> GetConnValidator(void) const;
76  virtual const CDBHandlerStack& GetOpeningMsgHandlers(void) const;
77 
78  virtual string GetParam(const string& key) const;
79 
80 protected:
81  void SetDriverName(const string& name)
82  {
83  m_DriverName = name;
84  }
86  {
87  m_ProtocolVersion = version;
88  }
89  void SetEncoding(EEncoding encoding)
90  {
91  m_Encoding = encoding;
92  }
93 
94  void SetServerName(const string& name)
95  {
96  m_ServerName = name;
97  }
98  void SetDatabaseName(const string& name)
99  {
100  m_DatabaseName = name;
101  }
102  void SetUserName(const string& name)
103  {
104  m_UserName = name;
105  }
106  void SetPassword(const string& passwd)
107  {
108  m_Password = passwd;
109  }
110 
112  {
113  m_ServerType = type;
114  }
115  void SetHost(Uint4 host)
116  {
117  m_Host = host;
118  }
119  void SetPort(Uint2 port)
120  {
121  m_PortNumber = port;
122  }
123 
124  void SetConnValidator(const CRef<IConnValidator>& validator)
125  {
126  m_Validator = validator;
127  }
128 
130  {
131  return m_OpeningMsgHandlers;
132  }
133 
134  void SetParam(const string& key, const string& value)
135  {
136  m_UnclassifiedParamMap[key] = value;
137  }
138 
139 private:
140  // Non-copyable.
142  CDBConnParamsBase& operator =(const CDBConnParamsBase& other);
143 
144 private:
146 
147  string m_DriverName;
150 
151  string m_ServerName;
153  string m_UserName;
154  string m_Password;
161 };
162 
163 } // namespace impl
164 
165 /////////////////////////////////////////////////////////////////////////////
166 ///
167 /// CDBConnParamsBase::
168 ///
169 
172 {
173 public:
175  virtual ~CDBConnParamsBase(void) {}
176 
177 public:
178  void SetDriverName(const string& name)
179  {
181  }
183  {
185  }
186  void SetEncoding(EEncoding encoding)
187  {
189  }
190 
191  void SetServerName(const string& name)
192  {
194  }
195  void SetDatabaseName(const string& name)
196  {
198  }
199  void SetUserName(const string& name)
200  {
202  }
203  void SetPassword(const string& passwd)
204  {
206  }
207 
209  {
211  }
212  void SetHost(Uint4 host)
213  {
215  }
216  void SetPort(Uint2 port)
217  {
219  }
220 
221  void SetConnValidator(const CRef<IConnValidator>& validator)
222  {
224  }
225 
227  {
229  }
230 
231  void SetParam(const string& key, const string& value)
232  {
234  }
235 
236 private:
237  // Non-copyable.
240 };
241 
242 
243 /////////////////////////////////////////////////////////////////////////////
244 ///
245 /// CDBDefaultConnParams::
246 ///
247 
250 {
251 public:
252  CDBDefaultConnParams(const string& srv_name,
253  const string& user_name,
254  const string& passwd,
256  bool reusable = false,
257  const string& pool_name = kEmptyStr);
258  virtual ~CDBDefaultConnParams(void);
259 
260 public:
261  void SetDriverName(const string& name)
262  {
264  }
266  {
268  }
269  void SetEncoding(EEncoding encoding)
270  {
272  }
273  void SetDatabaseName(const string& name)
274  {
276  }
278  {
280  }
281 
282  void SetHost(Uint4 host)
283  {
285  }
286  void SetPort(Uint2 port)
287  {
289  }
290 
291  void SetConnValidator(const CRef<IConnValidator>& validator)
292  {
294  }
295 
297  {
299  }
300 
301  void SetParam(const string& key, const string& value)
302  {
304  }
305 
306 private:
307  // Non-copyable.
310 };
311 
312 
313 /////////////////////////////////////////////////////////////////////////////
316 {
317 public:
318  CDBUriConnParams(const string& params);
319  virtual ~CDBUriConnParams(void);
320 
321 public:
322  void SetPassword(const string& passwd)
323  {
325  }
326 
327 private:
328  void ParseServer(const string& params, size_t cur_pos);
329  void ParseSlash(const string& params, size_t cur_pos);
330  void ParseParamPairs(const string& param_pairs, size_t cur_pos);
331 
332 private:
333  // Non-copyable.
336 };
337 
338 
339 /////////////////////////////////////////////////////////////////////////////
342 {
343 public:
344  CDB_ODBC_ConnParams(const string& params);
345  virtual ~CDB_ODBC_ConnParams(void);
346 
347 public:
348  void SetPassword(const string& passwd)
349  {
351  }
352 
353 private:
354  // Non-copyable.
357 
358 private:
359  void x_MapPairToParam(const string& key, const string& value);
360 };
361 
362 
363 /////////////////////////////////////////////////////////////////////////////
365 {
366 public:
368  const CDBConnParams& other,
369  const string& server_name_env = "DBAPI_SERVER",
370  const string& database_name_env = "DBAPI_DATABASE",
371  const string& user_name_env = "DBAPI_USER",
372  const string& passwd_env = "DBAPI_PASSWORD"
373  );
374  virtual ~CDBEnvConnParams(void);
375 
376 public:
377  void SetServerNameEnv(const string& name)
378  {
379  m_ServerNameEnv = name;
380  }
381  void SetDatabaseNameEnv(const string& name)
382  {
383  m_DatabaseNameEnv = name;
384  }
385  void SetUserNameEnv(const string& name)
386  {
387  m_UserNameEnv = name;
388  }
389  void SetPasswordEnv(const string& pwd)
390  {
391  m_PasswordEnv = pwd;
392  }
393 
394 public:
395  virtual string GetServerName(void) const;
396  virtual string GetDatabaseName(void) const;
397  virtual string GetUserName(void) const;
398  virtual string GetPassword(void) const;
399 
400 private:
401  // Non-copyable.
404 
405 private:
411 };
412 
413 
414 /////////////////////////////////////////////////////////////////////////////
416  public CDBConnParamsDelegate
417 {
418 public:
420  const CDBConnParams& other,
421  const string& file = kEmptyStr
422  );
423  virtual ~CDBInterfacesFileConnParams(void);
424 
425 public:
426  virtual EServerType GetServerType(void) const;
427  virtual Uint4 GetHost(void) const;
428  virtual Uint2 GetPort(void) const;
429 
430 private:
431  // Non-copyable.
434 
435 private:
436  struct SIRecord
437  {
438  SIRecord(void)
439  : m_Host(0)
440  , m_Port(0)
441  {
442  }
443  SIRecord(Uint4 host, Uint2 port)
444  : m_Host(host)
445  , m_Port(port)
446  {
447  }
448 
451  };
452 
455 };
456 
457 
458 /////////////////////////////////////////////////////////////////////////////
460  public CDBConnParamsDelegate
461 {
462 public:
463  CCPPToolkitConnParams(const CDBConnParams& other);
464  virtual ~CCPPToolkitConnParams(void);
465 
466 public:
467  static EServerType GetServerType(const CTempString& server_name);
468  virtual EServerType GetServerType(void) const;
469 
470 private:
471  // Non-copyable.
474 };
475 
476 
478 
479 
480 
481 #endif /* DBAPI_DRIVER___DBAPI_DRIVER_CONN_PARAMS__HPP */
CCPPToolkitConnParams(const CCPPToolkitConnParams &other)
void SetProtocolVersion(Uint4 version)
void SetEncoding(EEncoding encoding)
void SetPassword(const string &passwd)
CDBConnParamsBase(const CDBConnParamsBase &other)
impl::CDBHandlerStack & SetOpeningMsgHandlers(void)
void SetDriverName(const string &name)
void SetParam(const string &key, const string &value)
void SetServerName(const string &name)
void SetDatabaseName(const string &name)
void SetUserName(const string &name)
void SetConnValidator(const CRef< IConnValidator > &validator)
void SetServerType(EServerType type)
CDBConnParamsBase & operator=(const CDBConnParamsBase &other)
CDBConnParams::
Definition: interfaces.hpp:258
void SetDriverName(const string &name)
impl::CDBHandlerStack & SetOpeningMsgHandlers(void)
void SetConnValidator(const CRef< IConnValidator > &validator)
void SetProtocolVersion(Uint4 version)
void SetDatabaseName(const string &name)
CDBDefaultConnParams(const CDBDefaultConnParams &other)
void SetParam(const string &key, const string &value)
void SetServerType(EServerType type)
void SetEncoding(EEncoding encoding)
void SetServerNameEnv(const string &name)
CDBEnvConnParams(const CDBEnvConnParams &other)
const CNcbiEnvironment m_Env
void SetPasswordEnv(const string &pwd)
void SetUserNameEnv(const string &name)
void SetDatabaseNameEnv(const string &name)
CDBInterfacesFileConnParams(const CDBInterfacesFileConnParams &other)
CDBUriConnParams(const CDBUriConnParams &other)
void SetPassword(const string &passwd)
void SetPassword(const string &passwd)
CDB_ODBC_ConnParams(const CDB_ODBC_ConnParams &other)
CNcbiEnvironment –.
Definition: ncbienv.hpp:110
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
impl::CDBConnParamsBase::
void SetConnValidator(const CRef< IConnValidator > &validator)
CDBConnParamsBase(const CDBConnParamsBase &other)
void SetDriverName(const string &name)
void SetProtocolVersion(Uint4 version)
CDBHandlerStack & SetOpeningMsgHandlers(void)
TUnclassifiedParamMap m_UnclassifiedParamMap
CRef< IConnValidator > m_Validator
map< string, string, PNocase > TUnclassifiedParamMap
void SetServerType(EServerType type)
void SetUserName(const string &name)
void SetEncoding(EEncoding encoding)
void SetParam(const string &key, const string &value)
void SetServerName(const string &name)
void SetPassword(const string &passwd)
void SetDatabaseName(const string &name)
typedef NCBI_PARAM_TYPE(dbapi, can_use_kerberos) TDbapi_CanUseKerberos
static int type
Definition: getdata.c:31
virtual EServerType GetServerType(void) const =0
virtual string GetPassword(void) const =0
virtual Uint4 GetHost(void) const =0
virtual string GetServerName(void) const =0
virtual Uint2 GetPort(void) const =0
virtual string GetDatabaseName(void) const =0
CDBConnParams & operator=(const CDBConnParams &other)
virtual string GetUserName(void) const =0
#define NCBI_PARAM_DECL_EXPORT(expname, type, section, name)
Same as NCBI_PARAM_DECL but with export specifier (e.g.
Definition: ncbi_param.hpp:164
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
EEncoding
Definition: ncbistr.hpp:199
#define kEmptyStr
Definition: ncbistr.hpp:123
unsigned short m_Port
TCP port to listen on.
FILE * file
static int version
Definition: mdb_load.c:29
Uint2 GetPort(TEndpointKey key)
Uint4 GetHost(TEndpointKey key)
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Defines unified interface to application:
Definition: type.c:6
Modified on Thu Apr 11 15:21:23 2024 by modify_doxy.py rev. 669887