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

Go to the SVN repository for this file.

1 #ifndef DBAPI___DRIVER_MGR__HPP
2 #define DBAPI___DRIVER_MGR__HPP
3 
4 /* $Id: driver_mgr.hpp 58585 2013-06-18 15:26:09Z grichenk $
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: Michael Kholodov, Denis Vakatov
30  *
31  * File Description: Driver Manager definition
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbireg.hpp>
40 #include <map>
41 
42 
43 /** @addtogroup DbDrvMgr
44  *
45  * @{
46  */
47 
48 
50 
51 
52 /////////////////////////////////////////////////////////////////////////////
53 //
54 // CDriverManager::
55 //
56 // Static class for registering drivers and getting the datasource
57 //
58 
59 // Forward declaration
60 class IDataSource;
61 
62 template <typename T> class CSafeStatic_Allocator;
63 
65 {
67 
68 public:
69  // Get a single instance of CDriverManager
70  static CDriverManager& GetInstance();
71 
72  // Remove instance of CDriverManager
73  // DEPRECAETD. Instance will be removed automatically.
74  static void RemoveInstance();
75 
76  // Create data source object. By default, DBAPI uses a single
77  // shared data source per driver; however, supplying a tag will
78  // allow for multiple instances with different parameters.
79  // (SDBAPI uses this feature to ensure UTF-8 encoding.)
80 
81  IDataSource* CreateDs(const string& driver_name,
82  const map<string, string> *attr = 0,
83  const string& tag = kEmptyStr);
84 
85  IDataSource* CreateDs(const string& driver_name, const string& tag)
86  { return CreateDs(driver_name, NULL, tag); }
87 
88  IDataSource* CreateDsFrom(const string& drivers,
89  const IRegistry* reg = 0,
90  const string& tag = kEmptyStr);
91 
92  IDataSource* CreateDsFrom(const string& drivers, const string& tag)
93  { return CreateDs(drivers, NULL, tag); }
94 
95  IDataSource* MakeDs(const CDBConnParams& params,
96  const string& tag = kEmptyStr);
97 
98  // Destroy datasource object
99  void DestroyDs(const string& driver_name);
100  void DestroyDs(const IDataSource* ds);
101 
102  // Set maximum number of connections in application
103  void SetMaxConnect(unsigned int max_connect) {
104  CDbapiConnMgr::SetMaxConnect(max_connect);
105  }
106 
107  // Get maximum number of connections in application
108  unsigned int GetMaxConnect(void) {
110  }
111 
112 protected:
114 
115  // Prohibit explicit construction and destruction
116  CDriverManager();
117  virtual ~CDriverManager();
118 
119  // Put the new data source into the internal list with
120  // corresponding driver name, return previous, if already exists
121  class IDataSource* RegisterDs(const string& driver_name,
122  class I_DriverContext* ctx);
123 
124  mutable CMutex m_Mutex;
126 };
127 
129 
130 
131 /* @} */
132 
133 #endif /* DBAPI___DBAPI__HPP */
CDBConnParams::
Definition: interfaces.hpp:258
static void SetMaxConnect(unsigned int max_connect)
static unsigned int GetMaxConnect(void)
CMutex –.
Definition: ncbimtx.hpp:749
Helper class for object allocation/deallocation.
IDataSource –.
Definition: dbapi.hpp:963
IRegistry –.
Definition: ncbireg.hpp:73
Include a standard set of the NCBI C++ Toolkit most basic headers.
CS_CONTEXT * ctx
Definition: t0006.c:12
#define NULL
Definition: ncbistd.hpp:225
IDataSource * CreateDs(const string &driver_name, const string &tag)
Definition: driver_mgr.hpp:85
TDsContainer m_ds_list
Definition: driver_mgr.hpp:125
IDataSource * CreateDsFrom(const string &drivers, const string &tag)
Definition: driver_mgr.hpp:92
void SetMaxConnect(unsigned int max_connect)
Definition: driver_mgr.hpp:103
unsigned int GetMaxConnect(void)
Definition: driver_mgr.hpp:108
multimap< string, class IDataSource * > TDsContainer
Definition: driver_mgr.hpp:113
#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 kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_DBAPI_EXPORT
Definition: ncbi_export.h:432
const char * tag
Process information in the NCBI Registry, including working with configuration files.
Plugin manager (using class factory paradigm).
Modified on Sat Dec 02 09:19:52 2023 by modify_doxy.py rev. 669887