comparison Framework/Toolbox/ParsedDicomFileCache.cpp @ 1136:42581a6182c8 broker

reactivation of the cache of parsed DICOM files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 06 Nov 2019 17:54:14 +0100
parents a8bf81756839
children 6333e6f7248e
comparison
equal deleted inserted replaced
1135:a0a33e5ea5bb 1136:42581a6182c8
24 namespace OrthancStone 24 namespace OrthancStone
25 { 25 {
26 class ParsedDicomFileCache::Item : public Orthanc::ICacheable 26 class ParsedDicomFileCache::Item : public Orthanc::ICacheable
27 { 27 {
28 private: 28 private:
29 boost::mutex mutex_; 29 boost::mutex mutex_;
30 boost::shared_ptr<Orthanc::ParsedDicomFile> dicom_; 30 std::auto_ptr<Orthanc::ParsedDicomFile> dicom_;
31 size_t fileSize_; 31 size_t fileSize_;
32 bool hasPixelData_; 32 bool hasPixelData_;
33 33
34 public: 34 public:
35 Item(boost::shared_ptr<Orthanc::ParsedDicomFile> dicom, 35 Item(Orthanc::ParsedDicomFile* dicom,
36 size_t fileSize, 36 size_t fileSize,
37 bool hasPixelData) : 37 bool hasPixelData) :
38 dicom_(dicom), 38 dicom_(dicom),
39 fileSize_(fileSize), 39 fileSize_(fileSize),
40 hasPixelData_(hasPixelData) 40 hasPixelData_(hasPixelData)
53 virtual size_t GetMemoryUsage() const 53 virtual size_t GetMemoryUsage() const
54 { 54 {
55 return fileSize_; 55 return fileSize_;
56 } 56 }
57 57
58 boost::shared_ptr<Orthanc::ParsedDicomFile> GetDicom() const 58 Orthanc::ParsedDicomFile& GetDicom() const
59 { 59 {
60 assert(dicom_.get() != NULL); 60 assert(dicom_.get() != NULL);
61 return dicom_; 61 return *dicom_;
62 } 62 }
63 63
64 bool HasPixelData() const 64 bool HasPixelData() const
65 { 65 {
66 return hasPixelData_; 66 return hasPixelData_;
67 } 67 }
68 }; 68 };
69 69
70 70
71 void ParsedDicomFileCache::Acquire(const std::string& path, 71 void ParsedDicomFileCache::Acquire(const std::string& path,
72 boost::shared_ptr<Orthanc::ParsedDicomFile> dicom, 72 Orthanc::ParsedDicomFile* dicom,
73 size_t fileSize, 73 size_t fileSize,
74 bool hasPixelData) 74 bool hasPixelData)
75 { 75 {
76 cache_.Acquire(path, new Item(dicom, fileSize, hasPixelData)); 76 cache_.Acquire(path, new Item(dicom, fileSize, hasPixelData));
77 } 77 }
112 return item_->HasPixelData(); 112 return item_->HasPixelData();
113 } 113 }
114 } 114 }
115 115
116 116
117 boost::shared_ptr<Orthanc::ParsedDicomFile> ParsedDicomFileCache::Reader::GetDicom() const 117 Orthanc::ParsedDicomFile& ParsedDicomFileCache::Reader::GetDicom() const
118 { 118 {
119 if (item_ == NULL) 119 if (item_ == NULL)
120 { 120 {
121 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 121 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
122 } 122 }