Mercurial > hg > orthanc-stone
comparison Framework/Loaders/LoaderCache.cpp @ 1440:49f31fa332b3 loader-injection-feature
Merge from default.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 26 May 2020 09:52:09 +0200 |
parents | 4e233e3ea53b |
children | 30deba7bc8e2 |
comparison
equal
deleted
inserted
replaced
1432:758fb6958c20 | 1440:49f31fa332b3 |
---|---|
162 LOG(ERROR) << "Unknown exception in LoaderCache"; | 162 LOG(ERROR) << "Unknown exception in LoaderCache"; |
163 throw; | 163 throw; |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 /** | 167 std::string LoaderCache::BuildDicomStructureSetLoaderKey( |
168 This method allows to convert a list of string into a string by | 168 const std::string& instanceUuid, |
169 sorting the strings then joining them | 169 const std::string& uniqueKey) |
170 */ | 170 { |
171 static std::string SortAndJoin(const std::vector<std::string>& stringList) | 171 return instanceUuid + "_" + uniqueKey; |
172 { | 172 } |
173 if (stringList.size() == 0) | 173 |
174 { | 174 boost::shared_ptr<DicomStructureSetLoader> LoaderCache::GetDicomStructureSetLoader( |
175 return ""; | |
176 } | |
177 else | |
178 { | |
179 std::vector<std::string> sortedStringList = stringList; | |
180 std::sort(sortedStringList.begin(), sortedStringList.end()); | |
181 std::stringstream s; | |
182 s << sortedStringList[0]; | |
183 for (size_t i = 1; i < sortedStringList.size(); ++i) | |
184 { | |
185 s << "-" << sortedStringList[i]; | |
186 } | |
187 return s.str(); | |
188 } | |
189 } | |
190 | |
191 boost::shared_ptr<DicomStructureSetLoader> | |
192 LoaderCache::GetDicomStructureSetLoader( | |
193 std::string inInstanceUuid, | 175 std::string inInstanceUuid, |
194 const std::vector<std::string>& initiallyVisibleStructures) | 176 const std::vector<std::string>& initiallyVisibleStructures, |
177 const std::string& uniqueKey) | |
195 { | 178 { |
196 try | 179 try |
197 { | 180 { |
198 // normalize keys a little | 181 // normalize keys a little |
199 NormalizeUuid(inInstanceUuid); | 182 NormalizeUuid(inInstanceUuid); |
200 | 183 |
201 std::string initiallyVisibleStructuresKey = | 184 std::string entryKey = BuildDicomStructureSetLoaderKey(inInstanceUuid, uniqueKey); |
202 SortAndJoin(initiallyVisibleStructures); | |
203 | |
204 std::string entryKey = inInstanceUuid + "_" + initiallyVisibleStructuresKey; | |
205 | 185 |
206 // find in cache | 186 // find in cache |
207 if (dicomStructureSetLoaders_.find(entryKey) == dicomStructureSetLoaders_.end()) | 187 if (dicomStructureSetLoaders_.find(entryKey) == dicomStructureSetLoaders_.end()) |
208 { | 188 { |
209 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); | 189 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); |