changeset 2214:b1d93286b315

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Dec 2016 11:24:58 +0100
parents 95d1d758abb7
children 028214a95194
files Plugins/Samples/Common/OrthancPluginCppWrapper.h Plugins/Samples/ModalityWorklists/Plugin.cpp
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Sat Dec 10 10:17:44 2016 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Sat Dec 10 11:24:58 2016 +0100
@@ -353,6 +353,11 @@
 
     bool IsMatch(const void*  dicom,
                  uint32_t     size) const;
+
+    bool IsMatch(const MemoryBuffer& dicom) const
+    {
+      return IsMatch(dicom.GetData(), dicom.GetSize());
+    }
   };
 
 
--- a/Plugins/Samples/ModalityWorklists/Plugin.cpp	Sat Dec 10 10:17:44 2016 +0100
+++ b/Plugins/Samples/ModalityWorklists/Plugin.cpp	Sat Dec 10 11:24:58 2016 +0100
@@ -34,14 +34,15 @@
 /**
  * This is the main function for matching a DICOM worklist against a query.
  **/
-static void  MatchWorklist(OrthancPluginWorklistAnswers*     answers,
-                           const OrthancPluginWorklistQuery* query,
+static void  MatchWorklist(OrthancPluginWorklistAnswers*      answers,
+                           const OrthancPluginWorklistQuery*  query,
+                           const OrthancPlugins::FindMatcher& matcher,
                            const std::string& path)
 {
   OrthancPlugins::MemoryBuffer dicom(context_);
   dicom.ReadFile(path);
 
-  if (OrthancPluginWorklistIsMatch(context_, query, dicom.GetData(), dicom.GetSize()))
+  if (matcher.IsMatch(dicom))
   {
     // This DICOM file matches the worklist query, add it to the answers
     OrthancPluginErrorCode code = OrthancPluginWorklistAddAnswer
@@ -77,6 +78,8 @@
                               std::string(remoteAet) + ":\n" + json.toStyledString());
     }
 
+    OrthancPlugins::FindMatcher matcher(context_, query);
+
     fs::path source(folder_);
     fs::directory_iterator end;
 
@@ -94,7 +97,7 @@
 
           if (extension == ".wl")
           {
-            MatchWorklist(answers, query, it->path().string());
+            MatchWorklist(answers, query, matcher, it->path().string());
           }
         }
       }