Mercurial > hg > orthanc-wsi
annotate ViewerPlugin/DicomPyramidCache.h @ 146:213d35bc1881 OrthancWSI-0.5
OrthancWSI-0.5
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Apr 2018 17:11:31 +0200 |
parents | a0f9a3df1110 |
children | 6b8ccfc02051 |
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 |
115
a51dee6a1515
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
98
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * Affero General Public License for more details. |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 **/ |
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 #pragma once |
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 #include "../Framework/Inputs/DicomPyramid.h" |
140
a0f9a3df1110
resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
115
diff
changeset
|
25 |
a0f9a3df1110
resort to Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
115
diff
changeset
|
26 #include <Core/Cache/LeastRecentlyUsedIndex.h> |
73
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include <boost/thread/mutex.hpp> |
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 namespace OrthancWSI |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 class DicomPyramidCache : public boost::noncopyable |
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 private: |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 typedef Orthanc::LeastRecentlyUsedIndex<std::string, DicomPyramid*> Cache; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 boost::mutex mutex_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 OrthancPlugins::IOrthancConnection& orthanc_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 size_t maxSize_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 Cache cache_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
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 DicomPyramid* GetCachedPyramid(const std::string& seriesId); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 DicomPyramid& GetPyramid(const std::string& seriesId, |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 boost::mutex::scoped_lock& lock); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 public: |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 DicomPyramidCache(OrthancPlugins::IOrthancConnection& orthanc, |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 size_t maxSize); |
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 ~DicomPyramidCache(); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 void Invalidate(const std::string& seriesId); |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 class Locker : public boost::noncopyable |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 private: |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 boost::mutex::scoped_lock lock_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 DicomPyramid& pyramid_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 public: |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 Locker(DicomPyramidCache& cache, |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 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 DicomPyramid& GetPyramid() const |
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 return pyramid_; |
a8c90aa32ca6
LRU caching of pyramids, OrthancWSIClearCache script
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
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 } |