Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h @ 4685:693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 08 Jun 2021 18:28:57 +0200 |
parents | fa2311f94d9f |
children | 7053502fbf97 |
rev | line source |
---|---|
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * License along with this program. If not, see |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../Cache/MemoryObjectCache.h" |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "ParsedDicomFile.h" |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace Orthanc |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
30 class ORTHANC_PUBLIC ParsedDicomCache : public boost::noncopyable |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 private: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 class Item; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
35 #if !defined(__EMSCRIPTEN__) |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 boost::mutex mutex_; |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
37 #endif |
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
38 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 size_t cacheSize_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 std::unique_ptr<MemoryObjectCache> cache_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 std::unique_ptr<ParsedDicomFile> largeDicom_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 std::string largeId_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 size_t largeSize_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 public: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 explicit ParsedDicomCache(size_t size); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
48 size_t GetNumberOfItems(); // For unit tests only |
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
49 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 size_t GetCurrentSize(); // For unit tests only |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 void Invalidate(const std::string& id); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 void Acquire(const std::string& id, |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ParsedDicomFile* dicom, // Takes ownership |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 size_t fileSize); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
4486 | 58 class ORTHANC_PUBLIC Accessor : public boost::noncopyable |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 private: |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
61 #if !defined(__EMSCRIPTEN__) |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 boost::mutex::scoped_lock lock_; |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
63 #endif |
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
64 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 std::string id_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 ParsedDicomFile* file_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 size_t fileSize_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 std::unique_ptr<MemoryObjectCache::Accessor> accessor_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 public: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 Accessor(ParsedDicomCache& that, |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 const std::string& id); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
4495
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4486
diff
changeset
|
75 bool IsValid() const; |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 ParsedDicomFile& GetDicom() const; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 size_t GetFileSize() const; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 }; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 }; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |