annotate Framework/Loaders/LoaderCache.cpp @ 929:408bcc6c1505

Added Loader cache. Not activated yet.
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 24 Jul 2019 14:27:06 +0200
parents
children bf03cb879eb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include "../Messages/LockingEmitter.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 #include "../Volumes/DicomVolumeImage.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 #include "../Volumes/DicomVolumeImageMPRSlicer.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 #include <Core/OrthancException.h>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 #include <Core/Toolbox.h>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 namespace OrthancStone
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 #if ORTHANC_ENABLE_WASM == 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 LoaderCache::LoaderCache(IOracle& oracle)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 : oracle_(oracle)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 {
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 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 LoaderCache::LoaderCache(IOracle& oracle, LockingEmitter& lockingEmitter)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 : oracle_(oracle)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 , lockingEmitter_(lockingEmitter)
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 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 LoaderCache::GetSeriesVolumeProgressiveLoader(std::string seriesUuid)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 try
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 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 seriesUuid = Orthanc::Toolbox::StripSpaces(seriesUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 Orthanc::Toolbox::ToLowerCase(seriesUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 if (seriesVolumeProgressiveLoaders_.find(seriesUuid) == seriesVolumeProgressiveLoaders_.end())
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 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64
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 #if ORTHANC_ENABLE_WASM == 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, GetParent()->GetOracleRef(), GetParent()->GetOracleRef()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 loader->LoadSeries(seriesUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 seriesVolumeProgressiveLoaders_[seriesUuid] = loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 return seriesVolumeProgressiveLoaders_[seriesUuid];
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 catch (const Orthanc::OrthancException& e)
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 (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 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
83 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 else
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 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
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 throw;
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 std::exception& 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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 throw;
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 }
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 boost::shared_ptr<DicomVolumeImageMPRSlicer> LoaderCache::GetMultiframeDicomVolumeImageMPRSlicer(std::string instanceUuid)
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 try
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 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 Orthanc::Toolbox::ToLowerCase(instanceUuid);
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 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 if (dicomVolumeImageMPRSlicers_.find(instanceUuid) == dicomVolumeImageMPRSlicers_.end())
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 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 boost::shared_ptr<OrthancMultiframeVolumeLoader> loader;
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 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 #if ORTHANC_ENABLE_WASM == 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, GetParent()->GetOracleRef(), GetParent()->GetOracleRef()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 loader->LoadInstance(instanceUuid);
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 multiframeVolumeLoaders_[instanceUuid] = loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126 boost::shared_ptr<DicomVolumeImageMPRSlicer> mprSlicer(new DicomVolumeImageMPRSlicer(volumeImage));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 dicomVolumeImageMPRSlicers_[instanceUuid] = mprSlicer;
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 return dicomVolumeImageMPRSlicers_[instanceUuid];
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 catch (const Orthanc::OrthancException& e)
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 if (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 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
136 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
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 throw;
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 std::exception& 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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 throw;
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 }
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 boost::shared_ptr<DicomStructureSetLoader> LoaderCache::GetDicomStructureSetLoader(std::string instanceUuid)
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 try
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 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 Orthanc::Toolbox::ToLowerCase(instanceUuid);
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 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 if (dicomStructureSetLoaders_.find(instanceUuid) == dicomStructureSetLoaders_.end())
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 boost::shared_ptr<DicomStructureSetLoader> loader;
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 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 #if ORTHANC_ENABLE_WASM == 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 loader.reset(new DicomStructureSetLoader(volumeImage, GetParent()->GetOracleRef(), GetParent()->GetOracleRef()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 loader.reset(new DicomStructureSetLoader(oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 loader->LoadInstance(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 dicomStructureSetLoaders_[instanceUuid] = loader;
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 return dicomStructureSetLoaders_[instanceUuid];
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 catch (const Orthanc::OrthancException& e)
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 if (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 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
186 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 else
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 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
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 throw;
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 std::exception& 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 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
197 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
198 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
199 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
200 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201 throw;
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 }
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
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 void LoaderCache::ClearCache()
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 #if ORTHANC_ENABLE_WASM != 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
209 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211 seriesVolumeProgressiveLoaders_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212 multiframeVolumeLoaders_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 dicomVolumeImageMPRSlicers_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 dicomStructureSetLoaders_.clear();
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 }