Mercurial > hg > orthanc-transfers
annotate Framework/SourceDicomInstance.cpp @ 73:0a18367a3358 OrthancTransfers-1.5
1.5
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 26 Mar 2024 11:06:52 +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:
22
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 #include "SourceDicomInstance.h" | |
21 | |
22 | 22 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
23 | |
20 | 24 #include <Logging.h> |
25 #include <Toolbox.h> | |
0 | 26 |
27 | |
28 namespace OrthancPlugins | |
29 { | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
30 SourceDicomInstance::SourceDicomInstance(const std::string& instanceId) |
0 | 31 { |
32 LOG(INFO) << "Transfers accelerator reading DICOM instance: " << instanceId; | |
33 | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
34 MemoryBuffer buffer; |
0 | 35 buffer.GetDicomInstance(instanceId); |
36 | |
37 info_.reset(new DicomInstanceInfo(instanceId, buffer)); | |
38 | |
39 buffer_ = buffer.Release(); | |
40 } | |
41 | |
42 | |
43 SourceDicomInstance::~SourceDicomInstance() | |
44 { | |
8
4c3437217518
fix for compatibility with simplified OrthancPluginCppWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
45 OrthancPluginFreeMemoryBuffer(OrthancPlugins::GetGlobalContext(), &buffer_); |
0 | 46 } |
47 | |
48 | |
49 const DicomInstanceInfo& SourceDicomInstance::GetInfo() const | |
50 { | |
51 assert(info_.get() != NULL); | |
52 return *info_; | |
53 } | |
54 | |
55 | |
56 void SourceDicomInstance::GetChunk(std::string& target /* out */, | |
57 std::string& md5 /* out */, | |
58 size_t offset, | |
59 size_t size) const | |
60 { | |
61 if (offset + size > buffer_.size) | |
62 { | |
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
64 } | |
65 | |
66 const char* start = reinterpret_cast<const char*>(buffer_.data) + offset; | |
67 target.assign(start, start + size); | |
68 | |
69 Orthanc::Toolbox::ComputeMD5(md5, start, size); | |
70 } | |
71 } |