Mercurial > hg > orthanc-wsi
changeset 575:86082b569b99 annotations
reorganization
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 02 Sep 2026 16:38:56 +0200 |
| parents | 41f3ecfa81bd |
| children | 4c9949987d5f |
| files | ViewerPlugin/Annotations/AnnotationsRestApi.cpp ViewerPlugin/Annotations/CachedUserFeatures.cpp ViewerPlugin/Annotations/CachedUserFeatures.h ViewerPlugin/CMakeLists.txt |
| diffstat | 4 files changed, 121 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/ViewerPlugin/Annotations/AnnotationsRestApi.cpp Wed Sep 02 16:30:04 2026 +0200 +++ b/ViewerPlugin/Annotations/AnnotationsRestApi.cpp Wed Sep 02 16:38:56 2026 +0200 @@ -27,28 +27,21 @@ #include "../ViewerConfiguration.h" #include "../ViewerToolbox.h" #include "CachedAnnotationsWorkspace.h" +#include "CachedUserFeatures.h" #include "IAuthenticatedUser.h" -#include "UserFeatures.h" -#include <Cache/SharedObjectCache.h> -#include <Logging.h> #include <SerializationToolbox.h> +#include <Toolbox.h> #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" +static const char* const KEY_FEATURES = "features"; +static const char* const KEY_LAYER_ID = "layer-id"; + + namespace OrthancWSI { - static const char* const KEY_FEATURES = "features"; - static const char* const KEY_ID = "id"; - static const char* const KEY_LAYERS = "layers"; - static const char* const KEY_NAME = "name"; - static const char* const KEY_PUBLIC = "public"; - static const char* const KEY_PROJECT_NAME = "project-name"; - static const char* const KEY_PROJECT_DESCRIPTION = "project-description"; - static const char* const KEY_LAYER_ID = "layer-id"; - - class AnnotationsCommandContext : public boost::noncopyable { private: @@ -251,50 +244,6 @@ } - class CachedUserFeatures : public boost::noncopyable - { - private: - boost::shared_ptr<Orthanc::IDynamicObject> cached_; - - static Orthanc::SharedObjectCache& GetCache() - { - static boost::mutex mutex; - static std::unique_ptr<Orthanc::SharedObjectCache> cache; - - { - boost::mutex::scoped_lock lock(mutex); - - if (cache.get() == NULL) - { - cache.reset(new Orthanc::SharedObjectCache(ViewerConfiguration::GetInstance().GetFeaturesCacheSize())); - } - - return *cache; - } - } - - public: - CachedUserFeatures(const AnnotationsWorkspaceId& id, - const UserId& user) - { - const std::string key = id.GetFeaturesKey(user); - - cached_ = GetCache().GetCachedValue(key); - - if (cached_.get() == NULL) - { - cached_.reset(new UserFeatures(key)); - GetCache().Store(key, cached_, 1); - } - } - - UserFeatures& GetFeatures() const - { - return dynamic_cast<UserFeatures&>(*cached_); - } - }; - - void LoadUserFeatures(OrthancPluginRestOutput* output, const char* url, const OrthancPluginHttpRequest* request)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ViewerPlugin/Annotations/CachedUserFeatures.cpp Wed Sep 02 16:38:56 2026 +0200 @@ -0,0 +1,66 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2026 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#include "../../Framework/PrecompiledHeadersWSI.h" +#include "CachedUserFeatures.h" + +#include "../ViewerConfiguration.h" + +#include <Cache/SharedObjectCache.h> + + +static Orthanc::SharedObjectCache& GetCache() +{ + static boost::mutex mutex; + static std::unique_ptr<Orthanc::SharedObjectCache> cache; + + { + boost::mutex::scoped_lock lock(mutex); + + if (cache.get() == NULL) + { + const unsigned int cacheSize = OrthancWSI::ViewerConfiguration::GetInstance().GetFeaturesCacheSize(); + cache.reset(new Orthanc::SharedObjectCache(cacheSize)); + } + + return *cache; + } +} + + +namespace OrthancWSI +{ + CachedUserFeatures::CachedUserFeatures(const AnnotationsWorkspaceId& id, + const UserId& user) + { + const std::string key = id.GetFeaturesKey(user); + + cached_ = GetCache().GetCachedValue(key); + + if (cached_.get() == NULL) + { + cached_.reset(new UserFeatures(key)); + GetCache().Store(key, cached_, 1); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ViewerPlugin/Annotations/CachedUserFeatures.h Wed Sep 02 16:38:56 2026 +0200 @@ -0,0 +1,48 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017-2023 Osimis S.A., Belgium + * Copyright (C) 2024-2026 Orthanc Team SRL, Belgium + * Copyright (C) 2021-2026 Sebastien Jodogne, ICTEAM UCLouvain, Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include "AnnotationsWorkspaceId.h" +#include "UserFeatures.h" + +#include <boost/shared_ptr.hpp> + + +namespace OrthancWSI +{ + class CachedUserFeatures : public boost::noncopyable + { + private: + boost::shared_ptr<Orthanc::IDynamicObject> cached_; + + public: + CachedUserFeatures(const AnnotationsWorkspaceId& id, + const UserId& user); + + UserFeatures& GetFeatures() const + { + return dynamic_cast<UserFeatures&>(*cached_); + } + }; +}
--- a/ViewerPlugin/CMakeLists.txt Wed Sep 02 16:30:04 2026 +0200 +++ b/ViewerPlugin/CMakeLists.txt Wed Sep 02 16:38:56 2026 +0200 @@ -189,6 +189,7 @@ Annotations/AnnotationsWorkspace.cpp Annotations/AnnotationsWorkspaceId.cpp Annotations/CachedAnnotationsWorkspace.cpp + Annotations/CachedUserFeatures.cpp Annotations/IAuthenticatedUser.cpp Annotations/ISerializable.cpp Annotations/ImportedLayer.cpp
