Mercurial > hg > orthanc-stone
annotate Framework/Loaders/LoaderCache.cpp @ 930:bf03cb879eb4
Fixed LoaderCache
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 24 Jul 2019 18:45:33 +0200 |
parents | 408bcc6c1505 |
children | f75f6cb69c1b |
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 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 seriesUuid = Orthanc::Toolbox::StripSpaces(seriesUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 Orthanc::Toolbox::ToLowerCase(seriesUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 if (seriesVolumeProgressiveLoaders_.find(seriesUuid) == seriesVolumeProgressiveLoaders_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 { |
930 | 69 #if ORTHANC_ENABLE_WASM == 1 |
70 LOG(WARNING) << "Performing request for series " << seriesUuid << " sbrk(0) = " << sbrk(0); | |
71 #else | |
72 LOG(WARNING) << "Performing request for series " << seriesUuid; | |
73 #endif | |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 #if ORTHANC_ENABLE_WASM == 1 |
930 | 79 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 loader->LoadSeries(seriesUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 seriesVolumeProgressiveLoaders_[seriesUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 return seriesVolumeProgressiveLoaders_[seriesUuid]; |
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 catch (const Orthanc::OrthancException& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 if (e.HasDetails()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 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
|
95 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 else |
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 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
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 throw; |
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 catch (const std::exception& e) |
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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 throw; |
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 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 boost::shared_ptr<DicomVolumeImageMPRSlicer> LoaderCache::GetMultiframeDicomVolumeImageMPRSlicer(std::string instanceUuid) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 try |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 Orthanc::Toolbox::ToLowerCase(instanceUuid); |
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 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 if (dicomVolumeImageMPRSlicers_.find(instanceUuid) == dicomVolumeImageMPRSlicers_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 boost::shared_ptr<OrthancMultiframeVolumeLoader> loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 #if ORTHANC_ENABLE_WASM == 1 |
930 | 130 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 loader->LoadInstance(instanceUuid); |
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 multiframeVolumeLoaders_[instanceUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 boost::shared_ptr<DicomVolumeImageMPRSlicer> mprSlicer(new DicomVolumeImageMPRSlicer(volumeImage)); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 dicomVolumeImageMPRSlicers_[instanceUuid] = mprSlicer; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 return dicomVolumeImageMPRSlicers_[instanceUuid]; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 catch (const Orthanc::OrthancException& e) |
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 if (e.HasDetails()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 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
|
148 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 else |
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 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
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 throw; |
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 catch (const std::exception& e) |
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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 throw; |
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 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 boost::shared_ptr<DicomStructureSetLoader> LoaderCache::GetDicomStructureSetLoader(std::string instanceUuid) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 try |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 // normalize keys a little |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 Orthanc::Toolbox::ToLowerCase(instanceUuid); |
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 // find in cache |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 if (dicomStructureSetLoaders_.find(instanceUuid) == dicomStructureSetLoaders_.end()) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 boost::shared_ptr<DicomStructureSetLoader> loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 #if ORTHANC_ENABLE_WASM == 1 |
930 | 182 loader.reset(new DicomStructureSetLoader(oracle_, oracle_)); |
929
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 #else |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 loader.reset(new DicomStructureSetLoader(oracle_, lock.GetOracleObservable())); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 loader->LoadInstance(instanceUuid); |
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 dicomStructureSetLoaders_[instanceUuid] = loader; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 return dicomStructureSetLoaders_[instanceUuid]; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 catch (const Orthanc::OrthancException& e) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 if (e.HasDetails()) |
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 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
|
198 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 else |
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 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What(); |
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 throw; |
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 catch (const std::exception& e) |
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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 throw; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 catch (...) |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 { |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 LOG(ERROR) << "Unknown exception in LoaderCache"; |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 throw; |
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 } |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 |
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 void LoaderCache::ClearCache() |
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 #if ORTHANC_ENABLE_WASM != 1 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 LockingEmitter::WriterLock lock(lockingEmitter_); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 #endif |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 seriesVolumeProgressiveLoaders_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 multiframeVolumeLoaders_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 dicomVolumeImageMPRSlicers_.clear(); |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 dicomStructureSetLoaders_.clear(); |
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 |
408bcc6c1505
Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 } |