annotate ViewerPlugin/DicomPyramidCache.h @ 325:047b629616db OrthancWSI-1.1

closing OrthancWSI-1.1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Oct 2024 17:15:32 +0200
parents 49f647ed1b4c
children 20a730889ae2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
214
1e864138f0da upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 196
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
242
49f647ed1b4c added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
73
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * 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
12 *
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * Affero General Public License for more details.
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * 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
19 * 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
20 **/
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 #pragma once
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../Framework/Inputs/DicomPyramid.h"
140
a0f9a3df1110 resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 115
diff changeset
26
192
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 175
diff changeset
27 #include <Cache/LeastRecentlyUsedIndex.h>
73
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <boost/thread/mutex.hpp>
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancWSI
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class DicomPyramidCache : public boost::noncopyable
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 private:
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 typedef Orthanc::LeastRecentlyUsedIndex<std::string, DicomPyramid*> Cache;
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
38 boost::mutex mutex_;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
39 OrthancStone::IOrthancConnection& orthanc_;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
40 size_t maxSize_;
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
41 Cache cache_;
73
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 DicomPyramid* GetCachedPyramid(const std::string& seriesId);
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 DicomPyramid& GetPyramid(const std::string& seriesId,
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 boost::mutex::scoped_lock& lock);
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
196
b0bd22077cd8 sharing code with orthanc-stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 192
diff changeset
50 DicomPyramidCache(OrthancStone::IOrthancConnection& orthanc,
73
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 size_t maxSize);
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ~DicomPyramidCache();
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 void Invalidate(const std::string& seriesId);
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 class Locker : public boost::noncopyable
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 private:
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 boost::mutex::scoped_lock lock_;
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 DicomPyramid& pyramid_;
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 public:
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 Locker(DicomPyramidCache& cache,
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 const std::string& seriesId);
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 DicomPyramid& GetPyramid() const
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 return pyramid_;
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
a8c90aa32ca6 LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
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 }