diff OrthancServer/ServerContext.cpp @ 285:4031f73fe0e4

access to the raw dicom tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Dec 2012 17:53:14 +0100
parents f6fdf5abe751
children 40d3bf6cc8d9
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Wed Dec 12 15:40:18 2012 +0100
+++ b/OrthancServer/ServerContext.cpp	Wed Dec 12 17:53:14 2012 +0100
@@ -37,6 +37,8 @@
 #include <glog/logging.h>
 
 
+static const size_t DICOM_CACHE_SIZE = 2;
+
 /**
  * IMPORTANT: We make the assumption that the same instance of
  * FileStorage can be accessed from multiple threads. This seems OK
@@ -51,7 +53,9 @@
   ServerContext::ServerContext(const boost::filesystem::path& path) :
     storage_(path.string()),
     index_(*this, path.string()),
-    accessor_(storage_)
+    accessor_(storage_),
+    provider_(*this),
+    dicomCache_(provider_, DICOM_CACHE_SIZE)
   {
     // TODO RECYCLING SETUP HERE
     //index_.SetMaximumPatientCount(4);
@@ -165,4 +169,18 @@
     accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
     accessor_.Read(result, attachment.GetUuid());
   }
+
+
+  IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId)
+  {
+    std::string content;
+    context_.ReadFile(content, instancePublicId, FileContentType_Dicom);
+    return new ParsedDicomFile(content);
+  }
+
+
+  ParsedDicomFile& ServerContext::GetDicomFile(const std::string& instancePublicId)
+  {
+    return dynamic_cast<ParsedDicomFile&>(dicomCache_.Access(instancePublicId));
+  }
 }