annotate OrthancServer/Sources/DicomInstanceToStore.cpp @ 4072:3dda0d73193c framework

fix doxygen, more tolerant WebServiceParameters::SetUrl()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Jun 2020 16:28:03 +0200
parents 05b8fd21089c
children 2724977419fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1854
diff changeset
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
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1624
0a2ad4a6858f fix missing precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
34 #include "PrecompiledHeadersServer.h"
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "DicomInstanceToStore.h"
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
38 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
40 #include "../../OrthancFramework/Sources/OrthancException.h"
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
41
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
42 #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
43 #include <dcmtk/dcmdata/dcdeftag.h>
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
44
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
45
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 namespace Orthanc
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
48 // Anonymous namespace to avoid clashes between compilation modules
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
49 namespace
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
50 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
51 template <typename T>
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
52 class SmartContainer
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
53 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
54 private:
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
55 T* content_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
56 bool toDelete_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
57 bool isReadOnly_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
58
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
59 void Deallocate()
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 if (content_ && toDelete_)
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 delete content_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
64 toDelete_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
65 content_ = NULL;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
66 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
67 }
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 public:
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
70 SmartContainer() : content_(NULL), toDelete_(false), isReadOnly_(true)
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
71 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
72 }
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 ~SmartContainer()
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 Deallocate();
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
79 void Allocate()
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 Deallocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
82 content_ = new T;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
83 toDelete_ = true;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
84 isReadOnly_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
85 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
86
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
87 void TakeOwnership(T* content)
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 if (content == NULL)
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 throw OrthancException(ErrorCode_ParameterOutOfRange);
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
94 Deallocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
95 content_ = content;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
96 toDelete_ = true;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
97 isReadOnly_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
98 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
99
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
100 void SetReference(T& content) // Read and write assign, without transfering ownership
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 Deallocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
103 content_ = &content;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
104 toDelete_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
105 isReadOnly_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
106 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
107
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
108 void SetConstReference(const T& content) // Read-only assign, without transfering ownership
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 Deallocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
111 content_ = &const_cast<T&>(content);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
112 toDelete_ = false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
113 isReadOnly_ = true;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
114 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
115
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
116 bool HasContent() const
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 return content_ != NULL;
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
121 T& GetContent()
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 if (content_ == NULL)
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
128 if (isReadOnly_)
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 throw OrthancException(ErrorCode_ReadOnly);
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
133 return *content_;
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
136 const T& GetConstContent() const
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 if (content_ == NULL)
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 throw OrthancException(ErrorCode_BadSequenceOfCalls);
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
143 return *content_;
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 };
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
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
149 class DicomInstanceToStore::PImpl
2894
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 public:
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
152 DicomInstanceOrigin origin_;
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
153 bool hasBuffer_;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
154 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
155 const void* bufferData_;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
156 size_t bufferSize_;
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
157 SmartContainer<ParsedDicomFile> parsed_;
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
158 SmartContainer<DicomMap> summary_;
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
159 SmartContainer<Json::Value> json_;
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
160 MetadataMap metadata_;
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
161
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
162 PImpl() :
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
163 hasBuffer_(false),
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
164 bufferData_(NULL),
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
165 bufferSize_(0)
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
166 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
167 }
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
168
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
169 private:
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
170 std::unique_ptr<DicomInstanceHasher> hasher_;
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
171
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
172 void ParseDicomFile()
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
173 {
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
174 if (!parsed_.HasContent())
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 (!hasBuffer_)
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 throw OrthancException(ErrorCode_InternalError);
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
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
181 if (ownBuffer_.get() != NULL)
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 parsed_.TakeOwnership(new ParsedDicomFile(*ownBuffer_));
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 else
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 parsed_.TakeOwnership(new ParsedDicomFile(bufferData_, bufferSize_));
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 }
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
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
192 void ComputeMissingInformation()
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
193 {
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
194 if (hasBuffer_ &&
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
195 summary_.HasContent() &&
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
196 json_.HasContent())
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
197 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
198 // Fine, everything is available
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
199 return;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
200 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
201
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
202 if (!hasBuffer_)
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
203 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
204 if (!parsed_.HasContent())
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 (!summary_.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 throw OrthancException(ErrorCode_NotImplemented);
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 else
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
211 {
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
212 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
213 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
214 false /* be strict */));
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
215 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
216 }
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 // 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
219 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
220 if (!FromDcmtkBridge::SaveToMemoryBuffer(*ownBuffer_,
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
221 *parsed_.GetContent().GetDcmtkObject().getDataset()))
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
222 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
223 throw OrthancException(ErrorCode_InternalError,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2898
diff changeset
224 "Unable to serialize a DICOM file to a memory buffer");
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
225 }
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
226
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
227 hasBuffer_ = true;
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
228 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
229
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
230 if (summary_.HasContent() &&
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
231 json_.HasContent())
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
232 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
233 return;
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
236 // 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
237 // memory buffer, but that its summary or its JSON version is
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
238 // missing
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
239
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
240 ParseDicomFile();
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
241 assert(parsed_.HasContent());
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
242
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
243 // At this point, we have parsed the DICOM file
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 if (!summary_.HasContent())
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 summary_.Allocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
248 FromDcmtkBridge::ExtractDicomSummary(summary_.GetContent(),
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
249 *parsed_.GetContent().GetDcmtkObject().getDataset());
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
250 }
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 if (!json_.HasContent())
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
253 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
254 json_.Allocate();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
255
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
256 std::set<DicomTag> ignoreTagLength;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
257 FromDcmtkBridge::ExtractDicomAsJson(json_.GetContent(),
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
258 *parsed_.GetContent().GetDcmtkObject().getDataset(),
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
259 ignoreTagLength);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
260 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
261 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
262
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
263
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
264 public:
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
265 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
266 size_t size)
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
267 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
268 ownBuffer_.reset(NULL);
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
269 bufferData_ = data;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
270 bufferSize_ = size;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
271 hasBuffer_ = true;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
272 }
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
273
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
274 const void* GetBufferData()
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
275 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
276 ComputeMissingInformation();
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
277
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
278 if (!hasBuffer_)
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
279 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
280 throw OrthancException(ErrorCode_InternalError);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
281 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
282
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
283 if (ownBuffer_.get() != NULL)
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
284 {
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
285 if (ownBuffer_->empty())
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
286 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
287 return NULL;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
288 }
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
289 else
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
290 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
291 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
292 }
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
293 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
294 else
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
295 {
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
296 return bufferData_;
2894
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 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
301 size_t GetBufferSize()
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
302 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
303 ComputeMissingInformation();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
304
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
305 if (!hasBuffer_)
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
306 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
307 throw OrthancException(ErrorCode_InternalError);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
308 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
309
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
310 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
311 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
312 return ownBuffer_->size();
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
313 }
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
314 else
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
315 {
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
316 return bufferSize_;
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
317 }
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
318 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
321 const DicomMap& GetSummary()
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
322 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
323 ComputeMissingInformation();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
324
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
325 if (!summary_.HasContent())
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 throw OrthancException(ErrorCode_InternalError);
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 return summary_.GetConstContent();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
331 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
334 const Json::Value& GetJson()
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
335 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
336 ComputeMissingInformation();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
337
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
338 if (!json_.HasContent())
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 throw OrthancException(ErrorCode_InternalError);
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 return json_.GetConstContent();
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
344 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
345
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
346
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
347 DicomInstanceHasher& GetHasher()
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
348 {
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
349 if (hasher_.get() == NULL)
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 hasher_.reset(new DicomInstanceHasher(GetSummary()));
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
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
354 if (hasher_.get() == NULL)
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 throw OrthancException(ErrorCode_InternalError);
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 return *hasher_;
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
360 }
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
361
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
362
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
363 bool LookupTransferSyntax(std::string& result)
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
364 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
365 ComputeMissingInformation();
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 DicomMap header;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
368 if (DicomMap::ParseDicomMetaInformation(header, GetBufferData(), GetBufferSize()))
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
369 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
370 const DicomValue* value = header.TestAndGetValue(DICOM_TAG_TRANSFER_SYNTAX_UID);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
371 if (value != NULL &&
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
372 !value->IsBinary() &&
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
373 !value->IsNull())
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 result = Toolbox::StripSpaces(value->GetContent());
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
376 return true;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
377 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
378 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
379
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
380 return false;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
381 }
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
382
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
383
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
384 ParsedDicomFile& GetParsedDicomFile()
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
385 {
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
386 ComputeMissingInformation();
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
387 ParseDicomFile();
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
388
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
389 if (parsed_.HasContent())
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
390 {
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
391 return parsed_.GetContent();
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
392 }
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
393 else
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 throw OrthancException(ErrorCode_InternalError);
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
396 }
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
397 }
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
398 };
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
399
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
400
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
401 DicomInstanceToStore::DicomInstanceToStore() :
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
402 pimpl_(new PImpl)
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
403 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
404 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
405
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
406
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
407 void DicomInstanceToStore::SetOrigin(const DicomInstanceOrigin& origin)
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 pimpl_->origin_ = origin;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
410 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
411
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 const DicomInstanceOrigin& DicomInstanceToStore::GetOrigin() const
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 return pimpl_->origin_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
416 }
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
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
419 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
420 size_t size)
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
421 {
3841
be7df7fe3d80 avoid one memcpy of the DICOM buffer on "POST /instances"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
422 pimpl_->SetBuffer(dicom, size);
2894
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
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 void DicomInstanceToStore::SetParsedDicomFile(ParsedDicomFile& parsed)
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
427 {
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
428 pimpl_->parsed_.SetReference(parsed);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
429 }
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
430
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
431
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
432 void DicomInstanceToStore::SetSummary(const DicomMap& summary)
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 pimpl_->summary_.SetConstReference(summary);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
435 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
438 void DicomInstanceToStore::SetJson(const Json::Value& json)
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 pimpl_->json_.SetConstReference(json);
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
441 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
444 const DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata() const
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 return pimpl_->metadata_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
447 }
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
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
450 DicomInstanceToStore::MetadataMap& DicomInstanceToStore::GetMetadata()
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 return pimpl_->metadata_;
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
453 }
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
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
456 void DicomInstanceToStore::AddMetadata(ResourceType level,
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 MetadataType metadata,
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 const std::string& value)
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 {
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
460 pimpl_->metadata_[std::make_pair(level, metadata)] = value;
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
464 const void* DicomInstanceToStore::GetBufferData() const
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
466 return const_cast<PImpl&>(*pimpl_).GetBufferData();
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 }
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
470 size_t DicomInstanceToStore::GetBufferSize() const
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
472 return const_cast<PImpl&>(*pimpl_).GetBufferSize();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
473 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
474
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
475
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
476 const DicomMap& DicomInstanceToStore::GetSummary()
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
477 {
2894
a27b0e9a3fd9 refactoring DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2640
diff changeset
478 return pimpl_->GetSummary();
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
479 }
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
480
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
481
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
482 const Json::Value& DicomInstanceToStore::GetJson() const
1004
a226e0959d8b DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1003
diff changeset
483 {
3847
1491d501836a actual implementation of OrthancPluginRegisterIncomingDicomInstanceFilter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3845
diff changeset
484 return const_cast<PImpl&>(*pimpl_).GetJson();
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 }
1572
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
486
904096e7367e More information about the origin request in OnStoredInstance() callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
487
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
488 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
489 {
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
490 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
491 }
2898
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
492
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
493
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
494 DicomInstanceHasher& DicomInstanceToStore::GetHasher()
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
495 {
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
496 return pimpl_->GetHasher();
e5e3253a1164 DicomInstanceToStore::GetHasher()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2894
diff changeset
497 }
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
498
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
499 bool DicomInstanceToStore::HasPixelData() const
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
500 {
3912
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
501 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
502 }
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
503
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
504 ParsedDicomFile& DicomInstanceToStore::GetParsedDicomFile() const
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
505 {
7610af1532c3 prototyping automated transcoding of incoming DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3847
diff changeset
506 return const_cast<PImpl&>(*pimpl_).GetParsedDicomFile();
3845
281045a1e6db new "info" field in "ReceivedInstanceFilter()" callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3841
diff changeset
507 }
1003
1d35281d967c DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 }