Mercurial > hg > orthanc-transfers
annotate Framework/DownloadArea.h @ 72:d60d1a3a7357 OrthancTransfers-1.4
fix md5
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 26 Mar 2024 10:16:15 +0100 |
parents | 44a0430d7899 |
children | 1e396fb509ca |
rev | line source |
---|---|
0 | 1 /** |
2 * Transfers accelerator plugin for Orthanc | |
33
44a0430d7899
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
20
diff
changeset
|
3 * Copyright (C) 2018-2021 Osimis S.A., Belgium |
0 | 4 * |
5 * This program is free software: you can redistribute it and/or | |
6 * modify it under the terms of the GNU Affero General Public License | |
7 * as published by the Free Software Foundation, either version 3 of | |
8 * the License, or (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, but | |
11 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Affero General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Affero General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 **/ | |
18 | |
19 | |
20 #pragma once | |
21 | |
22 #include "TransferScheduler.h" | |
23 | |
20 | 24 #include <TemporaryFile.h> |
0 | 25 |
26 namespace OrthancPlugins | |
27 { | |
28 class DownloadArea : public boost::noncopyable | |
29 { | |
30 private: | |
31 class Instance : public boost::noncopyable | |
32 { | |
33 private: | |
34 DicomInstanceInfo info_; | |
35 Orthanc::TemporaryFile file_; | |
36 | |
37 class Writer; | |
38 | |
39 public: | |
12 | 40 explicit Instance(const DicomInstanceInfo& info); |
0 | 41 |
42 const DicomInstanceInfo& GetInfo() const | |
43 { | |
44 return info_; | |
45 } | |
46 | |
47 void WriteChunk(size_t offset, | |
48 const void* data, | |
49 size_t size); | |
50 | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
51 void Commit(bool simulate) const; |
0 | 52 }; |
53 | |
54 | |
55 typedef std::map<std::string, Instance*> Instances; | |
56 | |
57 boost::mutex mutex_; | |
58 Instances instances_; | |
59 size_t totalSize_; | |
60 | |
61 | |
62 void Clear(); | |
63 | |
64 Instance& LookupInstance(const std::string& id); | |
65 | |
66 void WriteUncompressedBucket(const TransferBucket& bucket, | |
67 const void* data, | |
68 size_t size); | |
69 | |
70 void Setup(const std::vector<DicomInstanceInfo>& instances); | |
71 | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
72 void CommitInternal(bool simulate); |
0 | 73 |
74 public: | |
12 | 75 explicit DownloadArea(const TransferScheduler& scheduler); |
0 | 76 |
12 | 77 explicit DownloadArea(const std::vector<DicomInstanceInfo>& instances) |
0 | 78 { |
79 Setup(instances); | |
80 } | |
81 | |
82 ~DownloadArea() | |
83 { | |
84 Clear(); | |
85 } | |
86 | |
87 size_t GetTotalSize() const | |
88 { | |
89 return totalSize_; | |
90 } | |
91 | |
92 void WriteBucket(const TransferBucket& bucket, | |
93 const void* data, | |
94 size_t size, | |
95 BucketCompression compression); | |
96 | |
97 void WriteInstance(const std::string& instanceId, | |
98 const void* data, | |
99 size_t size); | |
100 | |
101 void CheckMD5(); | |
102 | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
103 void Commit(); |
0 | 104 }; |
105 } |