Mercurial > hg > orthanc
annotate OrthancServer/DicomProtocol/DicomUserConnection.cpp @ 1092:88fcf73fbe39
Upgrade to Google Test 1.7.0
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Aug 2014 12:36:53 +0200 |
parents | 9d0c7301596e |
children | b17b6bd59747 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
0 | 4 * Belgium |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
33 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
34 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
35 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
36 This file is based on portions of the following project: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
37 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
38 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
39 Module: http://dicom.offis.de/dcmtk.php.en |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
40 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
41 Copyright (C) 1994-2011, OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
42 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
43 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
44 This software and supporting documentation were developed by |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
45 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
46 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
47 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
48 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
49 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
50 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
51 Redistribution and use in source and binary forms, with or without |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
52 modification, are permitted provided that the following conditions |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
53 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
54 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
55 - Redistributions of source code must retain the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
56 notice, this list of conditions and the following disclaimer. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
57 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
58 - Redistributions in binary form must reproduce the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
59 notice, this list of conditions and the following disclaimer in the |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
60 documentation and/or other materials provided with the distribution. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
61 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
62 - Neither the name of OFFIS nor the names of its contributors may be |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
63 used to endorse or promote products derived from this software |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
64 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
65 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
66 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
67 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
68 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
69 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
70 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
71 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
72 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
73 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
74 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
75 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
76 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
77 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
78 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
79 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
80 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
81 #include "../PrecompiledHeadersServer.h" |
0 | 82 #include "DicomUserConnection.h" |
83 | |
62 | 84 #include "../../Core/OrthancException.h" |
0 | 85 #include "../ToDcmtkBridge.h" |
86 #include "../FromDcmtkBridge.h" | |
87 | |
88 #include <dcmtk/dcmdata/dcistrmb.h> | |
89 #include <dcmtk/dcmdata/dcistrmf.h> | |
90 #include <dcmtk/dcmdata/dcfilefo.h> | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
91 #include <dcmtk/dcmdata/dcmetinf.h> |
0 | 92 #include <dcmtk/dcmnet/diutil.h> |
93 | |
94 #include <set> | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
95 #include <glog/logging.h> |
0 | 96 |
97 | |
98 | |
99 #ifdef _WIN32 | |
100 /** | |
101 * "The maximum length, in bytes, of the string returned in the buffer | |
102 * pointed to by the name parameter is dependent on the namespace provider, | |
103 * but this string must be 256 bytes or less. | |
104 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx | |
105 **/ | |
106 #define HOST_NAME_MAX 256 | |
107 #endif | |
108 | |
109 | |
918 | 110 #if !defined(HOST_NAME_MAX) && defined(_POSIX_HOST_NAME_MAX) |
890 | 111 /** |
112 * TO IMPROVE: "_POSIX_HOST_NAME_MAX is only the minimum value that | |
113 * HOST_NAME_MAX can ever have [...] Therefore you cannot allocate an | |
114 * array of size _POSIX_HOST_NAME_MAX, invoke gethostname() and expect | |
115 * that the result will fit." | |
116 * http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00128.html | |
117 **/ | |
118 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX | |
119 #endif | |
120 | |
121 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
122 static const char* DEFAULT_PREFERRED_TRANSFER_SYNTAX = UID_LittleEndianImplicitTransferSyntax; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
123 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
124 /** |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
125 * "If we have more than 64 storage SOP classes, tools such as |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
126 * storescu will fail because they attempt to negotiate two |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
127 * presentation contexts for each SOP class, and there is a total |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
128 * limit of 128 contexts for one association." |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
129 **/ |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
130 static const unsigned int MAXIMUM_STORAGE_SOP_CLASSES = 64; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
131 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
132 |
62 | 133 namespace Orthanc |
0 | 134 { |
135 struct DicomUserConnection::PImpl | |
136 { | |
137 // Connection state | |
138 T_ASC_Network* net_; | |
139 T_ASC_Parameters* params_; | |
140 T_ASC_Association* assoc_; | |
141 | |
142 bool IsOpen() const | |
143 { | |
144 return assoc_ != NULL; | |
145 } | |
146 | |
147 void CheckIsOpen() const; | |
148 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
149 void Store(DcmInputStream& is, DicomUserConnection& connection); |
0 | 150 }; |
151 | |
152 | |
153 static void Check(const OFCondition& cond) | |
154 { | |
155 if (cond.bad()) | |
156 { | |
1017 | 157 LOG(ERROR) << "DicomUserConnection: " << std::string(cond.text()); |
158 throw OrthancException(ErrorCode_NetworkProtocol); | |
0 | 159 } |
160 } | |
161 | |
162 void DicomUserConnection::PImpl::CheckIsOpen() const | |
163 { | |
164 if (!IsOpen()) | |
165 { | |
1017 | 166 LOG(ERROR) << "DicomUserConnection: First open the connection"; |
167 throw OrthancException(ErrorCode_NetworkProtocol); | |
0 | 168 } |
169 } | |
170 | |
171 | |
172 void DicomUserConnection::CheckIsOpen() const | |
173 { | |
174 pimpl_->CheckIsOpen(); | |
175 } | |
176 | |
177 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
178 static void RegisterStorageSOPClass(T_ASC_Parameters* params, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
179 unsigned int& presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
180 const std::string& sopClass, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
181 const char* asPreferred[], |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
182 std::vector<const char*>& asFallback) |
0 | 183 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
184 Check(ASC_addPresentationContext(params, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
185 sopClass.c_str(), asPreferred, 1)); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
186 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
187 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
188 if (asFallback.size() > 0) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
189 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
190 Check(ASC_addPresentationContext(params, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
191 sopClass.c_str(), &asFallback[0], asFallback.size())); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
192 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
193 } |
0 | 194 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
195 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
196 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
197 void DicomUserConnection::SetupPresentationContexts(const std::string& preferredTransferSyntax) |
0 | 198 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
199 // Flatten an array with the preferred transfer syntax |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
200 const char* asPreferred[1] = { preferredTransferSyntax.c_str() }; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
201 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
202 // Setup the fallback transfer syntaxes |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
203 std::set<std::string> fallbackSyntaxes; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
204 fallbackSyntaxes.insert(UID_LittleEndianExplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
205 fallbackSyntaxes.insert(UID_BigEndianExplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
206 fallbackSyntaxes.insert(UID_LittleEndianImplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
207 fallbackSyntaxes.erase(preferredTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
208 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
209 // Flatten an array with the fallback transfer syntaxes |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
210 std::vector<const char*> asFallback; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
211 asFallback.reserve(fallbackSyntaxes.size()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
212 for (std::set<std::string>::const_iterator |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
213 it = fallbackSyntaxes.begin(); it != fallbackSyntaxes.end(); ++it) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
214 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
215 asFallback.push_back(it->c_str()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
216 } |
0 | 217 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
218 CheckStorageSOPClassesInvariant(); |
0 | 219 unsigned int presentationContextId = 1; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
220 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
221 for (std::list<std::string>::const_iterator it = reservedStorageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
222 it != reservedStorageSOPClasses_.end(); ++it) |
0 | 223 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
224 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
225 *it, asPreferred, asFallback); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
226 } |
0 | 227 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
228 for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
229 it != storageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
230 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
231 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
232 *it, asPreferred, asFallback); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
233 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
234 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
235 for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
236 it != defaultStorageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
237 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
238 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
239 *it, asPreferred, asFallback); |
0 | 240 } |
241 } | |
242 | |
243 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
244 static bool IsGenericTransferSyntax(const std::string& syntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
245 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
246 return (syntax == UID_LittleEndianExplicitTransferSyntax || |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
247 syntax == UID_BigEndianExplicitTransferSyntax || |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
248 syntax == UID_LittleEndianImplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
249 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
250 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
251 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
252 void DicomUserConnection::PImpl::Store(DcmInputStream& is, DicomUserConnection& connection) |
0 | 253 { |
254 CheckIsOpen(); | |
255 | |
256 DcmFileFormat dcmff; | |
257 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength)); | |
258 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
259 // Determine the storage SOP class UID for this instance |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
260 static const DcmTagKey DCM_SOP_CLASS_UID(0x0008, 0x0016); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
261 OFString sopClassUid; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
262 if (dcmff.getDataset()->findAndGetOFString(DCM_SOP_CLASS_UID, sopClassUid).good()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
263 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
264 connection.AddStorageSOPClass(sopClassUid.c_str()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
265 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
266 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
267 // Determine whether a new presentation context must be |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
268 // negotiated, depending on the transfer syntax of this instance |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
269 DcmXfer xfer(dcmff.getDataset()->getOriginalXfer()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
270 const std::string syntax(xfer.getXferID()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
271 bool isGeneric = IsGenericTransferSyntax(syntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
272 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
273 if (isGeneric ^ IsGenericTransferSyntax(connection.GetPreferredTransferSyntax())) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
274 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
275 // Making a generic-to-specific or specific-to-generic change of |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
276 // the transfer syntax. Renegotiate the connection. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
277 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated"; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
278 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
279 if (isGeneric) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
280 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
281 connection.ResetPreferredTransferSyntax(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
282 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
283 else |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
284 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
285 connection.SetPreferredTransferSyntax(syntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
286 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
287 } |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
288 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
289 if (!connection.IsOpen()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
290 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
291 LOG(INFO) << "Renegotiating a C-Store association due to a change in the parameters"; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
292 connection.Open(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
293 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
294 |
0 | 295 // Figure out which SOP class and SOP instance is encapsulated in the file |
296 DIC_UI sopClass; | |
297 DIC_UI sopInstance; | |
298 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance)) | |
299 { | |
62 | 300 throw OrthancException("DicomUserConnection: Unable to find the SOP class and instance"); |
0 | 301 } |
302 | |
303 // Figure out which of the accepted presentation contexts should be used | |
304 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass); | |
305 if (presID == 0) | |
306 { | |
307 const char *modalityName = dcmSOPClassUIDToModality(sopClass); | |
308 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass); | |
309 if (!modalityName) modalityName = "unknown SOP class"; | |
62 | 310 throw OrthancException("DicomUserConnection: No presentation context for modality " + |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
311 std::string(modalityName)); |
0 | 312 } |
313 | |
314 // Prepare the transmission of data | |
315 T_DIMSE_C_StoreRQ req; | |
316 memset(&req, 0, sizeof(req)); | |
317 req.MessageID = assoc_->nextMsgID++; | |
318 strcpy(req.AffectedSOPClassUID, sopClass); | |
319 strcpy(req.AffectedSOPInstanceUID, sopInstance); | |
320 req.DataSetType = DIMSE_DATASET_PRESENT; | |
321 req.Priority = DIMSE_PRIORITY_MEDIUM; | |
322 | |
323 // Finally conduct transmission of data | |
324 T_DIMSE_C_StoreRSP rsp; | |
325 DcmDataset* statusDetail = NULL; | |
326 Check(DIMSE_storeUser(assoc_, presID, &req, | |
327 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL, | |
328 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0, | |
329 &rsp, &statusDetail, NULL)); | |
330 | |
331 if (statusDetail != NULL) | |
332 { | |
333 delete statusDetail; | |
334 } | |
335 } | |
336 | |
337 | |
338 static void FindCallback( | |
339 /* in */ | |
340 void *callbackData, | |
341 T_DIMSE_C_FindRQ *request, /* original find request */ | |
342 int responseCount, | |
343 T_DIMSE_C_FindRSP *response, /* pending response received */ | |
344 DcmDataset *responseIdentifiers /* pending response identifiers */ | |
345 ) | |
346 { | |
657
5425bb6f1ea5
further cppcheck fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
347 DicomFindAnswers& answers = *reinterpret_cast<DicomFindAnswers*>(callbackData); |
0 | 348 |
349 if (responseIdentifiers != NULL) | |
350 { | |
351 DicomMap m; | |
352 FromDcmtkBridge::Convert(m, *responseIdentifiers); | |
353 answers.Add(m); | |
354 } | |
355 } | |
356 | |
357 void DicomUserConnection::Find(DicomFindAnswers& result, | |
358 FindRootModel model, | |
359 const DicomMap& fields) | |
360 { | |
361 CheckIsOpen(); | |
362 | |
363 const char* sopClass; | |
364 std::auto_ptr<DcmDataset> dataset(ToDcmtkBridge::Convert(fields)); | |
365 switch (model) | |
366 { | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
367 case FindRootModel_Patient: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
368 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "PATIENT"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
369 sopClass = UID_FINDPatientRootQueryRetrieveInformationModel; |
0 | 370 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
371 // Accession number |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
372 if (!fields.HasTag(0x0008, 0x0050)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
373 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), ""); |
0 | 374 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
375 // Patient ID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
376 if (!fields.HasTag(0x0010, 0x0020)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
377 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0010, 0x0020), ""); |
0 | 378 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
379 break; |
0 | 380 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
381 case FindRootModel_Study: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
382 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "STUDY"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
383 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
0 | 384 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
385 // Accession number |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
386 if (!fields.HasTag(0x0008, 0x0050)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
387 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), ""); |
0 | 388 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
389 // Study instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
390 if (!fields.HasTag(0x0020, 0x000d)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
391 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), ""); |
0 | 392 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
393 break; |
0 | 394 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
395 case FindRootModel_Series: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
396 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "SERIES"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
397 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
0 | 398 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
399 // Accession number |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
400 if (!fields.HasTag(0x0008, 0x0050)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
401 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), ""); |
0 | 402 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
403 // Study instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
404 if (!fields.HasTag(0x0020, 0x000d)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
405 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), ""); |
0 | 406 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
407 // Series instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
408 if (!fields.HasTag(0x0020, 0x000e)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
409 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000e), ""); |
0 | 410 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
411 break; |
0 | 412 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
413 case FindRootModel_Instance: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
414 if (manufacturer_ == ModalityManufacturer_ClearCanvas || |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
415 manufacturer_ == ModalityManufacturer_Dcm4Chee) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
416 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
417 // This is a particular case for ClearCanvas, thanks to Peter Somlo <peter.somlo@gmail.com>. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
418 // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
419 // http://www.clearcanvas.ca/Home/Community/OldForums/tabid/526/aff/11/aft/14670/afv/topic/Default.aspx |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
420 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "IMAGE"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
421 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
422 else |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
423 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
424 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
425 } |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
426 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
427 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
0 | 428 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
429 // Accession number |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
430 if (!fields.HasTag(0x0008, 0x0050)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
431 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), ""); |
0 | 432 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
433 // Study instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
434 if (!fields.HasTag(0x0020, 0x000d)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
435 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), ""); |
0 | 436 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
437 // Series instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
438 if (!fields.HasTag(0x0020, 0x000e)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
439 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000e), ""); |
0 | 440 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
441 // SOP Instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
442 if (!fields.HasTag(0x0008, 0x0018)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
443 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0018), ""); |
0 | 444 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
445 break; |
0 | 446 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
447 default: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
448 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 449 } |
450 | |
451 // Figure out which of the accepted presentation contexts should be used | |
452 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); | |
453 if (presID == 0) | |
454 { | |
62 | 455 throw OrthancException("DicomUserConnection: The C-FIND command is not supported by the distant AET"); |
0 | 456 } |
457 | |
458 T_DIMSE_C_FindRQ request; | |
459 memset(&request, 0, sizeof(request)); | |
460 request.MessageID = pimpl_->assoc_->nextMsgID++; | |
461 strcpy(request.AffectedSOPClassUID, sopClass); | |
462 request.DataSetType = DIMSE_DATASET_PRESENT; | |
463 request.Priority = DIMSE_PRIORITY_MEDIUM; | |
464 | |
465 T_DIMSE_C_FindRSP response; | |
466 DcmDataset* statusDetail = NULL; | |
467 OFCondition cond = DIMSE_findUser(pimpl_->assoc_, presID, &request, dataset.get(), | |
468 FindCallback, &result, | |
469 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0, | |
470 &response, &statusDetail); | |
471 | |
472 if (statusDetail) | |
473 { | |
474 delete statusDetail; | |
475 } | |
476 | |
477 Check(cond); | |
478 } | |
479 | |
480 | |
481 void DicomUserConnection::FindPatient(DicomFindAnswers& result, | |
482 const DicomMap& fields) | |
483 { | |
484 // Only keep the filters from "fields" that are related to the patient | |
485 DicomMap s; | |
486 fields.ExtractPatientInformation(s); | |
487 Find(result, FindRootModel_Patient, s); | |
488 } | |
489 | |
490 void DicomUserConnection::FindStudy(DicomFindAnswers& result, | |
491 const DicomMap& fields) | |
492 { | |
493 // Only keep the filters from "fields" that are related to the study | |
494 DicomMap s; | |
495 fields.ExtractStudyInformation(s); | |
496 | |
80 | 497 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); |
498 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
725 | 499 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY); |
0 | 500 |
501 Find(result, FindRootModel_Study, s); | |
502 } | |
503 | |
504 void DicomUserConnection::FindSeries(DicomFindAnswers& result, | |
505 const DicomMap& fields) | |
506 { | |
507 // Only keep the filters from "fields" that are related to the series | |
508 DicomMap s; | |
509 fields.ExtractSeriesInformation(s); | |
510 | |
80 | 511 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); |
512 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
513 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
0 | 514 |
515 Find(result, FindRootModel_Series, s); | |
516 } | |
517 | |
518 void DicomUserConnection::FindInstance(DicomFindAnswers& result, | |
519 const DicomMap& fields) | |
520 { | |
521 // Only keep the filters from "fields" that are related to the instance | |
522 DicomMap s; | |
523 fields.ExtractInstanceInformation(s); | |
524 | |
80 | 525 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); |
526 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
527 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
528 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID); | |
0 | 529 |
530 Find(result, FindRootModel_Instance, s); | |
531 } | |
532 | |
533 | |
534 void DicomUserConnection::Move(const std::string& targetAet, | |
535 const DicomMap& fields) | |
536 { | |
537 CheckIsOpen(); | |
538 | |
539 const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel; | |
540 std::auto_ptr<DcmDataset> dataset(ToDcmtkBridge::Convert(fields)); | |
541 | |
542 // Figure out which of the accepted presentation contexts should be used | |
543 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); | |
544 if (presID == 0) | |
545 { | |
62 | 546 throw OrthancException("DicomUserConnection: The C-MOVE command is not supported by the distant AET"); |
0 | 547 } |
548 | |
549 T_DIMSE_C_MoveRQ request; | |
550 memset(&request, 0, sizeof(request)); | |
551 request.MessageID = pimpl_->assoc_->nextMsgID++; | |
552 strcpy(request.AffectedSOPClassUID, sopClass); | |
553 request.DataSetType = DIMSE_DATASET_PRESENT; | |
554 request.Priority = DIMSE_PRIORITY_MEDIUM; | |
555 strncpy(request.MoveDestination, targetAet.c_str(), sizeof(DIC_AE) / sizeof(char)); | |
556 | |
557 T_DIMSE_C_MoveRSP response; | |
558 DcmDataset* statusDetail = NULL; | |
559 DcmDataset* responseIdentifiers = NULL; | |
560 OFCondition cond = DIMSE_moveUser(pimpl_->assoc_, presID, &request, dataset.get(), | |
561 NULL, NULL, | |
562 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0, | |
563 pimpl_->net_, NULL, NULL, | |
564 &response, &statusDetail, &responseIdentifiers); | |
565 | |
566 if (statusDetail) | |
567 { | |
568 delete statusDetail; | |
569 } | |
570 | |
571 if (responseIdentifiers) | |
572 { | |
573 delete responseIdentifiers; | |
574 } | |
575 | |
576 Check(cond); | |
577 } | |
578 | |
579 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
580 void DicomUserConnection::ResetStorageSOPClasses() |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
581 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
582 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
583 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
584 storageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
585 defaultStorageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
586 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
587 // Copy the short list of storage SOP classes from DCMTK, making |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
588 // room for the 4 SOP classes reserved for C-ECHO, C-FIND, C-MOVE. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
589 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
590 std::set<std::string> uncommon; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
591 uncommon.insert(UID_BlendingSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
592 uncommon.insert(UID_GrayscaleSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
593 uncommon.insert(UID_ColorSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
594 uncommon.insert(UID_PseudoColorSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
595 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
596 // Add the storage syntaxes for C-STORE |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
597 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs - 1; i++) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
598 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
599 if (uncommon.find(dcmShortSCUStorageSOPClassUIDs[i]) == uncommon.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
600 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
601 defaultStorageSOPClasses_.insert(dcmShortSCUStorageSOPClassUIDs[i]); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
602 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
603 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
604 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
605 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
606 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
607 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
608 |
656 | 609 DicomUserConnection::DicomUserConnection() : |
610 pimpl_(new PImpl), | |
666
b8383ac0b227
fix cppcheck warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
662
diff
changeset
|
611 preferredTransferSyntax_(DEFAULT_PREFERRED_TRANSFER_SYNTAX), |
656 | 612 localAet_("STORESCU"), |
613 distantAet_("ANY-SCP"), | |
614 distantHost_("127.0.0.1") | |
0 | 615 { |
616 distantPort_ = 104; | |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
617 manufacturer_ = ModalityManufacturer_Generic; |
0 | 618 |
619 pimpl_->net_ = NULL; | |
620 pimpl_->params_ = NULL; | |
621 pimpl_->assoc_ = NULL; | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
622 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
623 // SOP classes for C-ECHO, C-FIND and C-MOVE |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
624 reservedStorageSOPClasses_.push_back(UID_VerificationSOPClass); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
625 reservedStorageSOPClasses_.push_back(UID_FINDPatientRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
626 reservedStorageSOPClasses_.push_back(UID_FINDStudyRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
627 reservedStorageSOPClasses_.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
628 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
629 ResetStorageSOPClasses(); |
0 | 630 } |
631 | |
632 DicomUserConnection::~DicomUserConnection() | |
633 { | |
634 Close(); | |
635 } | |
636 | |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
637 |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
638 void DicomUserConnection::Connect(const RemoteModalityParameters& parameters) |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
639 { |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
640 SetDistantApplicationEntityTitle(parameters.GetApplicationEntityTitle()); |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
641 SetDistantHost(parameters.GetHost()); |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
642 SetDistantPort(parameters.GetPort()); |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
643 SetDistantManufacturer(parameters.GetManufacturer()); |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
644 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
645 |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
646 |
0 | 647 void DicomUserConnection::SetLocalApplicationEntityTitle(const std::string& aet) |
648 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
649 if (localAet_ != aet) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
650 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
651 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
652 localAet_ = aet; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
653 } |
0 | 654 } |
655 | |
656 void DicomUserConnection::SetDistantApplicationEntityTitle(const std::string& aet) | |
657 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
658 if (distantAet_ != aet) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
659 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
660 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
661 distantAet_ = aet; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
662 } |
0 | 663 } |
664 | |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
665 void DicomUserConnection::SetDistantManufacturer(ModalityManufacturer manufacturer) |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
666 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
667 if (manufacturer_ != manufacturer) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
668 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
669 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
670 manufacturer_ = manufacturer; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
671 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
672 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
673 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
674 void DicomUserConnection::ResetPreferredTransferSyntax() |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
675 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
676 SetPreferredTransferSyntax(DEFAULT_PREFERRED_TRANSFER_SYNTAX); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
677 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
678 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
679 void DicomUserConnection::SetPreferredTransferSyntax(const std::string& preferredTransferSyntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
680 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
681 if (preferredTransferSyntax_ != preferredTransferSyntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
682 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
683 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
684 preferredTransferSyntax_ = preferredTransferSyntax; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
685 } |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
686 } |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
687 |
0 | 688 |
689 void DicomUserConnection::SetDistantHost(const std::string& host) | |
690 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
691 if (distantHost_ != host) |
0 | 692 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
693 if (host.size() > HOST_NAME_MAX - 10) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
694 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
695 throw OrthancException("Distant host name is too long"); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
696 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
697 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
698 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
699 distantHost_ = host; |
0 | 700 } |
701 } | |
702 | |
703 void DicomUserConnection::SetDistantPort(uint16_t port) | |
704 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
705 if (distantPort_ != port) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
706 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
707 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
708 distantPort_ = port; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
709 } |
0 | 710 } |
711 | |
712 void DicomUserConnection::Open() | |
713 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
714 if (IsOpen()) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
715 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
716 // Don't reopen the connection |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
717 return; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
718 } |
0 | 719 |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
720 LOG(INFO) << "Opening a DICOM SCU connection from AET \"" << GetLocalApplicationEntityTitle() |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
721 << "\" to AET \"" << GetDistantApplicationEntityTitle() << "\" on host " |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
722 << GetDistantHost() << ":" << GetDistantPort() |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
723 << " (manufacturer: " << EnumerationToString(GetDistantManufacturer()) << ")"; |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
724 |
0 | 725 Check(ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ 30, &pimpl_->net_)); |
726 Check(ASC_createAssociationParameters(&pimpl_->params_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); | |
727 | |
728 // Set this application's title and the called application's title in the params | |
729 Check(ASC_setAPTitles(pimpl_->params_, localAet_.c_str(), distantAet_.c_str(), NULL)); | |
730 | |
731 // Set the network addresses of the local and distant entities | |
732 char localHost[HOST_NAME_MAX]; | |
733 gethostname(localHost, HOST_NAME_MAX - 1); | |
734 | |
735 char distantHostAndPort[HOST_NAME_MAX]; | |
2 | 736 |
737 #ifdef _MSC_VER | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
738 _snprintf |
2 | 739 #else |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
740 snprintf |
2 | 741 #endif |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
742 (distantHostAndPort, HOST_NAME_MAX - 1, "%s:%d", distantHost_.c_str(), distantPort_); |
0 | 743 |
744 Check(ASC_setPresentationAddresses(pimpl_->params_, localHost, distantHostAndPort)); | |
745 | |
746 // Set various options | |
747 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false)); | |
748 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
749 SetupPresentationContexts(preferredTransferSyntax_); |
0 | 750 |
751 // Do the association | |
752 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_)); | |
753 | |
754 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0) | |
755 { | |
62 | 756 throw OrthancException("DicomUserConnection: No Acceptable Presentation Contexts"); |
0 | 757 } |
758 } | |
759 | |
760 void DicomUserConnection::Close() | |
761 { | |
762 if (pimpl_->assoc_ != NULL) | |
763 { | |
764 ASC_releaseAssociation(pimpl_->assoc_); | |
765 ASC_destroyAssociation(&pimpl_->assoc_); | |
766 pimpl_->assoc_ = NULL; | |
767 pimpl_->params_ = NULL; | |
768 } | |
769 else | |
770 { | |
771 if (pimpl_->params_ != NULL) | |
772 { | |
773 ASC_destroyAssociationParameters(&pimpl_->params_); | |
774 pimpl_->params_ = NULL; | |
775 } | |
776 } | |
777 | |
778 if (pimpl_->net_ != NULL) | |
779 { | |
780 ASC_dropNetwork(&pimpl_->net_); | |
781 pimpl_->net_ = NULL; | |
782 } | |
783 } | |
784 | |
785 bool DicomUserConnection::IsOpen() const | |
786 { | |
787 return pimpl_->IsOpen(); | |
788 } | |
789 | |
790 void DicomUserConnection::Store(const char* buffer, size_t size) | |
791 { | |
792 // Prepare an input stream for the memory buffer | |
793 DcmInputBufferStream is; | |
794 if (size > 0) | |
795 is.setBuffer(buffer, size); | |
796 is.setEos(); | |
797 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
798 pimpl_->Store(is, *this); |
0 | 799 } |
800 | |
801 void DicomUserConnection::Store(const std::string& buffer) | |
802 { | |
803 if (buffer.size() > 0) | |
804 Store(reinterpret_cast<const char*>(&buffer[0]), buffer.size()); | |
805 else | |
806 Store(NULL, 0); | |
807 } | |
808 | |
809 void DicomUserConnection::StoreFile(const std::string& path) | |
810 { | |
811 // Prepare an input stream for the file | |
812 DcmInputFileStream is(path.c_str()); | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
813 pimpl_->Store(is, *this); |
0 | 814 } |
815 | |
816 bool DicomUserConnection::Echo() | |
817 { | |
818 CheckIsOpen(); | |
819 DIC_US status; | |
820 Check(DIMSE_echoUser(pimpl_->assoc_, pimpl_->assoc_->nextMsgID++, | |
821 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ 0, | |
822 &status, NULL)); | |
823 return status == STATUS_Success; | |
824 } | |
825 | |
826 | |
827 void DicomUserConnection::MoveSeries(const std::string& targetAet, | |
828 const DicomMap& findResult) | |
829 { | |
830 DicomMap simplified; | |
80 | 831 simplified.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, findResult.GetValue(DICOM_TAG_STUDY_INSTANCE_UID)); |
832 simplified.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SERIES_INSTANCE_UID)); | |
0 | 833 Move(targetAet, simplified); |
834 } | |
835 | |
836 void DicomUserConnection::MoveSeries(const std::string& targetAet, | |
837 const std::string& studyUid, | |
838 const std::string& seriesUid) | |
839 { | |
840 DicomMap map; | |
80 | 841 map.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid); |
842 map.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid); | |
0 | 843 Move(targetAet, map); |
844 } | |
845 | |
846 void DicomUserConnection::MoveInstance(const std::string& targetAet, | |
847 const DicomMap& findResult) | |
848 { | |
849 DicomMap simplified; | |
80 | 850 simplified.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, findResult.GetValue(DICOM_TAG_STUDY_INSTANCE_UID)); |
851 simplified.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SERIES_INSTANCE_UID)); | |
852 simplified.SetValue(DICOM_TAG_SOP_INSTANCE_UID, findResult.GetValue(DICOM_TAG_SOP_INSTANCE_UID)); | |
0 | 853 Move(targetAet, simplified); |
854 } | |
855 | |
856 void DicomUserConnection::MoveInstance(const std::string& targetAet, | |
857 const std::string& studyUid, | |
858 const std::string& seriesUid, | |
859 const std::string& instanceUid) | |
860 { | |
861 DicomMap map; | |
80 | 862 map.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid); |
863 map.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid); | |
864 map.SetValue(DICOM_TAG_SOP_INSTANCE_UID, instanceUid); | |
0 | 865 Move(targetAet, map); |
866 } | |
867 | |
868 void DicomUserConnection::SetConnectionTimeout(uint32_t seconds) | |
869 { | |
870 dcmConnectionTimeout.set(seconds); | |
871 } | |
872 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
873 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
874 void DicomUserConnection::CheckStorageSOPClassesInvariant() const |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
875 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
876 assert(storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
877 defaultStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
878 reservedStorageSOPClasses_.size() <= MAXIMUM_STORAGE_SOP_CLASSES); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
879 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
880 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
881 void DicomUserConnection::AddStorageSOPClass(const char* sop) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
882 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
883 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
884 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
885 if (storageSOPClasses_.find(sop) != storageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
886 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
887 // This storage SOP class is already explicitly registered. Do |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
888 // nothing. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
889 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
890 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
891 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
892 if (defaultStorageSOPClasses_.find(sop) != defaultStorageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
893 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
894 // This storage SOP class is not explicitly registered, but is |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
895 // used by default. Just register it explicitly. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
896 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
897 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
898 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
899 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
900 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
901 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
902 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
903 // This storage SOP class is neither explicitly, nor implicitly |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
904 // registered. Close the connection and register it explicitly. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
905 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
906 Close(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
907 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
908 if (reservedStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
909 storageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) // (*) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
910 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
911 // The maximum number of SOP classes is reached |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
912 ResetStorageSOPClasses(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
913 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
914 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
915 else if (reservedStorageSOPClasses_.size() + storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
916 defaultStorageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
917 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
918 // Make room in the default storage syntaxes |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
919 assert(defaultStorageSOPClasses_.size() > 0); // Necessarily true because condition (*) is false |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
920 defaultStorageSOPClasses_.erase(*defaultStorageSOPClasses_.rbegin()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
921 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
922 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
923 // Explicitly register the new storage syntax |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
924 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
925 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
926 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
927 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
928 |
0 | 929 } |