Mercurial > hg > orthanc
changeset 792:111a1738e11e
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 May 2014 09:57:39 +0200 |
parents | 381f90e2b69d |
children | 145604a97914 |
files | OrthancServer/ParsedDicomFile.cpp OrthancServer/ParsedDicomFile.h OrthancServer/ServerContext.cpp |
diffstat | 3 files changed, 28 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/ParsedDicomFile.cpp Mon May 05 22:44:34 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.cpp Tue May 06 09:57:39 2014 +0200 @@ -1053,4 +1053,16 @@ Setup(&content[0], content.size()); } } + + + ParsedDicomFile::ParsedDicomFile(DcmFileFormat& other) : + file_(dynamic_cast<DcmFileFormat*>(other.clone())) + { + } + + + ParsedDicomFile::~ParsedDicomFile() + { + } + }
--- a/OrthancServer/ParsedDicomFile.h Mon May 05 22:44:34 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.h Tue May 06 09:57:39 2014 +0200 @@ -47,11 +47,10 @@ private: // TODO Move this as pimpl std::auto_ptr<DcmFileFormat> file_; + //struct PImpl; + //PImpl* pimpl_; - ParsedDicomFile(DcmFileFormat& other) : - file_(dynamic_cast<DcmFileFormat*>(other.clone())) - { - } + ParsedDicomFile(DcmFileFormat& other); void Setup(const char* content, size_t size); @@ -64,9 +63,11 @@ ParsedDicomFile(const std::string& content); - DcmFileFormat& GetDicom() + ~ParsedDicomFile(); + + void* GetDcmtkObject() { - return *file_; + return file_.get(); } ParsedDicomFile* Clone()
--- a/OrthancServer/ServerContext.cpp Mon May 05 22:44:34 2014 +0200 +++ b/OrthancServer/ServerContext.cpp Tue May 06 09:57:39 2014 +0200 @@ -246,13 +246,19 @@ } + static DcmFileFormat& GetDicom(ParsedDicomFile& file) + { + return *reinterpret_cast<DcmFileFormat*>(file.GetDcmtkObject()); + } + + StoreStatus ServerContext::Store(std::string& resultPublicId, ParsedDicomFile& dicomInstance, const char* dicomBuffer, size_t dicomSize) { DicomMap dicomSummary; - FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.GetDicom().getDataset()); + FromDcmtkBridge::Convert(dicomSummary, *GetDicom(dicomInstance).getDataset()); try { @@ -260,7 +266,7 @@ resultPublicId = hasher.HashInstance(); Json::Value dicomJson; - FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.GetDicom().getDataset()); + FromDcmtkBridge::ToJson(dicomJson, *GetDicom(dicomInstance).getDataset()); StoreStatus status = StoreStatus_Failure; if (dicomSize > 0) @@ -286,7 +292,7 @@ ParsedDicomFile& dicomInstance) { std::string buffer; - if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.GetDicom().getDataset())) + if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, GetDicom(dicomInstance).getDataset())) { throw OrthancException(ErrorCode_InternalError); }