diff Framework/Common/DatabaseManager.h @ 237:35598014f140

refactoring to remove GlobalProperties.cpp
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Apr 2021 19:09:04 +0200
parents 0a9b48d19643
children a063bbf10a3e
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.h	Thu Apr 08 12:00:01 2021 +0200
+++ b/Framework/Common/DatabaseManager.h	Thu Apr 08 19:09:04 2021 +0200
@@ -36,6 +36,9 @@
    * WARNING: In PostgreSQL releases <= 3.3 and in MySQL releases <=
    * 3.0, this class was protected by a mutex. It is now assumed that
    * locking must be implemented at a higher level.
+   *
+   * This class maintains a list of precompiled statements. At any
+   * time, this class handles 0 or 1 active transaction.
    **/
   class DatabaseManager : public boost::noncopyable
   {
@@ -47,11 +50,6 @@
     CachedStatements               cachedStatements_;
     Dialect                        dialect_;
 
-    IDatabase& GetDatabase()
-    {
-      return *database_;
-    }
-
     void CloseIfUnavailable(Orthanc::ErrorCode e);
 
     IPrecompiledStatement* LookupCachedStatement(const StatementLocation& location) const;
@@ -71,6 +69,11 @@
       Close();
     }
 
+    IDatabase& GetDatabase()
+    {
+      return *database_;
+    }
+
     Dialect GetDialect() const
     {
       return dialect_;
@@ -110,6 +113,21 @@
       {
         return database_;
       }
+
+      bool DoesTableExist(const std::string& name)
+      {
+        return manager_.GetTransaction().DoesTableExist(name);
+      }
+
+      bool DoesTriggerExist(const std::string& name)
+      {
+        return manager_.GetTransaction().DoesTriggerExist(name);
+      }
+
+      void ExecuteMultiLines(const std::string& sql)
+      {
+        manager_.GetTransaction().ExecuteMultiLines(sql);
+      }
     };