Mercurial > hg > orthanc
comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 2381:b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Aug 2017 19:59:01 +0200 |
parents | 96b3ec054b69 |
children |
comparison
equal
deleted
inserted
replaced
2380:96b3ec054b69 | 2381:b8969010b534 |
---|---|
37 #include "../../Core/Logging.h" | 37 #include "../../Core/Logging.h" |
38 #include "../../Core/MultiThreading/RunnableWorkersPool.h" | 38 #include "../../Core/MultiThreading/RunnableWorkersPool.h" |
39 #include "../../Core/OrthancException.h" | 39 #include "../../Core/OrthancException.h" |
40 #include "../../Core/Toolbox.h" | 40 #include "../../Core/Toolbox.h" |
41 #include "../Internals/CommandDispatcher.h" | 41 #include "../Internals/CommandDispatcher.h" |
42 #include "../OrthancInitialization.h" | |
43 | 42 |
44 #include <boost/thread.hpp> | 43 #include <boost/thread.hpp> |
45 | 44 |
46 #if defined(__linux__) | 45 #if defined(__linux__) |
47 #include <cstdlib> | 46 #include <cstdlib> |
88 DicomServer::DicomServer() : | 87 DicomServer::DicomServer() : |
89 pimpl_(new PImpl), | 88 pimpl_(new PImpl), |
90 aet_("ANY-SCP") | 89 aet_("ANY-SCP") |
91 { | 90 { |
92 port_ = 104; | 91 port_ = 104; |
92 modalities_ = NULL; | |
93 findRequestHandlerFactory_ = NULL; | 93 findRequestHandlerFactory_ = NULL; |
94 moveRequestHandlerFactory_ = NULL; | 94 moveRequestHandlerFactory_ = NULL; |
95 storeRequestHandlerFactory_ = NULL; | 95 storeRequestHandlerFactory_ = NULL; |
96 worklistRequestHandlerFactory_ = NULL; | 96 worklistRequestHandlerFactory_ = NULL; |
97 applicationEntityFilter_ = NULL; | 97 applicationEntityFilter_ = NULL; |
177 const std::string& DicomServer::GetApplicationEntityTitle() const | 177 const std::string& DicomServer::GetApplicationEntityTitle() const |
178 { | 178 { |
179 return aet_; | 179 return aet_; |
180 } | 180 } |
181 | 181 |
182 void DicomServer::SetRemoteModalities(IRemoteModalities& modalities) | |
183 { | |
184 Stop(); | |
185 modalities_ = &modalities; | |
186 } | |
187 | |
188 DicomServer::IRemoteModalities& DicomServer::GetRemoteModalities() const | |
189 { | |
190 if (modalities_ == NULL) | |
191 { | |
192 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
193 } | |
194 else | |
195 { | |
196 return *modalities_; | |
197 } | |
198 } | |
199 | |
182 void DicomServer::SetFindRequestHandlerFactory(IFindRequestHandlerFactory& factory) | 200 void DicomServer::SetFindRequestHandlerFactory(IFindRequestHandlerFactory& factory) |
183 { | 201 { |
184 Stop(); | 202 Stop(); |
185 findRequestHandlerFactory_ = &factory; | 203 findRequestHandlerFactory_ = &factory; |
186 } | 204 } |
294 } | 312 } |
295 } | 313 } |
296 | 314 |
297 void DicomServer::Start() | 315 void DicomServer::Start() |
298 { | 316 { |
317 if (modalities_ == NULL) | |
318 { | |
319 LOG(ERROR) << "No list of modalities was provided to the DICOM server"; | |
320 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
321 } | |
322 | |
299 Stop(); | 323 Stop(); |
300 | 324 |
301 /* initialize network, i.e. create an instance of T_ASC_Network*. */ | 325 /* initialize network, i.e. create an instance of T_ASC_Network*. */ |
302 OFCondition cond = ASC_initializeNetwork | 326 OFCondition cond = ASC_initializeNetwork |
303 (NET_ACCEPTOR, OFstatic_cast(int, port_), /*opt_acse_timeout*/ 30, &pimpl_->network_); | 327 (NET_ACCEPTOR, OFstatic_cast(int, port_), /*opt_acse_timeout*/ 30, &pimpl_->network_); |
337 } | 361 } |
338 | 362 |
339 | 363 |
340 bool DicomServer::IsMyAETitle(const std::string& aet) const | 364 bool DicomServer::IsMyAETitle(const std::string& aet) const |
341 { | 365 { |
366 if (modalities_ == NULL) | |
367 { | |
368 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
369 } | |
370 | |
342 if (!HasCalledApplicationEntityTitleCheck()) | 371 if (!HasCalledApplicationEntityTitleCheck()) |
343 { | 372 { |
344 // OK, no check on the AET. | 373 // OK, no check on the AET. |
345 return true; | 374 return true; |
346 } | 375 } |
347 | 376 else |
348 return Configuration::IsSameAETitle(aet, GetApplicationEntityTitle()); | 377 { |
378 return modalities_->IsSameAETitle(aet, GetApplicationEntityTitle()); | |
379 } | |
349 } | 380 } |
350 | 381 |
351 } | 382 } |