changeset 3099:9c71abbff70f db-changes

removing build dependency on plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Jan 2019 16:13:16 +0100
parents 717efd0989f9
children f6de9d25b20d
files OrthancServer/Database/Compatibility/DatabaseLookup.h OrthancServer/Database/ResourcesContent.cpp OrthancServer/Database/ResourcesContent.h OrthancServer/ServerToolbox.cpp Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Include/orthanc/OrthancCDatabasePlugin.h
diffstat 6 files changed, 66 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Database/Compatibility/DatabaseLookup.h	Sun Jan 06 12:43:19 2019 +0100
+++ b/OrthancServer/Database/Compatibility/DatabaseLookup.h	Mon Jan 07 16:13:16 2019 +0100
@@ -43,11 +43,11 @@
     class DatabaseLookup : public boost::noncopyable
     {
     private:
-      IDatabaseWrapper&              database_;
+      IDatabaseWrapper&  database_;
       ILookupResources&  compatibility_;
 
     public:
-      DatabaseLookup(IDatabaseWrapper&  database,
+      DatabaseLookup(IDatabaseWrapper& database,
                      ILookupResources& compatibility) :
         database_(database),
         compatibility_(compatibility)
--- a/OrthancServer/Database/ResourcesContent.cpp	Sun Jan 06 12:43:19 2019 +0100
+++ b/OrthancServer/Database/ResourcesContent.cpp	Mon Jan 07 16:13:16 2019 +0100
@@ -62,47 +62,4 @@
       compatibility.SetMetadata(it->resourceId_, it->metadata_,  it->value_);
     }
   }
-
-
-  void ResourcesContent::EncodeForPlugins(
-    std::vector<OrthancPluginResourcesContentTags>& identifierTags,
-    std::vector<OrthancPluginResourcesContentTags>& mainDicomTags,
-    std::vector<OrthancPluginResourcesContentMetadata>& metadata) const
-  {
-    identifierTags.reserve(tags_.size());
-    mainDicomTags.reserve(tags_.size());
-    metadata.reserve(metadata_.size());
-
-    for (std::list<TagValue>::const_iterator
-           it = tags_.begin(); it != tags_.end(); ++it)
-    {
-      OrthancPluginResourcesContentTags tmp;
-      tmp.resource = it->resourceId_;
-      tmp.group = it->tag_.GetGroup();
-      tmp.element = it->tag_.GetElement();
-      tmp.value = it->value_.c_str();
-
-      if (it->isIdentifier_)
-      {
-        identifierTags.push_back(tmp);
-      }
-      else
-      {
-        mainDicomTags.push_back(tmp);
-      }
-    }
-
-    for (std::list<Metadata>::const_iterator
-           it = metadata_.begin(); it != metadata_.end(); ++it)
-    {
-      OrthancPluginResourcesContentMetadata tmp;
-      tmp.resource = it->resourceId_;
-      tmp.metadata = it->metadata_;
-      tmp.value = it->value_.c_str();
-      metadata.push_back(tmp);
-    }
-
-    assert(identifierTags.size() + mainDicomTags.size() == tags_.size() &&
-           metadata.size() == metadata_.size());
-  }
 }
--- a/OrthancServer/Database/ResourcesContent.h	Sun Jan 06 12:43:19 2019 +0100
+++ b/OrthancServer/Database/ResourcesContent.h	Mon Jan 07 16:13:16 2019 +0100
@@ -36,11 +36,10 @@
 #include "../../Core/DicomFormat/DicomMap.h"
 #include "../ServerEnumerations.h"
 
-#include <orthanc/OrthancCDatabasePlugin.h>
-
 #include <boost/noncopyable.hpp>
 #include <list>
 
+
 namespace Orthanc
 {
   namespace Compatibility
@@ -50,7 +49,7 @@
   
   class ResourcesContent : public boost::noncopyable
   {
-  private:
+  public:
     struct TagValue
     {
       int64_t      resourceId_;
@@ -86,8 +85,12 @@
       }
     };
 
-    std::list<TagValue>  tags_;
-    std::list<Metadata>  metadata_;
+    typedef std::list<TagValue>  ListTags;
+    typedef std::list<Metadata>  ListMetadata;
+    
+  private:
+    ListTags       tags_;
+    ListMetadata   metadata_;
 
   public:
     void AddMainDicomTag(int64_t resourceId,
@@ -118,11 +121,14 @@
     // WARNING: The database should be locked with a transaction!
     void Store(Compatibility::ISetResourcesContent& target) const;
 
-    // WARNING: The resulting C structure will contain pointers to the
-    // current object. Don't delete or modify it!
-    void EncodeForPlugins(
-      std::vector<OrthancPluginResourcesContentTags>& identifierTags,
-      std::vector<OrthancPluginResourcesContentTags>& mainDicomTags,
-      std::vector<OrthancPluginResourcesContentMetadata>& metadata) const;
+    const ListTags& GetListTags() const
+    {
+      return tags_;
+    }
+
+    const ListMetadata& GetListMetadata() const
+    {
+      return metadata_;
+    }
   };
 }
--- a/OrthancServer/ServerToolbox.cpp	Sun Jan 06 12:43:19 2019 +0100
+++ b/OrthancServer/ServerToolbox.cpp	Mon Jan 07 16:13:16 2019 +0100
@@ -39,8 +39,8 @@
 #include "../Core/FileStorage/StorageAccessor.h"
 #include "../Core/Logging.h"
 #include "../Core/OrthancException.h"
-#include "../Plugins/Engine/OrthancPlugins.h"
 #include "Database/IDatabaseWrapper.h"
+#include "Database/ResourcesContent.h"
 #include "ServerContext.h"
 
 #include <cassert>
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Sun Jan 06 12:43:19 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Jan 07 16:13:16 2019 +0100
@@ -1294,8 +1294,43 @@
       std::vector<OrthancPluginResourcesContentTags> identifierTags;
       std::vector<OrthancPluginResourcesContentTags> mainDicomTags;
       std::vector<OrthancPluginResourcesContentMetadata> metadata;
-      content.EncodeForPlugins(identifierTags, mainDicomTags, metadata);
+
+      identifierTags.reserve(content.GetListTags().size());
+      mainDicomTags.reserve(content.GetListTags().size());
+      metadata.reserve(content.GetListMetadata().size());
+
+      for (ResourcesContent::ListTags::const_iterator
+             it = content.GetListTags().begin(); it != content.GetListTags().end(); ++it)
+      {
+        OrthancPluginResourcesContentTags tmp;
+        tmp.resource = it->resourceId_;
+        tmp.group = it->tag_.GetGroup();
+        tmp.element = it->tag_.GetElement();
+        tmp.value = it->value_.c_str();
 
+        if (it->isIdentifier_)
+        {
+          identifierTags.push_back(tmp);
+        }
+        else
+        {
+          mainDicomTags.push_back(tmp);
+        }
+      }
+
+      for (ResourcesContent::ListMetadata::const_iterator
+             it = content.GetListMetadata().begin(); it != content.GetListMetadata().end(); ++it)
+      {
+        OrthancPluginResourcesContentMetadata tmp;
+        tmp.resource = it->resourceId_;
+        tmp.metadata = it->metadata_;
+        tmp.value = it->value_.c_str();
+        metadata.push_back(tmp);
+      }
+
+      assert(identifierTags.size() + mainDicomTags.size() == content.GetListTags().size() &&
+             metadata.size() == content.GetListMetadata().size());
+       
       CheckSuccess(extensions_.setResourcesContent(
                      payload_,
                      identifierTags.size(),
--- a/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Sun Jan 06 12:43:19 2019 +0100
+++ b/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Mon Jan 07 16:13:16 2019 +0100
@@ -701,6 +701,10 @@
 
   typedef struct
   {
+    /**
+     * Extensions since Orthanc 0.9.5
+     **/
+    
     /* Output: Use OrthancPluginDatabaseAnswerString() */
     OrthancPluginErrorCode  (*getAllPublicIdsWithLimit) (
       /* outputs */
@@ -746,6 +750,11 @@
       const OrthancPluginDicomTag* tag,
       OrthancPluginIdentifierConstraint constraint);
 
+
+    /**
+     * Extensions since Orthanc 1.4.0
+     **/
+    
     /* Output: Use OrthancPluginDatabaseAnswerInt64() */
     OrthancPluginErrorCode  (*lookupIdentifierRange) (
       /* outputs */
@@ -775,6 +784,7 @@
       uint32_t limit,
       uint8_t requestSomeInstance);
 
+    
     OrthancPluginErrorCode  (*createInstance) (
       /* output */
       OrthancPluginCreateInstanceResult* output,