diff 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
line wrap: on
line diff
--- a/Framework/Toolbox/ParsedDicomCache.cpp	Fri Nov 15 12:38:15 2019 +0100
+++ b/Framework/Toolbox/ParsedDicomCache.cpp	Fri Nov 15 17:34:19 2019 +0100
@@ -68,30 +68,42 @@
   };
     
 
-  void ParsedDicomCache::Acquire(const std::string& key,
+  std::string ParsedDicomCache::GetIndex(unsigned int bucket,
+                                         const std::string& bucketKey)
+  {
+    return boost::lexical_cast<std::string>(bucket) + "|" + bucketKey;
+  }
+  
+
+  void ParsedDicomCache::Acquire(unsigned int bucket,
+                                 const std::string& bucketKey,
                                  Orthanc::ParsedDicomFile* dicom,
                                  size_t fileSize,
                                  bool hasPixelData)
   {
-    cache_.Acquire(key, new Item(dicom, fileSize, hasPixelData));
+    LOG(TRACE) << "new item stored in cache: bucket " << bucket << ", key " << bucketKey;
+    cache_.Acquire(GetIndex(bucket, bucketKey), new Item(dicom, fileSize, hasPixelData));
   }
 
   
   ParsedDicomCache::Reader::Reader(ParsedDicomCache& cache,
-                                   const std::string& key) :
+                                   unsigned int bucket,
+                                   const std::string& bucketKey) :
     /**
      * The "DcmFileFormat" object cannot be accessed from multiple
      * threads, even if using only getters. An unique lock (mutex) is
      * mandatory.
      **/
-    accessor_(cache.cache_, key, true /* unique */)
+    accessor_(cache.cache_, GetIndex(bucket, bucketKey), true /* unique */)
   {
     if (accessor_.IsValid())
     {
+      LOG(TRACE) << "accessing item within cache: bucket " << bucket << ", key " << bucketKey;
       item_ = &dynamic_cast<Item&>(accessor_.GetValue());
     }
     else
     {
+      LOG(TRACE) << "missing item within cache: bucket " << bucket << ", key " << bucketKey;
       item_ = NULL;
     }
   }