changeset 2213:95d1d758abb7

FindMatcher::IsMatch
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Dec 2016 10:17:44 +0100
parents c02f6ec404d8
children b1d93286b315
files Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugins/Samples/Common/OrthancPluginCppWrapper.h
diffstat 2 files changed, 46 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Sat Dec 10 10:05:16 2016 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Sat Dec 10 10:17:44 2016 +0100
@@ -836,12 +836,12 @@
 
 
   FindMatcher::FindMatcher(OrthancPluginContext*              context,
-                           const OrthancPluginWorklistQuery*  query) :
+                           const OrthancPluginWorklistQuery*  worklist) :
     context_(context),
     matcher_(NULL),
-    query_(query)
+    worklist_(worklist)
   {
-    if (query_ == NULL)
+    if (worklist_ == NULL)
     {
       ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange);
     }
@@ -852,7 +852,7 @@
                            const void*            query,
                            uint32_t               size) :
     context_(context),
-    query_(NULL)
+    worklist_(NULL)
   {
     matcher_ = OrthancPluginCreateFindMatcher(context_, query, size);
     if (matcher_ == NULL)
@@ -864,6 +864,8 @@
 
   FindMatcher::~FindMatcher()
   {
+    // The "worklist_" field 
+
     if (matcher_ != NULL)
     {
       OrthancPluginFreeFindMatcher(context_, matcher_);
@@ -871,6 +873,41 @@
   }
 
 
+
+  bool FindMatcher::IsMatch(const void*  dicom,
+                            uint32_t     size) const
+  {
+    int32_t result;
+
+    if (matcher_ != NULL)
+    {
+      result = OrthancPluginFindMatcherIsMatch(context_, matcher_, dicom, size);
+    }
+    else if (worklist_ != NULL)
+    {
+      result = OrthancPluginWorklistIsMatch(context_, worklist_, dicom, size);
+    }
+    else
+    {
+      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError);
+    }
+
+    if (result == 0)
+    {
+      return false;
+    }
+    else if (result == 1)
+    {
+      return true;
+    }
+    else
+    {
+      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InternalError);
+    }
+  }
+
+
+
   bool RestApiGet(Json::Value& result,
                   OrthancPluginContext* context,
                   const std::string& uri,
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Sat Dec 10 10:05:16 2016 +0100
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Sat Dec 10 10:17:44 2016 +0100
@@ -339,17 +339,20 @@
   private:
     OrthancPluginContext*              context_;
     OrthancPluginFindMatcher*          matcher_;
-    const OrthancPluginWorklistQuery*  query_;
+    const OrthancPluginWorklistQuery*  worklist_;
 
   public:
     FindMatcher(OrthancPluginContext*              context,
-                const OrthancPluginWorklistQuery*  query);
+                const OrthancPluginWorklistQuery*  worklist);
 
     FindMatcher(OrthancPluginContext*  context,
                 const void*            query,
                 uint32_t               size);
 
     ~FindMatcher();
+
+    bool IsMatch(const void*  dicom,
+                 uint32_t     size) const;
   };