File indexing completed on 2025-12-17 09:19:36
0001 #ifndef ODBC_ODBCINTERFACE_H
0002 #define ODBC_ODBCINTERFACE_H
0003
0004 #include <cstdint>
0005 #include <map>
0006 #include <string>
0007
0008 namespace odbc
0009 {
0010 class Connection;
0011 class Statement;
0012 }
0013
0014 class ODBCInterface
0015 {
0016 public:
0017 static ODBCInterface *instance();
0018
0019 virtual ~ODBCInterface();
0020
0021 void Verbosity(uint64_t i) {m_Verbosity = i;}
0022 uint64_t Verbosity() const {return m_Verbosity;}
0023
0024 void Print(const std::string & = "ALL") const;
0025
0026 odbc::Connection *getDBConnection(const std::string &dbname);
0027 odbc::Statement *getStatement(const std::string &dbname);
0028
0029 int ConnectionTries() const {return m_ConnectionTries;}
0030 int SleepMS() const {return m_SleepMS;}
0031 int CurrentConnections() const {return m_CurrentConnections;}
0032 void Disconnect();
0033 const std::map<std::string, int>& getNumConnection() const {return m_NumConnection;}
0034 const std::map<std::string, int>& getNumStatementUse() const {return m_NumStatementUse;}
0035 const std::map<std::string, odbc::Connection *>& getOdbcConnectionMap() {return m_OdbcConnectionMap;}
0036
0037 private:
0038
0039 ODBCInterface() = default;
0040 static ODBCInterface *__instance;
0041 int m_ConnectionTries {0};
0042 int m_CurrentConnections {0};
0043 int m_SleepMS {0};
0044 uint64_t m_Verbosity {0};
0045 static constexpr int m_MAX_NUM_RETRIES = 3000;
0046 static constexpr int m_MIN_SLEEP_DUR = 200;
0047 static constexpr int m_MAX_SLEEP_DUR = 3000;
0048
0049 std::map<std::string, odbc::Connection *> m_OdbcConnectionMap;
0050 std::map<std::string, odbc::Statement *> m_OdbcStatementMap;
0051 std::map<std::string, int> m_NumConnection;
0052 std::map<std::string, int> m_NumStatementUse;
0053 };
0054
0055 #endif