diff Framework/Inputs/OpenSlideLibrary.cpp @ 280:34b507959e32 iiif

integration mainline->iiif
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jul 2023 18:08:27 +0200
parents 169f168ba07a
children 7020852a8fa9
line wrap: on
line diff
--- a/Framework/Inputs/OpenSlideLibrary.cpp	Wed Jul 12 16:14:19 2023 +0200
+++ b/Framework/Inputs/OpenSlideLibrary.cpp	Wed Jul 12 18:08:27 2023 +0200
@@ -44,6 +44,8 @@
     getLevelDownsample_ = (FunctionGetLevelDownsample) library_.GetFunction("openslide_get_level_downsample");
     open_ = (FunctionOpen) library_.GetFunction("openslide_open");
     readRegion_ = (FunctionReadRegion) library_.GetFunction("openslide_read_region");
+    getPropertyNames_ = (FunctionGetPropertyNames) library_.GetFunction("openslide_get_property_names");
+    getPropertyValue_ = (FunctionGetPropertyValue) library_.GetFunction("openslide_get_property_value");
   }
 
 
@@ -144,6 +146,27 @@
     handle_(NULL)
   {
     Initialize(path);
+
+    const char* const* properties = that_.getPropertyNames_(handle_);
+    if (properties == NULL)
+    {
+      that_.close_(handle_);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+    }
+
+    for (size_t i = 0; properties[i] != NULL; i++)
+    {
+      const char* value = that_.getPropertyValue_(handle_, properties[i]);
+      if (value == NULL)
+      {
+        that_.close_(handle_);
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+      }
+      else
+      {
+        properties_[properties[i]] = value;
+      }
+    }
   }
 
 
@@ -237,4 +260,21 @@
   {
     globalLibrary_.reset(NULL);
   }
+
+
+  bool OpenSlideLibrary::Image::LookupProperty(std::string& value,
+                                               const std::string& property) const
+  {
+    std::map<std::string, std::string>::const_iterator found = properties_.find(property);
+
+    if (found == properties_.end())
+    {
+      return false;
+    }
+    else
+    {
+      value = found->second;
+      return true;
+    }
+  }
 }