changeset 1111:3730956f41a5 broker

ParseDicomFileCommand::GetDicomDirPath()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 Oct 2019 18:38:26 +0100
parents b82b74d13830
children a08699daf78b
files Framework/Oracle/GenericOracleRunner.cpp Framework/Oracle/ParseDicomFileCommand.cpp Framework/Oracle/ParseDicomFileCommand.h
diffstat 3 files changed, 62 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Oracle/GenericOracleRunner.cpp	Thu Oct 31 15:05:46 2019 +0100
+++ b/Framework/Oracle/GenericOracleRunner.cpp	Thu Oct 31 18:38:26 2019 +0100
@@ -208,7 +208,7 @@
       c = a / b;
     }
 
-    LOG(INFO) << "Oracle reading file: " << c.string();
+    LOG(TRACE) << "Oracle reading file: " << c.string();
     return c.string();
   }
 
--- a/Framework/Oracle/ParseDicomFileCommand.cpp	Thu Oct 31 15:05:46 2019 +0100
+++ b/Framework/Oracle/ParseDicomFileCommand.cpp	Thu Oct 31 18:38:26 2019 +0100
@@ -21,6 +21,10 @@
 
 #include "ParseDicomFileCommand.h"
 
+#include <Core/OrthancException.h>
+
+#include <boost/filesystem/path.hpp>
+
 namespace OrthancStone
 {
   ParseDicomFileCommand::SuccessMessage::SuccessMessage(const ParseDicomFileCommand& command,
@@ -29,4 +33,45 @@
   {
     dicom_.reset(new Orthanc::ParsedDicomFile(content));
   }
+
+
+  Orthanc::ParsedDicomFile& ParseDicomFileCommand::SuccessMessage::GetDicom() const
+  {
+    if (dicom_.get())
+    {
+      return *dicom_;
+    }
+    else
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+    }
+  }
+
+
+  Orthanc::ParsedDicomFile* ParseDicomFileCommand::SuccessMessage::ReleaseDicom()
+  {
+    if (dicom_.get())
+    {
+      return dicom_.release();
+    }
+    else
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+    }
+  }
+
+  
+  std::string ParseDicomFileCommand::GetDicomDirPath(const std::string& dicomDirPath,
+                                                     const std::string& file)
+  {
+    std::string tmp = file;
+
+#if !defined(_WIN32)
+    std::replace(tmp.begin(), tmp.end(), '\\', '/');
+#endif
+
+    boost::filesystem::path base = boost::filesystem::path(dicomDirPath).parent_path();
+
+    return (base / tmp).string();
+  }
 }
--- a/Framework/Oracle/ParseDicomFileCommand.h	Thu Oct 31 15:05:46 2019 +0100
+++ b/Framework/Oracle/ParseDicomFileCommand.h	Thu Oct 31 18:38:26 2019 +0100
@@ -52,10 +52,14 @@
       SuccessMessage(const ParseDicomFileCommand& command,
                      DcmFileFormat& content);
 
-      const Orthanc::ParsedDicomFile& GetDicom() const
+      bool HasDicom() const
       {
-        return *dicom_;
+        return dicom_.get() != NULL;
       }
+
+      Orthanc::ParsedDicomFile& GetDicom() const;
+
+      Orthanc::ParsedDicomFile* ReleaseDicom();
     };
 
   private:
@@ -69,6 +73,16 @@
     {
     }
 
+    ParseDicomFileCommand(const std::string& dicomDirPath,
+                          const std::string& file) :
+      path_(GetDicomDirPath(dicomDirPath, file)),
+      pixelDataIncluded_(true)
+    {
+    }
+
+    static std::string GetDicomDirPath(const std::string& dicomDirPath,
+                                       const std::string& file);
+
     virtual Type GetType() const
     {
       return Type_ParseDicomFile;