Mercurial > hg > orthanc-databases
diff Framework/Common/DatabaseManager.h @ 255:d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Apr 2021 17:57:08 +0200 |
parents | 8a4ce70f456a |
children | 29d2b76516f6 |
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.h Wed Apr 14 15:33:57 2021 +0200 +++ b/Framework/Common/DatabaseManager.h Wed Apr 14 17:57:08 2021 +0200 @@ -21,7 +21,7 @@ #pragma once -#include "IDatabase.h" +#include "IDatabaseFactory.h" #include "StatementLocation.h" #include <Compatibility.h> // For std::unique_ptr<> @@ -39,12 +39,17 @@ * * This class maintains a list of precompiled statements. At any * time, this class handles 0 or 1 active transaction. + * + * "DatabaseManager" takes a "IDatabaseFactory" as input, in order + * to be able to automatically re-open the database connection if + * the latter gets lost. **/ class DatabaseManager : public boost::noncopyable { private: typedef std::map<StatementLocation, IPrecompiledStatement*> CachedStatements; + std::unique_ptr<IDatabaseFactory> factory_; std::unique_ptr<IDatabase> database_; std::unique_ptr<ITransaction> transaction_; CachedStatements cachedStatements_; @@ -62,7 +67,7 @@ void ReleaseImplicitTransaction(); public: - explicit DatabaseManager(IDatabase* database); // Takes ownership + explicit DatabaseManager(IDatabaseFactory* factory); // Takes ownership ~DatabaseManager() { @@ -71,10 +76,7 @@ IDatabase& GetDatabase(); - Dialect GetDialect() const - { - return dialect_; - } + Dialect GetDialect() const; void Close();