# HG changeset patch # User Sebastien Jodogne # Date 1399322674 -7200 # Node ID 381f90e2b69d4645195d18acfb106372951aaa57 # Parent 331eaf9d9d69626c38ea3ed7cdbe15d7dc10d5d6 refactoring diff -r 331eaf9d9d69 -r 381f90e2b69d NEWS --- a/NEWS Mon May 05 18:55:10 2014 +0200 +++ b/NEWS Mon May 05 22:44:34 2014 +0200 @@ -4,7 +4,7 @@ * Dynamic negotiation of SOP classes for C-Store SCU * Reuse of the previous SCU connection to avoid unecessary handshakes * Fix missing licensing terms about reuse of some DCMTK code -* Refactorings +* Various code refactorings Version 0.7.4 (2014/04/16) diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/FromDcmtkBridge.h --- a/OrthancServer/FromDcmtkBridge.h Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/FromDcmtkBridge.h Mon May 05 22:44:34 2014 +0200 @@ -32,13 +32,11 @@ #pragma once -#include "../Core/DicomFormat/DicomInstanceHasher.h" -#include "../Core/RestApi/RestApiOutput.h" -#include "../Core/Toolbox.h" #include "ServerEnumerations.h" +#include "../Core/DicomFormat/DicomMap.h" + #include -#include #include #include diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon May 05 22:44:34 2014 +0200 @@ -256,7 +256,7 @@ modification.Apply(*modified); std::string modifiedInstance; - if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success) + if (context.Store(modifiedInstance, *modified) != StoreStatus_Success) { LOG(ERROR) << "Error while storing a modified instance " << *it; return; diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/ParsedDicomFile.cpp --- a/OrthancServer/ParsedDicomFile.cpp Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.cpp Mon May 05 22:44:34 2014 +0200 @@ -1035,4 +1035,22 @@ Replace(DICOM_TAG_SOP_INSTANCE_UID, FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Instance)); } + + ParsedDicomFile::ParsedDicomFile(const char* content, + size_t size) + { + Setup(content, size); + } + + ParsedDicomFile::ParsedDicomFile(const std::string& content) + { + if (content.size() == 0) + { + Setup(NULL, 0); + } + else + { + Setup(&content[0], content.size()); + } + } } diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/ParsedDicomFile.h --- a/OrthancServer/ParsedDicomFile.h Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.h Mon May 05 22:44:34 2014 +0200 @@ -60,18 +60,9 @@ ParsedDicomFile(); // Create a minimal DICOM instance ParsedDicomFile(const char* content, - size_t size) - { - Setup(content, size); - } + size_t size); - ParsedDicomFile(const std::string& content) - { - if (content.size() == 0) - Setup(NULL, 0); - else - Setup(&content[0], content.size()); - } + ParsedDicomFile(const std::string& content); DcmFileFormat& GetDicom() { diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/ServerContext.cpp Mon May 05 22:44:34 2014 +0200 @@ -247,12 +247,12 @@ StoreStatus ServerContext::Store(std::string& resultPublicId, - DcmFileFormat& dicomInstance, + ParsedDicomFile& dicomInstance, const char* dicomBuffer, size_t dicomSize) { DicomMap dicomSummary; - FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.getDataset()); + FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.GetDicom().getDataset()); try { @@ -260,7 +260,7 @@ resultPublicId = hasher.HashInstance(); Json::Value dicomJson; - FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset()); + FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.GetDicom().getDataset()); StoreStatus status = StoreStatus_Failure; if (dicomSize > 0) @@ -283,10 +283,10 @@ StoreStatus ServerContext::Store(std::string& resultPublicId, - DcmFileFormat& dicomInstance) + ParsedDicomFile& dicomInstance) { std::string buffer; - if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.getDataset())) + if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.GetDicom().getDataset())) { throw OrthancException(ErrorCode_InternalError); } @@ -303,9 +303,24 @@ size_t dicomSize) { ParsedDicomFile dicom(dicomBuffer, dicomSize); - return Store(resultPublicId, dicom.GetDicom(), dicomBuffer, dicomSize); + return Store(resultPublicId, dicom, dicomBuffer, dicomSize); } + + StoreStatus ServerContext::Store(std::string& resultPublicId, + const std::string& dicomContent) + { + if (dicomContent.size() == 0) + { + return Store(resultPublicId, NULL, 0); + } + else + { + return Store(resultPublicId, &dicomContent[0], dicomContent.size()); + } + } + + void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) { LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no"); diff -r 331eaf9d9d69 -r 381f90e2b69d OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Mon May 05 18:55:10 2014 +0200 +++ b/OrthancServer/ServerContext.h Mon May 05 22:44:34 2014 +0200 @@ -125,25 +125,19 @@ const std::string& remoteAet); StoreStatus Store(std::string& resultPublicId, - DcmFileFormat& dicomInstance, + ParsedDicomFile& dicomInstance, const char* dicomBuffer, size_t dicomSize); StoreStatus Store(std::string& resultPublicId, - DcmFileFormat& dicomInstance); + ParsedDicomFile& dicomInstance); StoreStatus Store(std::string& resultPublicId, const char* dicomBuffer, size_t dicomSize); StoreStatus Store(std::string& resultPublicId, - const std::string& dicomContent) - { - if (dicomContent.size() == 0) - return Store(resultPublicId, NULL, 0); - else - return Store(resultPublicId, &dicomContent[0], dicomContent.size()); - } + const std::string& dicomContent); void AnswerDicomFile(RestApiOutput& output, const std::string& instancePublicId,