changeset 942:b3f6fb1130cd

fixes thanks to cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 11:36:41 +0200
parents 83489fddd8c5
children 3fb427ac3f53 427a1f996b7b 394a19d44f9d c2c28dd17e87 e57e08ed510f 766a57997121
files Core/MultiThreading/ReaderWriterLock.h Core/Toolbox.cpp OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/DicomProtocol/RemoteModalityParameters.cpp OrthancServer/Internals/DicomImageDecoder.cpp OrthancServer/Internals/DicomImageDecoder.h OrthancServer/OrthancInitialization.cpp OrthancServer/ServerContext.cpp
diffstat 8 files changed, 125 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- 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 <boost/noncopyable.hpp>
+
 namespace Orthanc
 {
-  class ReaderWriterLock
+  class ReaderWriterLock : public boost::noncopyable
   {
   private:
     struct PImpl;
--- 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]))
--- 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<std::string>::const_iterator it = reservedStorageSOPClasses_.begin();
-         it != reservedStorageSOPClasses_.end(); it++)
+         it != reservedStorageSOPClasses_.end(); ++it)
     {
       RegisterStorageSOPClass(pimpl_->params_, presentationContextId, 
                               *it, asPreferred, asFallback);
     }
 
     for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin();
-         it != storageSOPClasses_.end(); it++)
+         it != storageSOPClasses_.end(); ++it)
     {
       RegisterStorageSOPClass(pimpl_->params_, presentationContextId, 
                               *it, asPreferred, asFallback);
     }
 
     for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin();
-         it != defaultStorageSOPClasses_.end(); it++)
+         it != defaultStorageSOPClasses_.end(); ++it)
     {
       RegisterStorageSOPClass(pimpl_->params_, presentationContextId, 
                               *it, asPreferred, asFallback);
--- 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)
--- 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<DicomIntegerPixelAccessor> slowAccessor_;
-    std::auto_ptr<ImageAccessor> 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<Uint8*>(&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<DicomIntegerPixelAccessor> slowAccessor_;
+    std::auto_ptr<ImageAccessor> 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<Uint8*>(&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
--- 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);
--- 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;
     }
   }
 
--- 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;
     }
   }