comparison Framework/Toolbox/ParsedDicomFileCache.cpp @ 1116:a08699daf78b broker

ParsedDicomFileCache
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2019 15:54:35 +0100
parents
children a8bf81756839
comparison
equal deleted inserted replaced
1111:3730956f41a5 1116:a08699daf78b
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "ParsedDicomFileCache.h"
23
24 namespace OrthancStone
25 {
26 class ParsedDicomFileCache::Item : public Orthanc::ICacheable
27 {
28 private:
29 std::auto_ptr<Orthanc::ParsedDicomFile> dicom_;
30 size_t fileSize_;
31
32 public:
33 Item(Orthanc::ParsedDicomFile* dicom,
34 size_t fileSize) :
35 dicom_(dicom),
36 fileSize_(fileSize)
37 {
38 if (dicom == NULL)
39 {
40 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
41 }
42 }
43
44 virtual size_t GetMemoryUsage() const
45 {
46 return fileSize_;
47 }
48
49 const Orthanc::ParsedDicomFile& GetDicom() const
50 {
51 assert(dicom_.get() != NULL);
52 return *dicom_;
53 }
54 };
55
56
57 void ParsedDicomFileCache::Acquire(const std::string& sopInstanceUid,
58 Orthanc::ParsedDicomFile* dicom,
59 size_t fileSize)
60 {
61 cache_.Acquire(sopInstanceUid, new Item(dicom, fileSize));
62 }
63
64
65 const Orthanc::ParsedDicomFile& ParsedDicomFileCache::Reader::GetDicom() const
66 {
67 return dynamic_cast<const Item&>(reader_.GetValue()).GetDicom();
68 }
69 }