comparison OrthancServer/Sources/DicomInstanceToStore.cpp @ 4504:7d1eabfac6e0

removed cached dicom-as-json from DicomInstanceToStore
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Feb 2021 11:29:53 +0100
parents d9473bd5ed43
children 97d103b57cd1
comparison
equal deleted inserted replaced
4503:b525e0c3cff0 4504:7d1eabfac6e0
156 std::unique_ptr<std::string> ownBuffer_; 156 std::unique_ptr<std::string> ownBuffer_;
157 const void* bufferData_; 157 const void* bufferData_;
158 size_t bufferSize_; 158 size_t bufferSize_;
159 SmartContainer<ParsedDicomFile> parsed_; 159 SmartContainer<ParsedDicomFile> parsed_;
160 SmartContainer<DicomMap> summary_; 160 SmartContainer<DicomMap> summary_;
161 SmartContainer<Json::Value> json_;
162 MetadataMap metadata_; 161 MetadataMap metadata_;
163 162
164 PImpl() : 163 PImpl() :
165 hasBuffer_(false), 164 hasBuffer_(false),
166 bufferData_(NULL), 165 bufferData_(NULL),
192 } 191 }
193 192
194 void ComputeMissingInformation() 193 void ComputeMissingInformation()
195 { 194 {
196 if (hasBuffer_ && 195 if (hasBuffer_ &&
197 summary_.HasContent() && 196 summary_.HasContent())
198 json_.HasContent())
199 { 197 {
200 // Fine, everything is available 198 // Fine, everything is available
201 return; 199 return;
202 } 200 }
203 201
227 } 225 }
228 226
229 hasBuffer_ = true; 227 hasBuffer_ = true;
230 } 228 }
231 229
232 if (summary_.HasContent() &&
233 json_.HasContent())
234 {
235 return;
236 }
237
238 // At this point, we know that the DICOM file is available as a
239 // memory buffer, but that its summary or its JSON version is
240 // missing
241
242 ParseDicomFile();
243 assert(parsed_.HasContent());
244
245 // At this point, we have parsed the DICOM file
246
247 if (!summary_.HasContent()) 230 if (!summary_.HasContent())
248 { 231 {
232 // At this point, we know that the DICOM file is available as a
233 // memory buffer, but that its summary or its JSON version is
234 // missing
235
236 ParseDicomFile();
237 assert(parsed_.HasContent());
238
239 // At this point, we have parsed the DICOM file
240
249 summary_.Allocate(); 241 summary_.Allocate();
250 OrthancConfiguration::DefaultExtractDicomSummary(summary_.GetContent(), parsed_.GetContent()); 242 OrthancConfiguration::DefaultExtractDicomSummary(summary_.GetContent(), parsed_.GetContent());
251 }
252
253 if (!json_.HasContent())
254 {
255 json_.Allocate();
256 OrthancConfiguration::DefaultDicomDatasetToJson(json_.GetContent(), parsed_.GetContent());
257 } 243 }
258 } 244 }
259 245
260 246
261 public: 247 public:
326 312
327 return summary_.GetConstContent(); 313 return summary_.GetConstContent();
328 } 314 }
329 315
330 316
331 const Json::Value& GetJson()
332 {
333 ComputeMissingInformation();
334
335 if (!json_.HasContent())
336 {
337 throw OrthancException(ErrorCode_InternalError);
338 }
339
340 return json_.GetConstContent();
341 }
342
343
344 DicomInstanceHasher& GetHasher() 317 DicomInstanceHasher& GetHasher()
345 { 318 {
346 if (hasher_.get() == NULL) 319 if (hasher_.get() == NULL)
347 { 320 {
348 hasher_.reset(new DicomInstanceHasher(GetSummary())); 321 hasher_.reset(new DicomInstanceHasher(GetSummary()));
442 { 415 {
443 pimpl_->summary_.SetConstReference(summary); 416 pimpl_->summary_.SetConstReference(summary);
444 } 417 }
445 418
446 419
447 void DicomInstanceToStore::SetJson(const Json::Value& json)
448 {
449 pimpl_->json_.SetConstReference(json);
450 }
451
452
453 const DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata() const 420 const DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata() const
454 { 421 {
455 return pimpl_->metadata_; 422 return pimpl_->metadata_;
456 } 423 }
457 424
486 { 453 {
487 return pimpl_->GetSummary(); 454 return pimpl_->GetSummary();
488 } 455 }
489 456
490 457
491 const Json::Value& DicomInstanceToStore::GetJson() const
492 {
493 return const_cast<PImpl&>(*pimpl_).GetJson();
494 }
495
496
497 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) const 458 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) const
498 { 459 {
499 return const_cast<PImpl&>(*pimpl_).LookupTransferSyntax(result); 460 return const_cast<PImpl&>(*pimpl_).LookupTransferSyntax(result);
500 } 461 }
501 462