Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/ParsedDicomCache.h @ 1779:9ab251c03eda
unit test VolumeRendering.TextureCorners
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 10:01:20 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
1116 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1714
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1116 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
1116 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1116 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
25 #include <Cache/MemoryObjectCache.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
26 #include <DicomParsing/ParsedDicomFile.h> |
1116 | 27 |
28 namespace OrthancStone | |
29 { | |
1149
2da8b4d6f8c1
renamed ParsedDicomFileCache as ParsedDicomCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1140
diff
changeset
|
30 class ParsedDicomCache : public boost::noncopyable |
1116 | 31 { |
32 private: | |
33 class Item; | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
34 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
35 static std::string GetIndex(unsigned int bucket, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
36 const std::string& bucketKey); |
1116 | 37 |
38 Orthanc::MemoryObjectCache cache_; | |
1714
a878e807cd96
configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
39 size_t lowCacheSizeWarning_; |
1116 | 40 |
41 public: | |
1714
a878e807cd96
configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
42 explicit ParsedDicomCache(size_t size) : |
a878e807cd96
configuration option "DicomCacheSize", warning if cache should be larger
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
43 lowCacheSizeWarning_(0) |
1116 | 44 { |
45 cache_.SetMaximumSize(size); | |
46 } | |
1140 | 47 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
48 void Invalidate(unsigned int bucket, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
49 const std::string& bucketKey) |
1140 | 50 { |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
51 cache_.Invalidate(GetIndex(bucket, bucketKey)); |
1140 | 52 } |
1116 | 53 |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
54 void Acquire(unsigned int bucket, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
55 const std::string& bucketKey, |
1136
42581a6182c8
reactivation of the cache of parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
56 Orthanc::ParsedDicomFile* dicom, |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
57 size_t fileSize, |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
58 bool hasPixelData); |
1116 | 59 |
60 class Reader : public boost::noncopyable | |
61 { | |
62 private: | |
1140 | 63 Orthanc::MemoryObjectCache::Accessor accessor_; |
64 Item* item_; | |
1116 | 65 |
66 public: | |
1149
2da8b4d6f8c1
renamed ParsedDicomFileCache as ParsedDicomCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1140
diff
changeset
|
67 Reader(ParsedDicomCache& cache, |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
68 unsigned int bucket, |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1149
diff
changeset
|
69 const std::string& bucketKey); |
1116 | 70 |
71 bool IsValid() const | |
72 { | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
73 return item_ != NULL; |
1116 | 74 } |
75 | |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
76 bool HasPixelData() const; |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
77 |
1136
42581a6182c8
reactivation of the cache of parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
78 Orthanc::ParsedDicomFile& GetDicom() const; |
1124
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
79 |
a8bf81756839
unsuccessful attempt to cache ParseDicomFileCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1116
diff
changeset
|
80 size_t GetFileSize() const; |
1116 | 81 }; |
82 }; | |
83 } |