Mercurial > hg > orthanc
annotate OrthancServer/Sources/DicomInstanceToStore.cpp @ 4427:30efda56500d
trying to enable TLS support in DCMTK
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 31 Dec 2020 15:16:18 +0100 |
parents | 92737070b301 |
children | d9473bd5ed43 |
rev | line source |
---|---|
1003 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3342
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1003 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
1624
0a2ad4a6858f
fix missing precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
34 #include "PrecompiledHeadersServer.h" |
1003 | 35 #include "DicomInstanceToStore.h" |
36 | |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
37 #include "OrthancConfiguration.h" |
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
38 |
4045 | 39 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
40 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" | |
41 #include "../../OrthancFramework/Sources/Logging.h" | |
42 #include "../../OrthancFramework/Sources/OrthancException.h" | |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
43 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
44 #include <dcmtk/dcmdata/dcfilefo.h> |
2189
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
45 #include <dcmtk/dcmdata/dcdeftag.h> |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
46 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
47 |
1003 | 48 namespace Orthanc |
49 { | |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
50 // Anonymous namespace to avoid clashes between compilation modules |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
51 namespace |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
52 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
53 template <typename T> |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
54 class SmartContainer |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
55 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
56 private: |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
57 T* content_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
58 bool toDelete_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
59 bool isReadOnly_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
60 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
61 void Deallocate() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
62 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
63 if (content_ && toDelete_) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
64 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
65 delete content_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
66 toDelete_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
67 content_ = NULL; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
68 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
69 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
70 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
71 public: |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
72 SmartContainer() : content_(NULL), toDelete_(false), isReadOnly_(true) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
73 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
74 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
75 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
76 ~SmartContainer() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
77 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
78 Deallocate(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
79 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
80 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
81 void Allocate() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
82 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
83 Deallocate(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
84 content_ = new T; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
85 toDelete_ = true; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
86 isReadOnly_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
87 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
88 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
89 void TakeOwnership(T* content) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
90 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
91 if (content == NULL) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
92 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
93 throw OrthancException(ErrorCode_ParameterOutOfRange); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
94 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
95 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
96 Deallocate(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
97 content_ = content; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
98 toDelete_ = true; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
99 isReadOnly_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
100 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
101 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
102 void SetReference(T& content) // Read and write assign, without transfering ownership |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
103 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
104 Deallocate(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
105 content_ = &content; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
106 toDelete_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
107 isReadOnly_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
108 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
109 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
110 void SetConstReference(const T& content) // Read-only assign, without transfering ownership |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
111 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
112 Deallocate(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
113 content_ = &const_cast<T&>(content); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
114 toDelete_ = false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
115 isReadOnly_ = true; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
116 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
117 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
118 bool HasContent() const |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
119 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
120 return content_ != NULL; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
121 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
122 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
123 T& GetContent() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
124 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
125 if (content_ == NULL) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
126 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
127 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
128 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
129 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
130 if (isReadOnly_) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
131 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
132 throw OrthancException(ErrorCode_ReadOnly); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
133 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
134 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
135 return *content_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
136 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
137 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
138 const T& GetConstContent() const |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
139 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
140 if (content_ == NULL) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
141 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
142 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
143 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
144 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
145 return *content_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
146 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
147 }; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
148 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
149 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
150 |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
151 class DicomInstanceToStore::PImpl |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
152 { |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
153 public: |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
154 DicomInstanceOrigin origin_; |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
155 bool hasBuffer_; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
156 std::unique_ptr<std::string> ownBuffer_; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
157 const void* bufferData_; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
158 size_t bufferSize_; |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
159 SmartContainer<ParsedDicomFile> parsed_; |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
160 SmartContainer<DicomMap> summary_; |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
161 SmartContainer<Json::Value> json_; |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
162 MetadataMap metadata_; |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
163 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
164 PImpl() : |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
165 hasBuffer_(false), |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
166 bufferData_(NULL), |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
167 bufferSize_(0) |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
168 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
169 } |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
170 |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
171 private: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
172 std::unique_ptr<DicomInstanceHasher> hasher_; |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
173 |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
174 void ParseDicomFile() |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
175 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
176 if (!parsed_.HasContent()) |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
177 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
178 if (!hasBuffer_) |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
179 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
180 throw OrthancException(ErrorCode_InternalError); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
181 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
182 |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
183 if (ownBuffer_.get() != NULL) |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
184 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
185 parsed_.TakeOwnership(new ParsedDicomFile(*ownBuffer_)); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
186 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
187 else |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
188 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
189 parsed_.TakeOwnership(new ParsedDicomFile(bufferData_, bufferSize_)); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
190 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
191 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
192 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
193 |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
194 void ComputeMissingInformation() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
195 { |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
196 if (hasBuffer_ && |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
197 summary_.HasContent() && |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
198 json_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
199 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
200 // Fine, everything is available |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
201 return; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
202 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
203 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
204 if (!hasBuffer_) |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
205 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
206 if (!parsed_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
207 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
208 if (!summary_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
209 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
210 throw OrthancException(ErrorCode_NotImplemented); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
211 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
212 else |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
213 { |
3342
63f59ad9381a
Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
214 parsed_.TakeOwnership(new ParsedDicomFile(summary_.GetConstContent(), |
63f59ad9381a
Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
215 GetDefaultDicomEncoding(), |
4035
cc6ed76bba27
added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
216 false /* be strict */)); |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
217 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
218 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
219 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
220 // Serialize the parsed DICOM file |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
221 ownBuffer_.reset(new std::string); |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
222 if (!FromDcmtkBridge::SaveToMemoryBuffer(*ownBuffer_, |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
223 *parsed_.GetContent().GetDcmtkObject().getDataset())) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
224 { |
2955 | 225 throw OrthancException(ErrorCode_InternalError, |
226 "Unable to serialize a DICOM file to a memory buffer"); | |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
227 } |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
228 |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
229 hasBuffer_ = true; |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
230 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
231 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
232 if (summary_.HasContent() && |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
233 json_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
234 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
235 return; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
236 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
237 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
238 // At this point, we know that the DICOM file is available as a |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
239 // memory buffer, but that its summary or its JSON version is |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
240 // missing |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
241 |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
242 ParseDicomFile(); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
243 assert(parsed_.HasContent()); |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
244 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
245 // At this point, we have parsed the DICOM file |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
246 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
247 if (!summary_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
248 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
249 summary_.Allocate(); |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
250 OrthancConfiguration::DefaultExtractDicomSummary(summary_.GetContent(), parsed_.GetContent()); |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
251 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
252 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
253 if (!json_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
254 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
255 json_.Allocate(); |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4137
diff
changeset
|
256 OrthancConfiguration::DefaultDicomDatasetToJson(json_.GetContent(), parsed_.GetContent()); |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
257 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
258 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
259 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
260 |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
261 public: |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
262 void SetBuffer(const void* data, |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
263 size_t size) |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
264 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
265 ownBuffer_.reset(NULL); |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
266 bufferData_ = data; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
267 bufferSize_ = size; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
268 hasBuffer_ = true; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
269 } |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
270 |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
271 const void* GetBufferData() |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
272 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
273 ComputeMissingInformation(); |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
274 |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
275 if (!hasBuffer_) |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
276 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
277 throw OrthancException(ErrorCode_InternalError); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
278 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
279 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
280 if (ownBuffer_.get() != NULL) |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
281 { |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
282 if (ownBuffer_->empty()) |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
283 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
284 return NULL; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
285 } |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
286 else |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
287 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
288 return ownBuffer_->c_str(); |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
289 } |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
290 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
291 else |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
292 { |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
293 return bufferData_; |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
294 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
295 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
296 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
297 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
298 size_t GetBufferSize() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
299 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
300 ComputeMissingInformation(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
301 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
302 if (!hasBuffer_) |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
303 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
304 throw OrthancException(ErrorCode_InternalError); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
305 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
306 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
307 if (ownBuffer_.get() != NULL) |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
308 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
309 return ownBuffer_->size(); |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
310 } |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
311 else |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
312 { |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
313 return bufferSize_; |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
314 } |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
315 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
316 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
317 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
318 const DicomMap& GetSummary() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
319 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
320 ComputeMissingInformation(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
321 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
322 if (!summary_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
323 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
324 throw OrthancException(ErrorCode_InternalError); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
325 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
326 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
327 return summary_.GetConstContent(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
328 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
329 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
330 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
331 const Json::Value& GetJson() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
332 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
333 ComputeMissingInformation(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
334 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
335 if (!json_.HasContent()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
336 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
337 throw OrthancException(ErrorCode_InternalError); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
338 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
339 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
340 return json_.GetConstContent(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
341 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
342 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
343 |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
344 DicomInstanceHasher& GetHasher() |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
345 { |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
346 if (hasher_.get() == NULL) |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
347 { |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
348 hasher_.reset(new DicomInstanceHasher(GetSummary())); |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
349 } |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
350 |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
351 if (hasher_.get() == NULL) |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
352 { |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
353 throw OrthancException(ErrorCode_InternalError); |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
354 } |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
355 |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
356 return *hasher_; |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
357 } |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
358 |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
359 |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
360 bool LookupTransferSyntax(std::string& result) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
361 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
362 ComputeMissingInformation(); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
363 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
364 DicomMap header; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
365 if (DicomMap::ParseDicomMetaInformation(header, GetBufferData(), GetBufferSize())) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
366 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
367 const DicomValue* value = header.TestAndGetValue(DICOM_TAG_TRANSFER_SYNTAX_UID); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
368 if (value != NULL && |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
369 !value->IsBinary() && |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
370 !value->IsNull()) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
371 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
372 result = Toolbox::StripSpaces(value->GetContent()); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
373 return true; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
374 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
375 } |
4385
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
376 else |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
377 { |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
378 // This is a DICOM file without a proper meta-header. Fallback |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
379 // to DCMTK, which will fully parse the dataset to retrieve |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
380 // the transfer syntax. Added in Orthanc 1.8.2. |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
381 std::string transferSyntax; |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
382 if (GetParsedDicomFile().LookupTransferSyntax(transferSyntax)) |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
383 { |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
384 result = Toolbox::StripSpaces(transferSyntax); |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
385 return true; |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
386 } |
92737070b301
If meta-header is missing, best-effort to extract "TransferSyntax" in "/instances/{id}/metadata"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4140
diff
changeset
|
387 } |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
388 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
389 return false; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
390 } |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
391 |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
392 |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
393 ParsedDicomFile& GetParsedDicomFile() |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
394 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
395 ComputeMissingInformation(); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
396 ParseDicomFile(); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
397 |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
398 if (parsed_.HasContent()) |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
399 { |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
400 return parsed_.GetContent(); |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
401 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
402 else |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
403 { |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
404 throw OrthancException(ErrorCode_InternalError); |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
405 } |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
406 } |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
407 }; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
408 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
409 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
410 DicomInstanceToStore::DicomInstanceToStore() : |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
411 pimpl_(new PImpl) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
412 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
413 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
414 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
415 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
416 void DicomInstanceToStore::SetOrigin(const DicomInstanceOrigin& origin) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
417 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
418 pimpl_->origin_ = origin; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
419 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
420 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
421 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
422 const DicomInstanceOrigin& DicomInstanceToStore::GetOrigin() const |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
423 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
424 return pimpl_->origin_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
425 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
426 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
427 |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
428 void DicomInstanceToStore::SetBuffer(const void* dicom, |
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
429 size_t size) |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
430 { |
3841
be7df7fe3d80
avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
431 pimpl_->SetBuffer(dicom, size); |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
432 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
433 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
434 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
435 void DicomInstanceToStore::SetParsedDicomFile(ParsedDicomFile& parsed) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
436 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
437 pimpl_->parsed_.SetReference(parsed); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
438 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
439 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
440 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
441 void DicomInstanceToStore::SetSummary(const DicomMap& summary) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
442 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
443 pimpl_->summary_.SetConstReference(summary); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
444 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
445 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
446 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
447 void DicomInstanceToStore::SetJson(const Json::Value& json) |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
448 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
449 pimpl_->json_.SetConstReference(json); |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
450 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
451 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
452 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
453 const DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata() const |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
454 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
455 return pimpl_->metadata_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
456 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
457 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
458 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
459 DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata() |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
460 { |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
461 return pimpl_->metadata_; |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
462 } |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
463 |
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
464 |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
465 void DicomInstanceToStore::AddMetadata(ResourceType level, |
1003 | 466 MetadataType metadata, |
467 const std::string& value) | |
468 { | |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
469 pimpl_->metadata_[std::make_pair(level, metadata)] = value; |
1003 | 470 } |
471 | |
472 | |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
473 const void* DicomInstanceToStore::GetBufferData() const |
1003 | 474 { |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
475 return const_cast<PImpl&>(*pimpl_).GetBufferData(); |
1003 | 476 } |
477 | |
478 | |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
479 size_t DicomInstanceToStore::GetBufferSize() const |
1003 | 480 { |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
481 return const_cast<PImpl&>(*pimpl_).GetBufferSize(); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
482 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
483 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
484 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
485 const DicomMap& DicomInstanceToStore::GetSummary() |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
486 { |
2894
a27b0e9a3fd9
refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2640
diff
changeset
|
487 return pimpl_->GetSummary(); |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
488 } |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
489 |
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
490 |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
491 const Json::Value& DicomInstanceToStore::GetJson() const |
1004
a226e0959d8b
DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1003
diff
changeset
|
492 { |
3847
1491d501836a
actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3845
diff
changeset
|
493 return const_cast<PImpl&>(*pimpl_).GetJson(); |
1003 | 494 } |
1572
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
495 |
904096e7367e
More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
496 |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
497 bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) const |
2189
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
498 { |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
499 return const_cast<PImpl&>(*pimpl_).LookupTransferSyntax(result); |
2189
c4b3259c8bce
New metadata automatically computed at the instance level: "TransferSyntax"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
500 } |
2898
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
501 |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
502 |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
503 DicomInstanceHasher& DicomInstanceToStore::GetHasher() |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
504 { |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
505 return pimpl_->GetHasher(); |
e5e3253a1164
DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2894
diff
changeset
|
506 } |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
507 |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
508 bool DicomInstanceToStore::HasPixelData() const |
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
509 { |
3912
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
510 return const_cast<PImpl&>(*pimpl_).GetParsedDicomFile().HasTag(DICOM_TAG_PIXEL_DATA); |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
511 } |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
512 |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
513 ParsedDicomFile& DicomInstanceToStore::GetParsedDicomFile() const |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
514 { |
7610af1532c3
prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3847
diff
changeset
|
515 return const_cast<PImpl&>(*pimpl_).GetParsedDicomFile(); |
3845
281045a1e6db
new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3841
diff
changeset
|
516 } |
1003 | 517 } |