comparison PalanthirServer/DicomProtocol/DicomUserConnection.cpp @ 50:a15e90e5d6fc

rename in code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Sep 2012 15:50:12 +0200
parents 33d67e1ab173
children
comparison
equal deleted inserted replaced
49:e1a3ae0dadf3 50:a15e90e5d6fc
1 /** 1 /**
2 * Palantir - A Lightweight, RESTful DICOM Store 2 * Palanthir - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium 4 * Belgium
5 * 5 *
6 * This program is free software: you can redistribute it and/or 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 7 * modify it under the terms of the GNU General Public License as
18 **/ 18 **/
19 19
20 20
21 #include "DicomUserConnection.h" 21 #include "DicomUserConnection.h"
22 22
23 #include "../../Core/PalantirException.h" 23 #include "../../Core/PalanthirException.h"
24 #include "../ToDcmtkBridge.h" 24 #include "../ToDcmtkBridge.h"
25 #include "../FromDcmtkBridge.h" 25 #include "../FromDcmtkBridge.h"
26 26
27 #include <dcmtk/dcmnet/assoc.h> 27 #include <dcmtk/dcmnet/assoc.h>
28 #include <dcmtk/dcmnet/dimse.h> 28 #include <dcmtk/dcmnet/dimse.h>
44 **/ 44 **/
45 #define HOST_NAME_MAX 256 45 #define HOST_NAME_MAX 256
46 #endif 46 #endif
47 47
48 48
49 namespace Palantir 49 namespace Palanthir
50 { 50 {
51 struct DicomUserConnection::PImpl 51 struct DicomUserConnection::PImpl
52 { 52 {
53 // Connection state 53 // Connection state
54 T_ASC_Network* net_; 54 T_ASC_Network* net_;
68 68
69 static void Check(const OFCondition& cond) 69 static void Check(const OFCondition& cond)
70 { 70 {
71 if (cond.bad()) 71 if (cond.bad())
72 { 72 {
73 throw PalantirException("DicomUserConnection: " + std::string(cond.text())); 73 throw PalanthirException("DicomUserConnection: " + std::string(cond.text()));
74 } 74 }
75 } 75 }
76 76
77 void DicomUserConnection::PImpl::CheckIsOpen() const 77 void DicomUserConnection::PImpl::CheckIsOpen() const
78 { 78 {
79 if (!IsOpen()) 79 if (!IsOpen())
80 { 80 {
81 throw PalantirException("DicomUserConnection: First open the connection"); 81 throw PalanthirException("DicomUserConnection: First open the connection");
82 } 82 }
83 } 83 }
84 84
85 85
86 void DicomUserConnection::CheckIsOpen() const 86 void DicomUserConnection::CheckIsOpen() const
168 // Figure out which SOP class and SOP instance is encapsulated in the file 168 // Figure out which SOP class and SOP instance is encapsulated in the file
169 DIC_UI sopClass; 169 DIC_UI sopClass;
170 DIC_UI sopInstance; 170 DIC_UI sopInstance;
171 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance)) 171 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance))
172 { 172 {
173 throw PalantirException("DicomUserConnection: Unable to find the SOP class and instance"); 173 throw PalanthirException("DicomUserConnection: Unable to find the SOP class and instance");
174 } 174 }
175 175
176 // Figure out which of the accepted presentation contexts should be used 176 // Figure out which of the accepted presentation contexts should be used
177 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass); 177 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass);
178 if (presID == 0) 178 if (presID == 0)
179 { 179 {
180 const char *modalityName = dcmSOPClassUIDToModality(sopClass); 180 const char *modalityName = dcmSOPClassUIDToModality(sopClass);
181 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass); 181 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass);
182 if (!modalityName) modalityName = "unknown SOP class"; 182 if (!modalityName) modalityName = "unknown SOP class";
183 throw PalantirException("DicomUserConnection: No presentation context for modality " + 183 throw PalanthirException("DicomUserConnection: No presentation context for modality " +
184 std::string(modalityName)); 184 std::string(modalityName));
185 } 185 }
186 186
187 // Prepare the transmission of data 187 // Prepare the transmission of data
188 T_DIMSE_C_StoreRQ req; 188 T_DIMSE_C_StoreRQ req;
304 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0018), ""); 304 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0018), "");
305 305
306 break; 306 break;
307 307
308 default: 308 default:
309 throw PalantirException(ErrorCode_ParameterOutOfRange); 309 throw PalanthirException(ErrorCode_ParameterOutOfRange);
310 } 310 }
311 311
312 // Figure out which of the accepted presentation contexts should be used 312 // Figure out which of the accepted presentation contexts should be used
313 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); 313 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
314 if (presID == 0) 314 if (presID == 0)
315 { 315 {
316 throw PalantirException("DicomUserConnection: The C-FIND command is not supported by the distant AET"); 316 throw PalanthirException("DicomUserConnection: The C-FIND command is not supported by the distant AET");
317 } 317 }
318 318
319 T_DIMSE_C_FindRQ request; 319 T_DIMSE_C_FindRQ request;
320 memset(&request, 0, sizeof(request)); 320 memset(&request, 0, sizeof(request));
321 request.MessageID = pimpl_->assoc_->nextMsgID++; 321 request.MessageID = pimpl_->assoc_->nextMsgID++;
401 401
402 // Figure out which of the accepted presentation contexts should be used 402 // Figure out which of the accepted presentation contexts should be used
403 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); 403 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
404 if (presID == 0) 404 if (presID == 0)
405 { 405 {
406 throw PalantirException("DicomUserConnection: The C-MOVE command is not supported by the distant AET"); 406 throw PalanthirException("DicomUserConnection: The C-MOVE command is not supported by the distant AET");
407 } 407 }
408 408
409 T_DIMSE_C_MoveRQ request; 409 T_DIMSE_C_MoveRQ request;
410 memset(&request, 0, sizeof(request)); 410 memset(&request, 0, sizeof(request));
411 request.MessageID = pimpl_->assoc_->nextMsgID++; 411 request.MessageID = pimpl_->assoc_->nextMsgID++;
469 469
470 void DicomUserConnection::SetDistantHost(const std::string& host) 470 void DicomUserConnection::SetDistantHost(const std::string& host)
471 { 471 {
472 if (host.size() > HOST_NAME_MAX - 10) 472 if (host.size() > HOST_NAME_MAX - 10)
473 { 473 {
474 throw PalantirException("Distant host name is too long"); 474 throw PalanthirException("Distant host name is too long");
475 } 475 }
476 476
477 Close(); 477 Close();
478 distantHost_ = host; 478 distantHost_ = host;
479 } 479 }
517 // Do the association 517 // Do the association
518 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_)); 518 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_));
519 519
520 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0) 520 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0)
521 { 521 {
522 throw PalantirException("DicomUserConnection: No Acceptable Presentation Contexts"); 522 throw PalanthirException("DicomUserConnection: No Acceptable Presentation Contexts");
523 } 523 }
524 } 524 }
525 525
526 void DicomUserConnection::Close() 526 void DicomUserConnection::Close()
527 { 527 {