changeset 3085:c829758b9ca0 db-changes

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 04 Jan 2019 16:52:53 +0100
parents 195ba4cbac3f
children 74e3e48aa9bd
files CMakeLists.txt OrthancServer/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.cpp OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h OrthancServer/Search/Compatibility/DatabaseLookup.cpp OrthancServer/Search/Compatibility/DatabaseLookup.h OrthancServer/Search/Compatibility/ILookupResources.cpp OrthancServer/Search/Compatibility/ILookupResources.h OrthancServer/Search/Compatibility/SetOfResources.cpp OrthancServer/Search/Compatibility/SetOfResources.h OrthancServer/ServerContext.h OrthancServer/ServerJobs/OrthancJobUnserializer.cpp OrthancServer/ServerToolbox.cpp Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Engine/OrthancPluginDatabase.h
diffstat 15 files changed, 158 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Jan 04 16:42:55 2019 +0100
+++ b/CMakeLists.txt	Fri Jan 04 16:52:53 2019 +0100
@@ -71,9 +71,9 @@
   OrthancServer/OrthancRestApi/OrthancRestSystem.cpp
   OrthancServer/QueryRetrieveHandler.cpp
   OrthancServer/SQLiteDatabaseWrapper.cpp
-  OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.cpp
   OrthancServer/Search/Compatibility/DatabaseLookup.cpp
   OrthancServer/Search/Compatibility/ICreateInstance.cpp
+  OrthancServer/Search/Compatibility/ILookupResources.cpp
   OrthancServer/Search/Compatibility/SetOfResources.cpp
   OrthancServer/Search/DatabaseConstraint.cpp
   OrthancServer/Search/DatabaseLookup.cpp
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -45,6 +45,8 @@
 #include "../ServerToolbox.h"
 #include "../SliceOrdering.h"
 
+#include "../../Plugins/Engine/OrthancPlugins.h"
+
 
 namespace Orthanc
 {
--- a/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/**
- * Orthanc - A Lightweight, RESTful DICOM Store
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * In addition, as a special exception, the copyright holders of this
- * program give permission to link the code of its release with the
- * OpenSSL project's "OpenSSL" library (or with modified versions of it
- * that use the same license as the "OpenSSL" library), and distribute
- * the linked executables. You must obey the GNU General Public License
- * in all respects for all of the code used other than "OpenSSL". If you
- * modify file(s) with this exception, you may extend this exception to
- * your version of the file(s), but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source files
- * in the program, then also delete it here.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#include "../../PrecompiledHeadersServer.h"
-#include "CompatibilityDatabaseWrapper.h"
-
-#include "DatabaseLookup.h"
-
-namespace Orthanc
-{
-  namespace Compatibility
-  {
-    void CompatibilityDatabaseWrapper::Apply(
-      IDatabaseWrapper& database,
-      CompatibilityDatabaseWrapper& compatibility,
-      std::list<std::string>& resourcesId,
-      std::list<std::string>* instancesId,
-      const std::vector<DatabaseConstraint>& lookup,
-      ResourceType queryLevel,
-      size_t limit)
-    {
-      Compatibility::DatabaseLookup compat(database, compatibility);
-      compat.ApplyLookupResources(resourcesId, instancesId, lookup, queryLevel, limit);
-    }
-  }
-}
--- a/OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h	Fri Jan 04 16:42:55 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
- * Orthanc - A Lightweight, RESTful DICOM Store
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * In addition, as a special exception, the copyright holders of this
- * program give permission to link the code of its release with the
- * OpenSSL project's "OpenSSL" library (or with modified versions of it
- * that use the same license as the "OpenSSL" library), and distribute
- * the linked executables. You must obey the GNU General Public License
- * in all respects for all of the code used other than "OpenSSL". If you
- * modify file(s) with this exception, you may extend this exception to
- * your version of the file(s), but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source files
- * in the program, then also delete it here.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#pragma once
-
-#include "../../IDatabaseWrapper.h"
-
-namespace Orthanc
-{
-  namespace Compatibility
-  {
-    /**
-     * This is a compatibility class that contains database primitives
-     * that were used in Orthanc <= 1.5.1, and that have been removed
-     * during the optimization of the database engine.
-     **/
-    class CompatibilityDatabaseWrapper : public boost::noncopyable
-    {     
-    public:
-      virtual ~CompatibilityDatabaseWrapper()
-      {
-      }
-      
-      virtual void GetAllInternalIds(std::list<int64_t>& target,
-                                     ResourceType resourceType) = 0;
-      
-      virtual void LookupIdentifier(std::list<int64_t>& result,
-                                    ResourceType level,
-                                    const DicomTag& tag,
-                                    IdentifierConstraintType type,
-                                    const std::string& value) = 0;
- 
-      virtual void LookupIdentifierRange(std::list<int64_t>& result,
-                                         ResourceType level,
-                                         const DicomTag& tag,
-                                         const std::string& start,
-                                         const std::string& end) = 0;
-
-      static void Apply(IDatabaseWrapper& database,
-                        CompatibilityDatabaseWrapper& compatibility,
-                        std::list<std::string>& resourcesId,
-                        std::list<std::string>* instancesId,
-                        const std::vector<DatabaseConstraint>& lookup,
-                        ResourceType queryLevel,
-                        size_t limit);
-    };
-  }
-}
--- a/OrthancServer/Search/Compatibility/DatabaseLookup.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/Search/Compatibility/DatabaseLookup.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -92,7 +92,7 @@
     
     
     static void ApplyIdentifierConstraint(SetOfResources& candidates,
-                                          CompatibilityDatabaseWrapper& compatibility,
+                                          ILookupResources& compatibility,
                                           const DatabaseConstraint& constraint,
                                           ResourceType level)
     {
@@ -142,7 +142,7 @@
 
     
     static void ApplyIdentifierRange(SetOfResources& candidates,
-                                     CompatibilityDatabaseWrapper& compatibility,
+                                     ILookupResources& compatibility,
                                      const DatabaseConstraint& smaller,
                                      const DatabaseConstraint& greater,
                                      ResourceType level)
@@ -161,7 +161,7 @@
     
     static void ApplyLevel(SetOfResources& candidates,
                            IDatabaseWrapper& database,
-                           CompatibilityDatabaseWrapper& compatibility,
+                           ILookupResources& compatibility,
                            const std::vector<DatabaseConstraint>& lookup,
                            ResourceType level)
     {
--- a/OrthancServer/Search/Compatibility/DatabaseLookup.h	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/Search/Compatibility/DatabaseLookup.h	Fri Jan 04 16:52:53 2019 +0100
@@ -34,7 +34,7 @@
 #pragma once
 
 #include "../../IDatabaseWrapper.h"
-#include "CompatibilityDatabaseWrapper.h"
+#include "ILookupResources.h"
 
 namespace Orthanc
 {
@@ -44,11 +44,11 @@
     {
     private:
       IDatabaseWrapper&              database_;
-      CompatibilityDatabaseWrapper&  compatibility_;
+      ILookupResources&  compatibility_;
 
     public:
       DatabaseLookup(IDatabaseWrapper&  database,
-                     CompatibilityDatabaseWrapper& compatibility) :
+                     ILookupResources& compatibility) :
         database_(database),
         compatibility_(compatibility)
       {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Search/Compatibility/ILookupResources.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -0,0 +1,56 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2019 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * In addition, as a special exception, the copyright holders of this
+ * program give permission to link the code of its release with the
+ * OpenSSL project's "OpenSSL" library (or with modified versions of it
+ * that use the same license as the "OpenSSL" library), and distribute
+ * the linked executables. You must obey the GNU General Public License
+ * in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s) with this exception, you may extend this exception to
+ * your version of the file(s), but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source files
+ * in the program, then also delete it here.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#include "../../PrecompiledHeadersServer.h"
+#include "ILookupResources.h"
+
+#include "DatabaseLookup.h"
+
+namespace Orthanc
+{
+  namespace Compatibility
+  {
+    void ILookupResources::Apply(
+      IDatabaseWrapper& database,
+      ILookupResources& compatibility,
+      std::list<std::string>& resourcesId,
+      std::list<std::string>* instancesId,
+      const std::vector<DatabaseConstraint>& lookup,
+      ResourceType queryLevel,
+      size_t limit)
+    {
+      Compatibility::DatabaseLookup compat(database, compatibility);
+      compat.ApplyLookupResources(resourcesId, instancesId, lookup, queryLevel, limit);
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Search/Compatibility/ILookupResources.h	Fri Jan 04 16:52:53 2019 +0100
@@ -0,0 +1,78 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2019 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * In addition, as a special exception, the copyright holders of this
+ * program give permission to link the code of its release with the
+ * OpenSSL project's "OpenSSL" library (or with modified versions of it
+ * that use the same license as the "OpenSSL" library), and distribute
+ * the linked executables. You must obey the GNU General Public License
+ * in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s) with this exception, you may extend this exception to
+ * your version of the file(s), but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source files
+ * in the program, then also delete it here.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#include "../../IDatabaseWrapper.h"
+
+namespace Orthanc
+{
+  namespace Compatibility
+  {
+    /**
+     * This is a compatibility class that contains database primitives
+     * that were used in Orthanc <= 1.5.1, and that have been removed
+     * during the optimization of the database engine.
+     **/
+    class ILookupResources : public boost::noncopyable
+    {     
+    public:
+      virtual ~ILookupResources()
+      {
+      }
+      
+      virtual void GetAllInternalIds(std::list<int64_t>& target,
+                                     ResourceType resourceType) = 0;
+      
+      virtual void LookupIdentifier(std::list<int64_t>& result,
+                                    ResourceType level,
+                                    const DicomTag& tag,
+                                    IdentifierConstraintType type,
+                                    const std::string& value) = 0;
+ 
+      virtual void LookupIdentifierRange(std::list<int64_t>& result,
+                                         ResourceType level,
+                                         const DicomTag& tag,
+                                         const std::string& start,
+                                         const std::string& end) = 0;
+
+      static void Apply(IDatabaseWrapper& database,
+                        ILookupResources& compatibility,
+                        std::list<std::string>& resourcesId,
+                        std::list<std::string>* instancesId,
+                        const std::vector<DatabaseConstraint>& lookup,
+                        ResourceType queryLevel,
+                        size_t limit);
+    };
+  }
+}
--- a/OrthancServer/Search/Compatibility/SetOfResources.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/Search/Compatibility/SetOfResources.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -138,7 +138,7 @@
     }
 
 
-    void SetOfResources::Flatten(CompatibilityDatabaseWrapper& compatibility,
+    void SetOfResources::Flatten(ILookupResources& compatibility,
                                  std::list<int64_t>& result)
     {
       result.clear();
--- a/OrthancServer/Search/Compatibility/SetOfResources.h	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/Search/Compatibility/SetOfResources.h	Fri Jan 04 16:52:53 2019 +0100
@@ -34,7 +34,7 @@
 #pragma once
 
 #include "../../IDatabaseWrapper.h"
-#include "CompatibilityDatabaseWrapper.h"
+#include "ILookupResources.h"
 
 #include <set>
 #include <memory>
@@ -69,7 +69,7 @@
 
       void GoDown();
 
-      void Flatten(CompatibilityDatabaseWrapper& compatibility,
+      void Flatten(ILookupResources& compatibility,
                    std::list<int64_t>& result);
 
       void Flatten(std::list<std::string>& result);
--- a/OrthancServer/ServerContext.h	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/ServerContext.h	Fri Jan 04 16:52:53 2019 +0100
@@ -47,7 +47,6 @@
 #include "../Core/JobsEngine/SetOfInstancesJob.h"
 #include "../Core/MultiThreading/SharedMessageQueue.h"
 #include "../Core/RestApi/RestApiOutput.h"
-#include "../Plugins/Engine/OrthancPlugins.h"
 
 #include <boost/filesystem.hpp>
 #include <boost/thread.hpp>
@@ -55,6 +54,8 @@
 
 namespace Orthanc
 {
+  class OrthancPlugins;
+  
   /**
    * This class is responsible for maintaining the storage area on the
    * filesystem (including compression), as well as the index of the
--- a/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/ServerJobs/OrthancJobUnserializer.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -37,6 +37,7 @@
 #include "../../Core/Logging.h"
 #include "../../Core/OrthancException.h"
 #include "../../Core/SerializationToolbox.h"
+#include "../../Plugins/Engine/OrthancPlugins.h"
 
 #include "Operations/DeleteResourceOperation.h"
 #include "Operations/DicomInstanceOperationValue.h"
@@ -52,6 +53,7 @@
 #include "MergeStudyJob.h"
 #include "SplitStudyJob.h"
 
+
 namespace Orthanc
 {
   IJob* OrthancJobUnserializer::UnserializeJob(const Json::Value& source)
--- a/OrthancServer/ServerToolbox.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/OrthancServer/ServerToolbox.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -39,6 +39,7 @@
 #include "../Core/FileStorage/StorageAccessor.h"
 #include "../Core/Logging.h"
 #include "../Core/OrthancException.h"
+#include "../Plugins/Engine/OrthancPlugins.h"
 #include "IDatabaseWrapper.h"
 #include "ServerContext.h"
 
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Fri Jan 04 16:42:55 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Fri Jan 04 16:52:53 2019 +0100
@@ -1161,8 +1161,8 @@
     if (extensions_.lookupResources == NULL)
     {
       // Fallback to compatibility mode
-      CompatibilityDatabaseWrapper::Apply(*this, *this, resourcesId, instancesId,
-                                          lookup, queryLevel, limit);
+      ILookupResources::Apply
+        (*this, *this, resourcesId, instancesId, lookup, queryLevel, limit);
     }
     else
     {
--- a/Plugins/Engine/OrthancPluginDatabase.h	Fri Jan 04 16:42:55 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.h	Fri Jan 04 16:52:53 2019 +0100
@@ -36,7 +36,7 @@
 #if ORTHANC_ENABLE_PLUGINS == 1
 
 #include "../../Core/SharedLibrary.h"
-#include "../../OrthancServer/Search/Compatibility/CompatibilityDatabaseWrapper.h"
+#include "../../OrthancServer/Search/Compatibility/ILookupResources.h"
 #include "../../OrthancServer/Search/Compatibility/ISetResourcesContent.h"
 #include "../../OrthancServer/Search/Compatibility/ICreateInstance.h"
 #include "../Include/orthanc/OrthancCDatabasePlugin.h"
@@ -46,7 +46,7 @@
 {
   class OrthancPluginDatabase :
     public IDatabaseWrapper,
-    public Compatibility::CompatibilityDatabaseWrapper,
+    public Compatibility::ILookupResources,
     public Compatibility::ISetResourcesContent,
     public Compatibility::ICreateInstance
   {
@@ -330,12 +330,12 @@
                                 const std::string& instance)
       ORTHANC_OVERRIDE;
 
-    // From the "CompatibilityDatabaseWrapper" interface
+    // From the "ILookupResources" interface
     virtual void GetAllInternalIds(std::list<int64_t>& target,
                                    ResourceType resourceType) 
       ORTHANC_OVERRIDE;
 
-    // From the "CompatibilityDatabaseWrapper" interface
+    // From the "ILookupResources" interface
     virtual void LookupIdentifier(std::list<int64_t>& result,
                                   ResourceType level,
                                   const DicomTag& tag,
@@ -343,7 +343,7 @@
                                   const std::string& value)
       ORTHANC_OVERRIDE;
     
-    // From the "CompatibilityDatabaseWrapper" interface
+    // From the "ILookupResources" interface
     virtual void LookupIdentifierRange(std::list<int64_t>& result,
                                        ResourceType level,
                                        const DicomTag& tag,