changeset 579:2556d9fd27c6 annotations

fix namespaces
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Sep 2026 14:29:13 +0200
parents d1a9fb8cc45a
children be0aa2c9d0b1
files ViewerPlugin/Annotations/CachedAnnotationsWorkspace.cpp ViewerPlugin/Annotations/CachedUserFeatures.cpp ViewerPlugin/Annotations/IAuthenticatedUser.cpp ViewerPlugin/Annotations/IAuthenticatedUser.h ViewerPlugin/Annotations/UserId.cpp ViewerPlugin/Annotations/UserId.h ViewerPlugin/DicomPyramidCache.cpp ViewerPlugin/OrthancPyramidFrameFetcher.cpp
diffstat 8 files changed, 408 insertions(+), 393 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/Annotations/CachedAnnotationsWorkspace.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/CachedAnnotationsWorkspace.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -29,27 +29,27 @@
 #include <Cache/SharedObjectCache.h>
 
 
-static Orthanc::SharedObjectCache& GetCache()
+namespace OrthancWSI
 {
-  static boost::mutex  mutex;
-  static std::unique_ptr<Orthanc::SharedObjectCache>  cache;
+  static Orthanc::SharedObjectCache& GetCache()
+  {
+    static boost::mutex  mutex;
+    static std::unique_ptr<Orthanc::SharedObjectCache>  cache;
 
-  {
-    boost::mutex::scoped_lock lock(mutex);
+    {
+      boost::mutex::scoped_lock lock(mutex);
 
-    if (cache.get() == NULL)
-    {
-      const unsigned int cacheSize = OrthancWSI::ViewerConfiguration::GetInstance().GetAnnotationsCacheSize();
-      cache.reset(new Orthanc::SharedObjectCache(cacheSize));
+      if (cache.get() == NULL)
+      {
+        const unsigned int cacheSize = ViewerConfiguration::GetInstance().GetAnnotationsCacheSize();
+        cache.reset(new Orthanc::SharedObjectCache(cacheSize));
+      }
+
+      return *cache;
     }
-
-    return *cache;
   }
-}
 
 
-namespace OrthancWSI
-{
   CachedAnnotationsWorkspace::CachedAnnotationsWorkspace(const AnnotationsWorkspaceId& id)
   {
     const std::string key = id.GetInfoKey();
--- a/ViewerPlugin/Annotations/CachedUserFeatures.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/CachedUserFeatures.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -29,27 +29,27 @@
 #include <Cache/SharedObjectCache.h>
 
 
-static Orthanc::SharedObjectCache& GetCache()
+namespace OrthancWSI
 {
-  static boost::mutex  mutex;
-  static std::unique_ptr<Orthanc::SharedObjectCache>  cache;
+  static Orthanc::SharedObjectCache& GetCache()
+  {
+    static boost::mutex  mutex;
+    static std::unique_ptr<Orthanc::SharedObjectCache>  cache;
 
-  {
-    boost::mutex::scoped_lock lock(mutex);
+    {
+      boost::mutex::scoped_lock lock(mutex);
 
-    if (cache.get() == NULL)
-    {
-      const unsigned int cacheSize = OrthancWSI::ViewerConfiguration::GetInstance().GetFeaturesCacheSize();
-      cache.reset(new Orthanc::SharedObjectCache(cacheSize));
+      if (cache.get() == NULL)
+      {
+        const unsigned int cacheSize = ViewerConfiguration::GetInstance().GetFeaturesCacheSize();
+        cache.reset(new Orthanc::SharedObjectCache(cacheSize));
+      }
+
+      return *cache;
     }
-
-    return *cache;
   }
-}
 
 
-namespace OrthancWSI
-{
   CachedUserFeatures::CachedUserFeatures(const AnnotationsWorkspaceId& id,
                                          const UserId& user)
   {
--- a/ViewerPlugin/Annotations/IAuthenticatedUser.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/IAuthenticatedUser.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -36,297 +36,301 @@
 #include <cassert>
 #include <json/reader.h>
 
-namespace
+
+namespace OrthancWSI
 {
-  // If Orthanc runs without an authentication plugin
-  class RootUser : public IAuthenticatedUser
-  {
-  public:
-    virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
-    {
-      return UserId(UserId::Type_Root);
-    }
-
-    virtual std::string Format() const ORTHANC_OVERRIDE
-    {
-      return "(root)";
-    }
-
-    virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
-    {
-      return ProjectRole_Instructor;
-    }
-  };
-
-
-  class GuestUser : public IAuthenticatedUser
+  namespace
   {
-  public:
-    virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
-    {
-      // Anonymous users cannot save annotations
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess);
-    }
-
-    virtual std::string Format() const ORTHANC_OVERRIDE
-    {
-      return "(guest)";
-    }
-
-    virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
+    // If Orthanc runs without an authentication plugin
+    class RootUser : public IAuthenticatedUser
     {
-      return ProjectRole_Guest;
-    }
-  };
-
+    public:
+      virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
+      {
+        return UserId(UserId::Type_Root);
+      }
 
-  class EducationPluginAuthenticatedUser : public IAuthenticatedUser
-  {
-  public:
-    enum EducationRole
-    {
-      EducationRole_Administrator,
-      EducationRole_Standard,
-      EducationRole_Guest
+      virtual std::string Format() const ORTHANC_OVERRIDE
+      {
+        return "(root)";
+      }
+
+      virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
+      {
+        return ProjectRole_Instructor;
+      }
     };
 
-  private:
-    std::string            id_;
-    EducationRole          role_;
-    std::set<std::string>  instructorOfProjects_;
-    std::set<std::string>  learnerOfProjects_;
-
-  public:
-    explicit EducationPluginAuthenticatedUser(const Json::Value& authentication)
-    {
-      assert(Orthanc::SerializationToolbox::ReadString(authentication, "source") == "orthanc-education");
-
-      id_ = Orthanc::SerializationToolbox::ReadString(authentication, "id");
-
-      const std::string role = Orthanc::SerializationToolbox::ReadString(authentication, "role");
 
-      if (role == "admin")
+    class GuestUser : public IAuthenticatedUser
+    {
+    public:
+      virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
       {
-        role_ = EducationRole_Administrator;
-      }
-      else if (role == "standard")
-      {
-        role_ = EducationRole_Standard;
+        // Anonymous users cannot save annotations
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess);
       }
-      else if (role == "guest")
+
+      virtual std::string Format() const ORTHANC_OVERRIDE
       {
-        role_ = EducationRole_Guest;
-      }
-      else
-      {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+        return "(guest)";
       }
 
-      Orthanc::SerializationToolbox::ReadSetOfStrings(instructorOfProjects_, authentication, "instructor_of");
-      Orthanc::SerializationToolbox::ReadSetOfStrings(learnerOfProjects_, authentication, "learner_of");
-    }
-
-    virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
-    {
-      switch (role_)
+      virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
       {
-      case EducationRole_Administrator:
-        return UserId(UserId::Type_Root);
-
-      case EducationRole_Standard:
-        return UserId(UserId::Type_Standard, id_);
-
-      case EducationRole_Guest:
-        // Anonymous users cannot save annotations
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess);
-
-      default:
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+        return ProjectRole_Guest;
       }
-    }
+    };
 
-    virtual std::string Format() const ORTHANC_OVERRIDE
+
+    class EducationPluginAuthenticatedUser : public IAuthenticatedUser
     {
-      return id_;
-    }
-
-    virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
-    {
-      switch (role_)
+    public:
+      enum EducationRole
       {
-      case EducationRole_Administrator:
-        return ProjectRole_Instructor;
+        EducationRole_Administrator,
+        EducationRole_Standard,
+        EducationRole_Guest
+      };
+
+    private:
+      std::string            id_;
+      EducationRole          role_;
+      std::set<std::string>  instructorOfProjects_;
+      std::set<std::string>  learnerOfProjects_;
 
-      case EducationRole_Standard:
-        if (instructorOfProjects_.find(projectId) != instructorOfProjects_.end())
+    public:
+      explicit EducationPluginAuthenticatedUser(const Json::Value& authentication)
+      {
+        assert(Orthanc::SerializationToolbox::ReadString(authentication, "source") == "orthanc-education");
+
+        id_ = Orthanc::SerializationToolbox::ReadString(authentication, "id");
+
+        const std::string role = Orthanc::SerializationToolbox::ReadString(authentication, "role");
+
+        if (role == "admin")
         {
-          return ProjectRole_Instructor;
+          role_ = EducationRole_Administrator;
         }
-        else if (learnerOfProjects_.find(projectId) != learnerOfProjects_.end())
+        else if (role == "standard")
         {
-          return ProjectRole_Learner;
+          role_ = EducationRole_Standard;
+        }
+        else if (role == "guest")
+        {
+          role_ = EducationRole_Guest;
         }
         else
         {
-          return ProjectRole_Guest;
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
         }
 
-      case EducationRole_Guest:
-        return ProjectRole_Guest;
+        Orthanc::SerializationToolbox::ReadSetOfStrings(instructorOfProjects_, authentication, "instructor_of");
+        Orthanc::SerializationToolbox::ReadSetOfStrings(learnerOfProjects_, authentication, "learner_of");
+      }
+
+      virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
+      {
+        switch (role_)
+        {
+          case EducationRole_Administrator:
+            return UserId(UserId::Type_Root);
+
+          case EducationRole_Standard:
+            return UserId(UserId::Type_Standard, id_);
+
+          case EducationRole_Guest:
+            // Anonymous users cannot save annotations
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess);
+
+          default:
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+        }
+      }
+
+      virtual std::string Format() const ORTHANC_OVERRIDE
+      {
+        return id_;
+      }
 
-      default:
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+      virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
+      {
+        switch (role_)
+        {
+          case EducationRole_Administrator:
+            return ProjectRole_Instructor;
+
+          case EducationRole_Standard:
+            if (instructorOfProjects_.find(projectId) != instructorOfProjects_.end())
+            {
+              return ProjectRole_Instructor;
+            }
+            else if (learnerOfProjects_.find(projectId) != learnerOfProjects_.end())
+            {
+              return ProjectRole_Learner;
+            }
+            else
+            {
+              return ProjectRole_Guest;
+            }
+
+          case EducationRole_Guest:
+            return ProjectRole_Guest;
+
+          default:
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+        }
       }
-    }
-  };
+    };
 
 
-  class GenericInstructor : public IAuthenticatedUser
-  {
-  private:
-    std::string  username_;
-
-  public:
-    explicit GenericInstructor(const std::string& username) :
-      username_(username)
-    {
-    }
-
-    virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
+    class GenericInstructor : public IAuthenticatedUser
     {
-      return UserId(UserId::Type_Standard, username_);
-    }
+    private:
+      std::string  username_;
+
+    public:
+      explicit GenericInstructor(const std::string& username) :
+        username_(username)
+      {
+      }
 
-    virtual std::string Format() const ORTHANC_OVERRIDE
-    {
-      return username_;
-    }
+      virtual UserId GetAnnotatingId() const ORTHANC_OVERRIDE
+      {
+        return UserId(UserId::Type_Standard, username_);
+      }
 
-    virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
-    {
-      return ProjectRole_Instructor;
-    }
-  };
-}
+      virtual std::string Format() const ORTHANC_OVERRIDE
+      {
+        return username_;
+      }
+
+      virtual ProjectRole GetRoleInProject(const std::string& projectId) const ORTHANC_OVERRIDE
+      {
+        return ProjectRole_Instructor;
+      }
+    };
+  }
 
 
-static IAuthenticatedUser* FromRegisteredUsers(const OrthancPluginHttpRequest* request)
-{
-  for (uint32_t i = 0; i < request->headersCount; i++)
+  static IAuthenticatedUser* FromRegisteredUsers(const OrthancPluginHttpRequest* request)
   {
-    if (std::string(request->headersKeys[i]) == "authorization")
+    for (uint32_t i = 0; i < request->headersCount; i++)
     {
-      const std::string value(request->headersValues[i]);
+      if (std::string(request->headersKeys[i]) == "authorization")
+      {
+        const std::string value(request->headersValues[i]);
 
-      std::vector<std::string> tokens;
-      Orthanc::Toolbox::TokenizeString(tokens, value, ' ');
+        std::vector<std::string> tokens;
+        Orthanc::Toolbox::TokenizeString(tokens, value, ' ');
 
-      if (tokens.size() == 2 &&
-          tokens[0] == "Basic")
-      {
-        std::string decoded;
-        Orthanc::Toolbox::DecodeBase64(decoded, tokens[1]);
+        if (tokens.size() == 2 &&
+            tokens[0] == "Basic")
+        {
+          std::string decoded;
+          Orthanc::Toolbox::DecodeBase64(decoded, tokens[1]);
 
-        Orthanc::Toolbox::TokenizeString(tokens, decoded, ':');
-        if (!tokens.empty() &&
-            !tokens[0].empty())
-        {
-          return new GenericInstructor(tokens[0]);
+          Orthanc::Toolbox::TokenizeString(tokens, decoded, ':');
+          if (!tokens.empty() &&
+              !tokens[0].empty())
+          {
+            return new GenericInstructor(tokens[0]);
+          }
         }
       }
     }
+
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess,
+                                    "Forbidden access, HTTP basic authentication is missing");
   }
 
-  throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess,
-                                  "Forbidden access, HTTP basic authentication is missing");
-}
-
 
-static IAuthenticatedUser* FromHttpHeader(const OrthancPluginHttpRequest* request)
-{
-  const std::string& header = OrthancWSI::ViewerConfiguration::GetInstance().GetAuthenticationHttpHeader();
+  static IAuthenticatedUser* FromHttpHeader(const OrthancPluginHttpRequest* request)
+  {
+    const std::string& header = ViewerConfiguration::GetInstance().GetAuthenticationHttpHeader();
 
-  for (uint32_t i = 0; i < request->headersCount; i++)
-  {
-    if (std::string(request->headersKeys[i]) == header)
+    for (uint32_t i = 0; i < request->headersCount; i++)
     {
-      const std::string user(request->headersValues[i]);
-
-      if (user.empty())
+      if (std::string(request->headersKeys[i]) == header)
       {
-        return new GuestUser;
-      }
-      else
-      {
-        return new GenericInstructor(request->headersValues[i]);
+        const std::string user(request->headersValues[i]);
+
+        if (user.empty())
+        {
+          return new GuestUser;
+        }
+        else
+        {
+          return new GenericInstructor(request->headersValues[i]);
+        }
       }
     }
+
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess,
+                                    "Forbidden access, as HTTP header \"" + header + "\" is not set by your proxy");
   }
 
-  throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess,
-                                  "Forbidden access, as HTTP header \"" + header + "\" is not set by your proxy");
-}
-
 
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 9)
-static IAuthenticatedUser* FromPlugin(const OrthancPluginHttpRequest* request)
-{
-  if (request->authenticationPayloadSize == 0)
+  static IAuthenticatedUser* FromPlugin(const OrthancPluginHttpRequest* request)
   {
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "No authentication plugin is properly installed");
-  }
-  else
-  {
-    const char* payload = reinterpret_cast<const char*>(request->authenticationPayload);
+    if (request->authenticationPayloadSize == 0)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "No authentication plugin is properly installed");
+    }
+    else
+    {
+      const char* payload = reinterpret_cast<const char*>(request->authenticationPayload);
 
-    // We use "Json::Reader" as "Orthanc::ReadJson()" would write an
-    // error log if the authentication payload is not a JSON string
-    Json::Reader reader;
+      // We use "Json::Reader" as "Orthanc::ReadJson()" would write an
+      // error log if the authentication payload is not a JSON string
+      Json::Reader reader;
 
-    Json::Value authentication;
-    if (reader.parse(payload, payload + request->authenticationPayloadSize, authentication, false))
-    {
-      const std::string source = Orthanc::SerializationToolbox::ReadString(authentication, "source", "(none)");
+      Json::Value authentication;
+      if (reader.parse(payload, payload + request->authenticationPayloadSize, authentication, false))
+      {
+        const std::string source = Orthanc::SerializationToolbox::ReadString(authentication, "source", "(none)");
 
-      if (source == "orthanc-education")
-      {
-        return new EducationPluginAuthenticatedUser(authentication);
+        if (source == "orthanc-education")
+        {
+          return new EducationPluginAuthenticatedUser(authentication);
+        }
+        else
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unknown authentication plugin: " + source);
+        }
       }
-      else
-      {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unknown authentication plugin: " + source);
-      }
+
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unknown authentication plugin");
     }
-
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unknown authentication plugin");
   }
-}
 #endif
 
 
 
-IAuthenticatedUser* IAuthenticatedUser::FromHttpRequest(const OrthancPluginHttpRequest* request)
-{
-  switch (OrthancWSI::ViewerConfiguration::GetInstance().GetAuthenticationSource())
+  IAuthenticatedUser* IAuthenticatedUser::FromHttpRequest(const OrthancPluginHttpRequest* request)
   {
-  case OrthancWSI::AuthenticationSource_None:
-    // No authentication is available, use the root user of Orthanc
-    return new RootUser;
+    switch (ViewerConfiguration::GetInstance().GetAuthenticationSource())
+    {
+      case AuthenticationSource_None:
+        // No authentication is available, use the root user of Orthanc
+        return new RootUser;
 
-  case OrthancWSI::AuthenticationSource_RegisteredUsers:
-    return FromRegisteredUsers(request);
+      case AuthenticationSource_RegisteredUsers:
+        return FromRegisteredUsers(request);
 
-  case OrthancWSI::AuthenticationSource_HttpHeader:
-    return FromHttpHeader(request);
+      case AuthenticationSource_HttpHeader:
+        return FromHttpHeader(request);
 
-  case OrthancWSI::AuthenticationSource_Plugin:
+      case AuthenticationSource_Plugin:
 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 9)
-    return FromPlugin(request);
+        return FromPlugin(request);
 #else
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
 #endif
 
-  default:
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
   }
 }
--- a/ViewerPlugin/Annotations/IAuthenticatedUser.h	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/IAuthenticatedUser.h	Thu Sep 03 14:29:13 2026 +0200
@@ -29,25 +29,29 @@
 
 #include <boost/noncopyable.hpp>
 
-class IAuthenticatedUser : public boost::noncopyable
+
+namespace OrthancWSI
 {
-public:
-  enum ProjectRole
+  class IAuthenticatedUser : public boost::noncopyable
   {
-    ProjectRole_Instructor,
-    ProjectRole_Learner,
-    ProjectRole_Guest
-  };
+  public:
+    enum ProjectRole
+    {
+      ProjectRole_Instructor,
+      ProjectRole_Learner,
+      ProjectRole_Guest
+    };
 
-  virtual ~IAuthenticatedUser()
-  {
-  }
+    virtual ~IAuthenticatedUser()
+    {
+    }
 
-  virtual UserId GetAnnotatingId() const = 0;
+    virtual UserId GetAnnotatingId() const = 0;
 
-  virtual std::string Format() const = 0;
+    virtual std::string Format() const = 0;
+
+    virtual ProjectRole GetRoleInProject(const std::string& projectId) const = 0;
 
-  virtual ProjectRole GetRoleInProject(const std::string& projectId) const = 0;
-
-  static IAuthenticatedUser* FromHttpRequest(const OrthancPluginHttpRequest* request);
-};
+    static IAuthenticatedUser* FromHttpRequest(const OrthancPluginHttpRequest* request);
+  };
+}
--- a/ViewerPlugin/Annotations/UserId.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/UserId.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -33,110 +33,113 @@
 static const char* const KEY_NAME = "name";
 
 
-void UserId::Setup(Type type,
-                   const std::string& name)
+namespace OrthancWSI
 {
-  type_ = type;
-  name_ = name;
+  void UserId::Setup(Type type,
+                     const std::string& name)
+  {
+    type_ = type;
+    name_ = name;
 
-  switch (type_)
-  {
-  case Type_Invalid:
-  case Type_Root:
-    if (!name.empty())
+    switch (type_)
     {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+      case Type_Invalid:
+      case Type_Root:
+        if (!name.empty())
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+        }
+        break;
+
+      case Type_Standard:
+        if (name.empty())
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+        }
+        break;
+
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
-    break;
-
-  case Type_Standard:
-    if (name.empty())
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
-    }
-    break;
-
-  default:
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
   }
-}
 
 
-UserId::UserId(const Json::Value& serialized)
-{
-  Setup(static_cast<Type>(Orthanc::SerializationToolbox::ReadInteger(serialized, KEY_TYPE)),
-        Orthanc::SerializationToolbox::ReadString(serialized, KEY_NAME));
-}
+  UserId::UserId(const Json::Value& serialized)
+  {
+    Setup(static_cast<Type>(Orthanc::SerializationToolbox::ReadInteger(serialized, KEY_TYPE)),
+          Orthanc::SerializationToolbox::ReadString(serialized, KEY_NAME));
+  }
 
 
-bool UserId::Equals(const UserId& other) const
-{
-  if (type_ != other.type_)
-  {
-    return false;
-  }
-  else if (type_ == Type_Standard)
+  bool UserId::Equals(const UserId& other) const
   {
-    return name_ == other.name_;
+    if (type_ != other.type_)
+    {
+      return false;
+    }
+    else if (type_ == Type_Standard)
+    {
+      return name_ == other.name_;
+    }
+    else
+    {
+      return true;
+    }
   }
-  else
-  {
-    return true;
-  }
-}
 
 
-bool UserId::operator<(const UserId& other) const
-{
-  if (type_ < other.type_)
-  {
-    return true;
-  }
-  else if (type_ > other.type_)
+  bool UserId::operator<(const UserId& other) const
   {
-    return false;
+    if (type_ < other.type_)
+    {
+      return true;
+    }
+    else if (type_ > other.type_)
+    {
+      return false;
+    }
+    else
+    {
+      return name_ < other.name_;
+    }
   }
-  else
-  {
-    return name_ < other.name_;
-  }
-}
 
 
-std::string UserId::GetKey() const
-{
-  switch (type_)
+  std::string UserId::GetKey() const
   {
-  case Type_Root:
-    return "root";
+    switch (type_)
+    {
+      case Type_Root:
+        return "root";
 
-  case Type_Standard:
-  {
-    // The pipe character "|" is not part of Base64, so we can safely use it to separate components
-    std::string s;
-    Orthanc::Toolbox::EncodeBase64(s, name_);
-    return "user_" + s;
+      case Type_Standard:
+      {
+        // The pipe character "|" is not part of Base64, so we can safely use it to separate components
+        std::string s;
+        Orthanc::Toolbox::EncodeBase64(s, name_);
+        return "user_" + s;
+      }
+
+      case Type_Invalid:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+    }
   }
 
-  case Type_Invalid:
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
 
-  default:
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+  void UserId::Serialize(Json::Value& target) const
+  {
+    if (type_ == Type_Invalid)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+    }
+    else
+    {
+      target = Json::objectValue;
+      target[KEY_TYPE] = static_cast<int>(type_);
+      target[KEY_NAME] = name_;
+    }
   }
 }
-
-
-void UserId::Serialize(Json::Value& target) const
-{
-  if (type_ == Type_Invalid)
-  {
-    throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-  }
-  else
-  {
-    target = Json::objectValue;
-    target[KEY_TYPE] = static_cast<int>(type_);
-    target[KEY_NAME] = name_;
-  }
-}
--- a/ViewerPlugin/Annotations/UserId.h	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/Annotations/UserId.h	Thu Sep 03 14:29:13 2026 +0200
@@ -26,57 +26,61 @@
 #include <json/value.h>
 #include <string>
 
-class UserId
+
+namespace OrthancWSI
 {
-public:
-  enum Type
-  {
-    Type_Root,
-    Type_Standard,
-    Type_Invalid
-  };
-
-private:
-  Type         type_;
-  std::string  name_;
-
-  void Setup(Type type,
-             const std::string& name);
-
-public:
-  explicit UserId()
-  {
-    Setup(Type_Invalid, "");
-  }
-
-  explicit UserId(Type type)
+  class UserId
   {
-    Setup(type, "");
-  }
+  public:
+    enum Type
+    {
+      Type_Root,
+      Type_Standard,
+      Type_Invalid
+    };
+
+  private:
+    Type         type_;
+    std::string  name_;
 
-  UserId(Type type,
-         const std::string& name)
-  {
-    Setup(type, name);
-  }
+    void Setup(Type type,
+               const std::string& name);
 
-  explicit UserId(const Json::Value& serialized);
+  public:
+    explicit UserId()
+    {
+      Setup(Type_Invalid, "");
+    }
+
+    explicit UserId(Type type)
+    {
+      Setup(type, "");
+    }
 
-  Type GetType() const
-  {
-    return type_;
-  }
+    UserId(Type type,
+           const std::string& name)
+    {
+      Setup(type, name);
+    }
+
+    explicit UserId(const Json::Value& serialized);
+
+    Type GetType() const
+    {
+      return type_;
+    }
 
-  const std::string& GetName() const
-  {
-    return name_;
-  }
+    const std::string& GetName() const
+    {
+      return name_;
+    }
 
-  bool Equals(const UserId& other) const;
+    bool Equals(const UserId& other) const;
 
-  bool operator<(const UserId& other) const;
+    bool operator<(const UserId& other) const;
+
+    std::string GetKey() const;
 
-  std::string GetKey() const;
-
-  void Serialize(Json::Value& target) const;
-};
+    void Serialize(Json::Value& target) const;
+  };
+}
--- a/ViewerPlugin/DicomPyramidCache.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/DicomPyramidCache.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -162,7 +162,7 @@
   {
     if (singleton_.get() == NULL)
     {
-      singleton_.reset(new DicomPyramidCache(new OrthancWSI::OrthancPluginConnection, maxSize, useMetadataCache));
+      singleton_.reset(new DicomPyramidCache(new OrthancPluginConnection, maxSize, useMetadataCache));
     }
     else
     {
--- a/ViewerPlugin/OrthancPyramidFrameFetcher.cpp	Thu Sep 03 09:50:36 2026 +0200
+++ b/ViewerPlugin/OrthancPyramidFrameFetcher.cpp	Thu Sep 03 14:29:13 2026 +0200
@@ -129,7 +129,7 @@
 
     if (paddingX_ >= 2)
     {
-      paddedWidth = OrthancWSI::CeilingDivision(frame->GetWidth(), paddingX_) * paddingX_;
+      paddedWidth = CeilingDivision(frame->GetWidth(), paddingX_) * paddingX_;
     }
     else
     {
@@ -138,7 +138,7 @@
 
     if (paddingY_ >= 2)
     {
-      paddedHeight = OrthancWSI::CeilingDivision(frame->GetHeight(), paddingY_) * paddingY_;
+      paddedHeight = CeilingDivision(frame->GetHeight(), paddingY_) * paddingY_;
     }
     else
     {