Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h @ 5746:afd421225eb4 find-refactoring-clean tip
WIP: started to implement IntegratedFind in SQLite
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Fri, 30 Aug 2024 18:03:37 +0200 |
parents | f7adfb22e20e |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * 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
|
11 * as published by the Free Software Foundation, either version 3 of |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * the License, or (at your option) any later version. |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * Lesser General Public License for more details. |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * 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
|
20 * License along with this program. If not, see |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
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 |
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 #pragma once |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../Cache/MemoryObjectCache.h" |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include "ParsedDicomFile.h" |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 namespace Orthanc |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
32 class ORTHANC_PUBLIC ParsedDicomCache : public boost::noncopyable |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 private: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 class Item; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
37 #if !defined(__EMSCRIPTEN__) |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 boost::mutex mutex_; |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
39 #endif |
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
40 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 size_t cacheSize_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 std::unique_ptr<MemoryObjectCache> cache_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 std::unique_ptr<ParsedDicomFile> largeDicom_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 std::string largeId_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 size_t largeSize_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 public: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 explicit ParsedDicomCache(size_t size); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
4457
789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4456
diff
changeset
|
50 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
|
51 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 size_t GetCurrentSize(); // For unit tests only |
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 Invalidate(const std::string& id); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 void Acquire(const std::string& id, |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 ParsedDicomFile* dicom, // Takes ownership |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 size_t fileSize); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
4486 | 60 class ORTHANC_PUBLIC Accessor : public boost::noncopyable |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 private: |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
63 #if !defined(__EMSCRIPTEN__) |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 boost::mutex::scoped_lock lock_; |
4458
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
65 #endif |
e4dae17035b9
fix ParsedDicomCache for emscripten
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4457
diff
changeset
|
66 |
4456
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 std::string id_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 ParsedDicomFile* file_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 size_t fileSize_; |
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 std::unique_ptr<MemoryObjectCache::Accessor> accessor_; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 public: |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 Accessor(ParsedDicomCache& that, |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 const std::string& id); |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
4495
fa2311f94d9f
IStorageArea::ReadRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4486
diff
changeset
|
77 bool IsValid() const; |
4456
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 ParsedDicomFile& GetDicom() 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 size_t GetFileSize() const; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 }; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 }; |
3e4f7b7840f0
new class: ParsedDicomCache()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 } |