# HG changeset patch # User Sebastien Jodogne # Date 1403689001 -7200 # Node ID b3f6fb1130cd60680e954fe055ce74214b18bf57 # Parent 83489fddd8c53200bbf6ae76b12d160798213b59 fixes thanks to cppcheck diff -r 83489fddd8c5 -r b3f6fb1130cd Core/MultiThreading/ReaderWriterLock.h --- a/Core/MultiThreading/ReaderWriterLock.h Wed Jun 25 11:08:11 2014 +0200 +++ b/Core/MultiThreading/ReaderWriterLock.h Wed Jun 25 11:36:41 2014 +0200 @@ -34,9 +34,11 @@ #include "ILockable.h" +#include + namespace Orthanc { - class ReaderWriterLock + class ReaderWriterLock : public boost::noncopyable { private: struct PImpl; diff -r 83489fddd8c5 -r b3f6fb1130cd Core/Toolbox.cpp --- a/Core/Toolbox.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/Core/Toolbox.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -513,7 +513,7 @@ { std::string result; - result.reserve(source.size()); + result.reserve(source.size() + 1); for (size_t i = 0; i < source.size(); i++) { if (source[i] < 128 && source[i] >= 0 && !iscntrl(source[i])) diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/DicomProtocol/DicomUserConnection.cpp --- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -217,21 +217,21 @@ unsigned int presentationContextId = 1; for (std::list::const_iterator it = reservedStorageSOPClasses_.begin(); - it != reservedStorageSOPClasses_.end(); it++) + it != reservedStorageSOPClasses_.end(); ++it) { RegisterStorageSOPClass(pimpl_->params_, presentationContextId, *it, asPreferred, asFallback); } for (std::set::const_iterator it = storageSOPClasses_.begin(); - it != storageSOPClasses_.end(); it++) + it != storageSOPClasses_.end(); ++it) { RegisterStorageSOPClass(pimpl_->params_, presentationContextId, *it, asPreferred, asFallback); } for (std::set::const_iterator it = defaultStorageSOPClasses_.begin(); - it != defaultStorageSOPClasses_.end(); it++) + it != defaultStorageSOPClasses_.end(); ++it) { RegisterStorageSOPClass(pimpl_->params_, presentationContextId, *it, asPreferred, asFallback); diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/DicomProtocol/RemoteModalityParameters.cpp --- a/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/DicomProtocol/RemoteModalityParameters.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -40,12 +40,12 @@ namespace Orthanc { - RemoteModalityParameters::RemoteModalityParameters() + RemoteModalityParameters::RemoteModalityParameters() : + aet_("ORTHANC"), + host_("localhost"), + port_(104), + manufacturer_(ModalityManufacturer_Generic) { - aet_ = "ORTHANC"; - host_ = "localhost"; - port_ = 104; - manufacturer_ = ModalityManufacturer_Generic; } void RemoteModalityParameters::SetPort(int port) diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/Internals/DicomImageDecoder.cpp --- a/OrthancServer/Internals/DicomImageDecoder.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/Internals/DicomImageDecoder.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -100,108 +100,19 @@ namespace Orthanc { - class DicomImageDecoder::ImageSource - { - private: - std::string psmct_; - std::auto_ptr slowAccessor_; - std::auto_ptr fastAccessor_; - - public: - void Setup(DcmDataset& dataset, - unsigned int frame) - { - psmct_.clear(); - slowAccessor_.reset(NULL); - fastAccessor_.reset(NULL); - - // See also: http://support.dcmtk.org/wiki/dcmtk/howto/accessing-compressed-data - - DicomMap m; - FromDcmtkBridge::Convert(m, dataset); - - /** - * Create an accessor to the raw values of the DICOM image. - **/ - - DcmElement* e; - if (dataset.findAndGetElement(ToDcmtkBridge::Convert(DICOM_TAG_PIXEL_DATA), e).good() && - e != NULL) - { - Uint8* pixData = NULL; - if (e->getUint8Array(pixData) == EC_Normal) - { - slowAccessor_.reset(new DicomIntegerPixelAccessor(m, pixData, e->getLength())); - } - } - else if (DicomImageDecoder::DecodePsmctRle1(psmct_, dataset)) - { - LOG(INFO) << "The PMSCT_RLE1 decoding has succeeded"; - Uint8* pixData = NULL; - if (psmct_.size() > 0) - { - pixData = reinterpret_cast(&psmct_[0]); - } - - slowAccessor_.reset(new DicomIntegerPixelAccessor(m, pixData, psmct_.size())); - } - - if (slowAccessor_.get() == NULL) - { - throw OrthancException(ErrorCode_BadFileFormat); - } - - slowAccessor_->SetCurrentFrame(frame); - - - /** - * If possible, create a fast ImageAccessor to the image buffer. - **/ - - - } - - unsigned int GetWidth() const - { - assert(slowAccessor_.get() != NULL); - return slowAccessor_->GetInformation().GetWidth(); - } - - unsigned int GetHeight() const - { - assert(slowAccessor_.get() != NULL); - return slowAccessor_->GetInformation().GetHeight(); - } - - unsigned int GetChannelCount() const - { - assert(slowAccessor_.get() != NULL); - return slowAccessor_->GetInformation().GetChannelCount(); - } - - const DicomIntegerPixelAccessor& GetAccessor() const - { - assert(slowAccessor_.get() != NULL); - return *slowAccessor_; - } - - bool HasFastAccessor() const - { - return fastAccessor_.get() != NULL; - } - - const ImageAccessor& GetFastAccessor() const - { - assert(HasFastAccessor()); - return *fastAccessor_; - } - }; - - static const DicomTag DICOM_TAG_CONTENT(0x07a1, 0x100a); static const DicomTag DICOM_TAG_COMPRESSION_TYPE(0x07a1, 0x1011); - bool DicomImageDecoder::IsPsmctRle1(DcmDataset& dataset) + + static bool IsJpegLossless(const DcmDataset& dataset) + { + // http://support.dcmtk.org/docs/dcxfer_8h-source.html + return (dataset.getOriginalXfer() == EXS_JPEGLSLossless || + dataset.getOriginalXfer() == EXS_JPEGLSLossy); + } + + + static bool IsPsmctRle1(DcmDataset& dataset) { DcmElement* e; char* c; @@ -224,8 +135,8 @@ } - bool DicomImageDecoder::DecodePsmctRle1(std::string& output, - DcmDataset& dataset) + static bool DecodePsmctRle1(std::string& output, + DcmDataset& dataset) { // Check whether the DICOM instance contains an image encoded with // the PMSCT_RLE1 scheme. @@ -309,6 +220,104 @@ } + class DicomImageDecoder::ImageSource + { + private: + std::string psmct_; + std::auto_ptr slowAccessor_; + std::auto_ptr fastAccessor_; + + public: + void Setup(DcmDataset& dataset, + unsigned int frame) + { + psmct_.clear(); + slowAccessor_.reset(NULL); + fastAccessor_.reset(NULL); + + // See also: http://support.dcmtk.org/wiki/dcmtk/howto/accessing-compressed-data + + DicomMap m; + FromDcmtkBridge::Convert(m, dataset); + + /** + * Create an accessor to the raw values of the DICOM image. + **/ + + DcmElement* e; + if (dataset.findAndGetElement(ToDcmtkBridge::Convert(DICOM_TAG_PIXEL_DATA), e).good() && + e != NULL) + { + Uint8* pixData = NULL; + if (e->getUint8Array(pixData) == EC_Normal) + { + slowAccessor_.reset(new DicomIntegerPixelAccessor(m, pixData, e->getLength())); + } + } + else if (DecodePsmctRle1(psmct_, dataset)) + { + LOG(INFO) << "The PMSCT_RLE1 decoding has succeeded"; + Uint8* pixData = NULL; + if (psmct_.size() > 0) + { + pixData = reinterpret_cast(&psmct_[0]); + } + + slowAccessor_.reset(new DicomIntegerPixelAccessor(m, pixData, psmct_.size())); + } + + if (slowAccessor_.get() == NULL) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + slowAccessor_->SetCurrentFrame(frame); + + + /** + * If possible, create a fast ImageAccessor to the image buffer. + **/ + + + } + + unsigned int GetWidth() const + { + assert(slowAccessor_.get() != NULL); + return slowAccessor_->GetInformation().GetWidth(); + } + + unsigned int GetHeight() const + { + assert(slowAccessor_.get() != NULL); + return slowAccessor_->GetInformation().GetHeight(); + } + + unsigned int GetChannelCount() const + { + assert(slowAccessor_.get() != NULL); + return slowAccessor_->GetInformation().GetChannelCount(); + } + + const DicomIntegerPixelAccessor& GetAccessor() const + { + assert(slowAccessor_.get() != NULL); + return *slowAccessor_; + } + + bool HasFastAccessor() const + { + return fastAccessor_.get() != NULL; + } + + const ImageAccessor& GetFastAccessor() const + { + assert(HasFastAccessor()); + return *fastAccessor_; + } + }; + + void DicomImageDecoder::SetupImageBuffer(ImageBuffer& target, DcmDataset& dataset) { @@ -333,14 +342,6 @@ } - bool DicomImageDecoder::IsJpegLossless(const DcmDataset& dataset) - { - // http://support.dcmtk.org/docs/dcxfer_8h-source.html - return (dataset.getOriginalXfer() == EXS_JPEGLSLossless || - dataset.getOriginalXfer() == EXS_JPEGLSLossy); - } - - bool DicomImageDecoder::IsUncompressedImage(const DcmDataset& dataset) { // http://support.dcmtk.org/docs/dcxfer_8h-source.html diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/Internals/DicomImageDecoder.h --- a/OrthancServer/Internals/DicomImageDecoder.h Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/Internals/DicomImageDecoder.h Wed Jun 25 11:36:41 2014 +0200 @@ -52,13 +52,8 @@ static void SetupImageBuffer(ImageBuffer& target, DcmDataset& dataset); - static bool DecodePsmctRle1(std::string& output, - DcmDataset& dataset); - static bool IsUncompressedImage(const DcmDataset& dataset); - static bool IsJpegLossless(const DcmDataset& dataset); - static void DecodeUncompressedImage(ImageBuffer& target, DcmDataset& dataset, unsigned int frame); diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -299,7 +299,7 @@ { LOG(ERROR) << "Syntax error in the definition of modality \"" << name << "\". Please check your configuration file."; - throw e; + throw; } } @@ -330,7 +330,7 @@ { LOG(ERROR) << "Syntax error in the definition of peer \"" << name << "\". Please check your configuration file."; - throw e; + throw; } } diff -r 83489fddd8c5 -r b3f6fb1130cd OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Wed Jun 25 11:08:11 2014 +0200 +++ b/OrthancServer/ServerContext.cpp Wed Jun 25 11:36:41 2014 +0200 @@ -286,7 +286,7 @@ LogMissingRequiredTag(dicomSummary); } - throw e; + throw; } }