Mercurial > hg > orthanc-stone
annotate Framework/Loaders/LoaderCache.cpp @ 933:f75f6cb69c1b
Commented-out traces for debug
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 26 Jul 2019 20:09:42 +0200 |
parents | bf03cb879eb4 |
children | 86ac61a040c9 |
rev | line source |
---|---|
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "LoaderCache.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #include "OrthancSeriesVolumeProgressiveLoader.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 #include "OrthancMultiframeVolumeLoader.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include "DicomStructureSetLoader.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
930 | 27 #if ORTHANC_ENABLE_WASM == 1 |
28 # include <unistd.h> | |
29 # include "../Oracle/WebAssemblyOracle.h" | |
30 #else | |
31 # include "../Oracle/ThreadedOracle.h" | |
32 #endif | |
33 | |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 #include "../Messages/LockingEmitter.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 #include "../Volumes/DicomVolumeImage.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 #include "../Volumes/DicomVolumeImageMPRSlicer.h" |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 #include <Core/OrthancException.h> |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 #include <Core/Toolbox.h> |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 namespace OrthancStone |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 #if ORTHANC_ENABLE_WASM == 1 |
930 | 44 LoaderCache::LoaderCache(WebAssemblyOracle& oracle) |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 : oracle_(oracle) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 #else |
930 | 50 LoaderCache::LoaderCache(ThreadedOracle& oracle, LockingEmitter& lockingEmitter) |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 : oracle_(oracle) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 , lockingEmitter_(lockingEmitter) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 LoaderCache::GetSeriesVolumeProgressiveLoader(std::string seriesUuid) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 try |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 { |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
62 |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 seriesUuid = Orthanc::Toolbox::StripSpaces(seriesUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 Orthanc::Toolbox::ToLowerCase(seriesUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 if (seriesVolumeProgressiveLoaders_.find(seriesUuid) == seriesVolumeProgressiveLoaders_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 { |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
70 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : CACHEMISS --> need to load seriesUUid = " << seriesUuid; |
930 | 71 #if ORTHANC_ENABLE_WASM == 1 |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
72 // LOG(TRACE) << "Performing request for series " << seriesUuid << " sbrk(0) = " << sbrk(0); |
930 | 73 #else |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
74 // LOG(TRACE) << "Performing request for series " << seriesUuid; |
930 | 75 #endif |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> loader; |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
78 // LOG(TRACE) << "volumeImage = " << volumeImage.get(); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 #if ORTHANC_ENABLE_WASM == 1 |
930 | 81 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 #endif |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
86 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : loader = " << loader.get(); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 loader->LoadSeries(seriesUuid); |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
88 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : loader->LoadSeries successful"; |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 seriesVolumeProgressiveLoaders_[seriesUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 } |
933
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
92 else |
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
93 { |
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
94 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : returning cached loader for seriesUUid = " << seriesUuid; |
f75f6cb69c1b
Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents:
930
diff
changeset
|
95 } |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 return seriesVolumeProgressiveLoaders_[seriesUuid]; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 catch (const Orthanc::OrthancException& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 if (e.HasDetails()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 catch (const std::exception& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 boost::shared_ptr<DicomVolumeImageMPRSlicer> LoaderCache::GetMultiframeDicomVolumeImageMPRSlicer(std::string instanceUuid) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 try |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 Orthanc::Toolbox::ToLowerCase(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 if (dicomVolumeImageMPRSlicers_.find(instanceUuid) == dicomVolumeImageMPRSlicers_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 boost::shared_ptr<OrthancMultiframeVolumeLoader> loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 #if ORTHANC_ENABLE_WASM == 1 |
930 | 138 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 loader->LoadInstance(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 multiframeVolumeLoaders_[instanceUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 boost::shared_ptr<DicomVolumeImageMPRSlicer> mprSlicer(new DicomVolumeImageMPRSlicer(volumeImage)); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 dicomVolumeImageMPRSlicers_[instanceUuid] = mprSlicer; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 return dicomVolumeImageMPRSlicers_[instanceUuid]; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 catch (const Orthanc::OrthancException& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 if (e.HasDetails()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 catch (const std::exception& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 boost::shared_ptr<DicomStructureSetLoader> LoaderCache::GetDicomStructureSetLoader(std::string instanceUuid) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 try |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 Orthanc::Toolbox::ToLowerCase(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 if (dicomStructureSetLoaders_.find(instanceUuid) == dicomStructureSetLoaders_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 boost::shared_ptr<DicomStructureSetLoader> loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 #if ORTHANC_ENABLE_WASM == 1 |
930 | 190 loader.reset(new DicomStructureSetLoader(oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 loader.reset(new DicomStructureSetLoader(oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 loader->LoadInstance(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 dicomStructureSetLoaders_[instanceUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 return dicomStructureSetLoaders_[instanceUuid]; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 catch (const Orthanc::OrthancException& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 if (e.HasDetails()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 catch (const std::exception& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 void LoaderCache::ClearCache() |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 #if ORTHANC_ENABLE_WASM != 1 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 seriesVolumeProgressiveLoaders_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 multiframeVolumeLoaders_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 dicomVolumeImageMPRSlicers_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 dicomStructureSetLoaders_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 } |