Mercurial > hg > orthanc-wsi
annotate ViewerPlugin/DicomPyramidCache.h @ 334:f011fc199b6a default tip
back to mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Oct 2024 15:44:18 +0200 |
parents | 0683312e21ba |
children |
rev | line source |
---|---|
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
312
0683312e21ba
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
309
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0683312e21ba
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
309
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
309
7020852a8fa9
updated year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU Affero General Public License |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * the License, or (at your option) any later version. |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * Affero General Public License for more details. |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU Affero General Public License |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #pragma once |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../Framework/Inputs/DicomPyramid.h" |
140
a0f9a3df1110
resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
115
diff
changeset
|
27 |
192 | 28 #include <Cache/LeastRecentlyUsedIndex.h> |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include <boost/thread/mutex.hpp> |
261 | 31 #include <string> |
32 | |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 namespace OrthancWSI |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 class DicomPyramidCache : public boost::noncopyable |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 private: |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 typedef Orthanc::LeastRecentlyUsedIndex<std::string, DicomPyramid*> Cache; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
261 | 41 std::unique_ptr<OrthancStone::IOrthancConnection> orthanc_; |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
261 | 43 boost::mutex mutex_; |
44 size_t maxSize_; | |
45 Cache cache_; | |
46 | |
47 DicomPyramidCache(OrthancStone::IOrthancConnection* orthanc /* takes ownership */, | |
48 size_t maxSize); | |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 DicomPyramid* GetCachedPyramid(const std::string& seriesId); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 DicomPyramid& GetPyramid(const std::string& seriesId, |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 boost::mutex::scoped_lock& lock); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 public: |
261 | 56 ~DicomPyramidCache(); |
57 | |
58 static void InitializeInstance(size_t maxSize); | |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
261 | 60 static void FinalizeInstance(); |
61 | |
62 static DicomPyramidCache& GetInstance(); | |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 void Invalidate(const std::string& seriesId); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 class Locker : public boost::noncopyable |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 private: |
261 | 69 DicomPyramidCache& cache_; |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 boost::mutex::scoped_lock lock_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 DicomPyramid& pyramid_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 public: |
291 | 74 explicit Locker(const std::string& seriesId); |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 DicomPyramid& GetPyramid() const |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 return pyramid_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 } |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 }; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 }; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |