comparison Framework/Toolbox/ParsedDicomCache.cpp @ 1151:48befc2bf66d broker

ParseDicomFromWadoCommand
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Nov 2019 17:34:19 +0100
parents 2da8b4d6f8c1
children b9b5d4378874
comparison
equal deleted inserted replaced
1150:7aad0984d38a 1151:48befc2bf66d
66 return hasPixelData_; 66 return hasPixelData_;
67 } 67 }
68 }; 68 };
69 69
70 70
71 void ParsedDicomCache::Acquire(const std::string& key, 71 std::string ParsedDicomCache::GetIndex(unsigned int bucket,
72 const std::string& bucketKey)
73 {
74 return boost::lexical_cast<std::string>(bucket) + "|" + bucketKey;
75 }
76
77
78 void ParsedDicomCache::Acquire(unsigned int bucket,
79 const std::string& bucketKey,
72 Orthanc::ParsedDicomFile* dicom, 80 Orthanc::ParsedDicomFile* dicom,
73 size_t fileSize, 81 size_t fileSize,
74 bool hasPixelData) 82 bool hasPixelData)
75 { 83 {
76 cache_.Acquire(key, new Item(dicom, fileSize, hasPixelData)); 84 LOG(TRACE) << "new item stored in cache: bucket " << bucket << ", key " << bucketKey;
85 cache_.Acquire(GetIndex(bucket, bucketKey), new Item(dicom, fileSize, hasPixelData));
77 } 86 }
78 87
79 88
80 ParsedDicomCache::Reader::Reader(ParsedDicomCache& cache, 89 ParsedDicomCache::Reader::Reader(ParsedDicomCache& cache,
81 const std::string& key) : 90 unsigned int bucket,
91 const std::string& bucketKey) :
82 /** 92 /**
83 * The "DcmFileFormat" object cannot be accessed from multiple 93 * The "DcmFileFormat" object cannot be accessed from multiple
84 * threads, even if using only getters. An unique lock (mutex) is 94 * threads, even if using only getters. An unique lock (mutex) is
85 * mandatory. 95 * mandatory.
86 **/ 96 **/
87 accessor_(cache.cache_, key, true /* unique */) 97 accessor_(cache.cache_, GetIndex(bucket, bucketKey), true /* unique */)
88 { 98 {
89 if (accessor_.IsValid()) 99 if (accessor_.IsValid())
90 { 100 {
101 LOG(TRACE) << "accessing item within cache: bucket " << bucket << ", key " << bucketKey;
91 item_ = &dynamic_cast<Item&>(accessor_.GetValue()); 102 item_ = &dynamic_cast<Item&>(accessor_.GetValue());
92 } 103 }
93 else 104 else
94 { 105 {
106 LOG(TRACE) << "missing item within cache: bucket " << bucket << ", key " << bucketKey;
95 item_ = NULL; 107 item_ = NULL;
96 } 108 }
97 } 109 }
98 110
99 111