comparison 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
comparison
equal deleted inserted replaced
284:06aa7b7b6723 285:4031f73fe0e4
35 #include "../Core/HttpServer/FilesystemHttpSender.h" 35 #include "../Core/HttpServer/FilesystemHttpSender.h"
36 36
37 #include <glog/logging.h> 37 #include <glog/logging.h>
38 38
39 39
40 static const size_t DICOM_CACHE_SIZE = 2;
41
40 /** 42 /**
41 * IMPORTANT: We make the assumption that the same instance of 43 * IMPORTANT: We make the assumption that the same instance of
42 * FileStorage can be accessed from multiple threads. This seems OK 44 * FileStorage can be accessed from multiple threads. This seems OK
43 * since the filesystem implements the required locking mechanisms, 45 * since the filesystem implements the required locking mechanisms,
44 * but maybe a read-writer lock on the "FileStorage" could be 46 * but maybe a read-writer lock on the "FileStorage" could be
49 namespace Orthanc 51 namespace Orthanc
50 { 52 {
51 ServerContext::ServerContext(const boost::filesystem::path& path) : 53 ServerContext::ServerContext(const boost::filesystem::path& path) :
52 storage_(path.string()), 54 storage_(path.string()),
53 index_(*this, path.string()), 55 index_(*this, path.string()),
54 accessor_(storage_) 56 accessor_(storage_),
57 provider_(*this),
58 dicomCache_(provider_, DICOM_CACHE_SIZE)
55 { 59 {
56 // TODO RECYCLING SETUP HERE 60 // TODO RECYCLING SETUP HERE
57 //index_.SetMaximumPatientCount(4); 61 //index_.SetMaximumPatientCount(4);
58 //index_.SetMaximumStorageSize(10); 62 //index_.SetMaximumStorageSize(10);
59 } 63 }
163 } 167 }
164 168
165 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType()); 169 accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
166 accessor_.Read(result, attachment.GetUuid()); 170 accessor_.Read(result, attachment.GetUuid());
167 } 171 }
172
173
174 IDynamicObject* ServerContext::DicomCacheProvider::Provide(const std::string& instancePublicId)
175 {
176 std::string content;
177 context_.ReadFile(content, instancePublicId, FileContentType_Dicom);
178 return new ParsedDicomFile(content);
179 }
180
181
182 ParsedDicomFile& ServerContext::GetDicomFile(const std::string& instancePublicId)
183 {
184 return dynamic_cast<ParsedDicomFile&>(dicomCache_.Access(instancePublicId));
185 }
168 } 186 }