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