Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 5130:f2dcdbe05884
ResourceModification jobs can now use multiple threads
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 05 Jan 2023 17:24:43 +0100 |
parents | 8638522eeda1 |
children | 482f3e80ed0a |
comparison
equal
deleted
inserted
replaced
5128:ede035d48b8e | 5130:f2dcdbe05884 |
---|---|
437 | 437 |
438 void DicomModification::RegisterMappedDicomIdentifier(const std::string& original, | 438 void DicomModification::RegisterMappedDicomIdentifier(const std::string& original, |
439 const std::string& mapped, | 439 const std::string& mapped, |
440 ResourceType level) | 440 ResourceType level) |
441 { | 441 { |
442 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
443 | |
442 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, original)); | 444 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, original)); |
443 | 445 |
444 if (previous == uidMap_.end()) | 446 if (previous == uidMap_.end()) |
445 { | 447 { |
446 uidMap_.insert(std::make_pair(std::make_pair(level, original), mapped)); | 448 uidMap_.insert(std::make_pair(std::make_pair(level, original), mapped)); |
448 } | 450 } |
449 | 451 |
450 std::string DicomModification::MapDicomIdentifier(const std::string& original, | 452 std::string DicomModification::MapDicomIdentifier(const std::string& original, |
451 ResourceType level) | 453 ResourceType level) |
452 { | 454 { |
455 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
456 | |
453 const std::string stripped = Toolbox::StripSpaces(original); | 457 const std::string stripped = Toolbox::StripSpaces(original); |
454 | 458 |
455 std::string mapped; | 459 std::string mapped; |
456 | 460 |
457 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, stripped)); | 461 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, stripped)); |
682 return removePrivateTags_; | 686 return removePrivateTags_; |
683 } | 687 } |
684 | 688 |
685 void DicomModification::SetLevel(ResourceType level) | 689 void DicomModification::SetLevel(ResourceType level) |
686 { | 690 { |
691 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
692 | |
687 uidMap_.clear(); | 693 uidMap_.clear(); |
688 level_ = level; | 694 level_ = level; |
689 | 695 |
690 if (level != ResourceType_Patient) | 696 if (level != ResourceType_Patient) |
691 { | 697 { |
837 } | 843 } |
838 | 844 |
839 | 845 |
840 void DicomModification::SetupAnonymization(DicomVersion version) | 846 void DicomModification::SetupAnonymization(DicomVersion version) |
841 { | 847 { |
848 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
849 | |
842 isAnonymization_ = true; | 850 isAnonymization_ = true; |
843 | 851 |
844 removals_.clear(); | 852 removals_.clear(); |
845 clearings_.clear(); | 853 clearings_.clear(); |
846 removedRanges_.clear(); | 854 removedRanges_.clear(); |
1421 static const char* REMOVE_SEQUENCES = "RemoveSequences"; // New in Orthanc 1.9.4 | 1429 static const char* REMOVE_SEQUENCES = "RemoveSequences"; // New in Orthanc 1.9.4 |
1422 static const char* SEQUENCE_REPLACEMENTS = "SequenceReplacements"; // New in Orthanc 1.9.4 | 1430 static const char* SEQUENCE_REPLACEMENTS = "SequenceReplacements"; // New in Orthanc 1.9.4 |
1423 | 1431 |
1424 void DicomModification::Serialize(Json::Value& value) const | 1432 void DicomModification::Serialize(Json::Value& value) const |
1425 { | 1433 { |
1434 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
1435 | |
1426 if (identifierGenerator_ != NULL) | 1436 if (identifierGenerator_ != NULL) |
1427 { | 1437 { |
1428 throw OrthancException(ErrorCode_InternalError, | 1438 throw OrthancException(ErrorCode_InternalError, |
1429 "Cannot serialize a DicomModification with a custom identifier generator"); | 1439 "Cannot serialize a DicomModification with a custom identifier generator"); |
1430 } | 1440 } |
1546 | 1556 |
1547 void DicomModification::UnserializeUidMap(ResourceType level, | 1557 void DicomModification::UnserializeUidMap(ResourceType level, |
1548 const Json::Value& serialized, | 1558 const Json::Value& serialized, |
1549 const char* field) | 1559 const char* field) |
1550 { | 1560 { |
1561 boost::recursive_mutex::scoped_lock lock(uidMapMutex_); | |
1562 | |
1551 if (!serialized.isMember(field) || | 1563 if (!serialized.isMember(field) || |
1552 serialized[field].type() != Json::objectValue) | 1564 serialized[field].type() != Json::objectValue) |
1553 { | 1565 { |
1554 throw OrthancException(ErrorCode_BadFileFormat); | 1566 throw OrthancException(ErrorCode_BadFileFormat); |
1555 } | 1567 } |