changeset 3850:d729d6e8b484

removing useless abstraction IDicomConnectionManager
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 20 Apr 2020 14:45:21 +0200
parents 8c96b20fb275
children 6498739a3c3c
files Core/DicomNetworking/IDicomConnectionManager.h Core/DicomNetworking/TimeoutDicomConnectionManager.cpp Core/DicomNetworking/TimeoutDicomConnectionManager.h Core/JobsEngine/Operations/IJobOperation.h Core/JobsEngine/Operations/LogJobOperation.cpp Core/JobsEngine/Operations/LogJobOperation.h Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp OrthancServer/ServerJobs/Operations/DeleteResourceOperation.cpp OrthancServer/ServerJobs/Operations/DeleteResourceOperation.h OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp OrthancServer/ServerJobs/Operations/StorePeerOperation.h OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp OrthancServer/ServerJobs/Operations/StoreScuOperation.h OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp OrthancServer/ServerJobs/Operations/SystemCallOperation.h
diffstat 17 files changed, 55 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/IDicomConnectionManager.h	Mon Apr 20 14:24:36 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/**
- * Orthanc - A Lightweight, RESTful DICOM Store
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * In addition, as a special exception, the copyright holders of this
- * program give permission to link the code of its release with the
- * OpenSSL project's "OpenSSL" library (or with modified versions of it
- * that use the same license as the "OpenSSL" library), and distribute
- * the linked executables. You must obey the GNU General Public License
- * in all respects for all of the code used other than "OpenSSL". If you
- * modify file(s) with this exception, you may extend this exception to
- * your version of the file(s), but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source files
- * in the program, then also delete it here.
- * 
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- **/
-
-
-#pragma once
-
-#if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING)
-#  error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be defined
-#endif
-
-#if ORTHANC_ENABLE_DCMTK_NETWORKING == 0
-
-namespace Orthanc
-{
-  // DICOM networking is disabled, this is just a void class
-  class IDicomConnectionManager : public boost::noncopyable
-  {
-  public:
-    virtual ~IDicomConnectionManager()
-    {
-    }
-  };
-}
-
-#else
-
-#include "DicomUserConnection.h"
-
-namespace Orthanc
-{
-  class IDicomConnectionManager : public boost::noncopyable
-  {
-  public:
-    virtual ~IDicomConnectionManager()
-    {
-    }
-
-    class IResource : public boost::noncopyable
-    {
-    public:
-      virtual ~IResource()
-      {
-      }
-
-      virtual DicomUserConnection& GetConnection() = 0;
-    };
-
-    virtual IResource* AcquireConnection(const std::string& localAet,
-                                         const RemoteModalityParameters& remote) = 0;
-  };
-}
-
-#endif
--- a/Core/DicomNetworking/TimeoutDicomConnectionManager.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/DicomNetworking/TimeoutDicomConnectionManager.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -44,32 +44,28 @@
     return boost::posix_time::microsec_clock::universal_time();
   }
 
-  class TimeoutDicomConnectionManager::Resource : public IDicomConnectionManager::IResource
+
+  TimeoutDicomConnectionManager::Resource::Resource(TimeoutDicomConnectionManager& that) : 
+    that_(that)
   {
-  private:
-    TimeoutDicomConnectionManager&  that_;
-
-  public:
-    Resource(TimeoutDicomConnectionManager& that) : 
-      that_(that)
+    if (that_.connection_.get() == NULL)
     {
-      if (that_.connection_.get() == NULL)
-      {
-        throw OrthancException(ErrorCode_InternalError);
-      }
+      throw OrthancException(ErrorCode_InternalError);
     }
+  }
 
-    ~Resource()
-    {
-      that_.Touch();
-    }
+  
+  TimeoutDicomConnectionManager::Resource::~Resource()
+  {
+    that_.Touch();
+  }
 
-    DicomUserConnection& GetConnection()
-    {
-      assert(that_.connection_.get() != NULL);
-      return *that_.connection_;
-    }
-  };
+  
+  DicomUserConnection& TimeoutDicomConnectionManager::Resource::GetConnection()
+  {
+    assert(that_.connection_.get() != NULL);
+    return *that_.connection_;
+  }
 
 
   void TimeoutDicomConnectionManager::Touch()
@@ -119,7 +115,7 @@
   }
 
 
-  IDicomConnectionManager::IResource* 
+  TimeoutDicomConnectionManager::Resource* 
   TimeoutDicomConnectionManager::AcquireConnection(const std::string& localAet,
                                                    const RemoteModalityParameters& remote)
   {
--- a/Core/DicomNetworking/TimeoutDicomConnectionManager.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/DicomNetworking/TimeoutDicomConnectionManager.h	Mon Apr 20 14:45:21 2020 +0200
@@ -33,13 +33,15 @@
 
 #pragma once
 
-#include "IDicomConnectionManager.h"
+#if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING)
+#  error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be defined
+#endif
 
 #if ORTHANC_ENABLE_DCMTK_NETWORKING == 0
 
 namespace Orthanc
 {
-  class TimeoutDicomConnectionManager : public IDicomConnectionManager
+  class TimeoutDicomConnectionManager : public boost::noncopyable
   {
   public:
     void SetTimeout(unsigned int timeout)
@@ -64,16 +66,15 @@
 #else
 
 #include "../Compatibility.h"
+#include "DicomUserConnection.h"
 
 #include <boost/date_time/posix_time/posix_time.hpp>
 
 namespace Orthanc
 {
-  class TimeoutDicomConnectionManager : public IDicomConnectionManager
+  class TimeoutDicomConnectionManager : public boost::noncopyable
   {
   private:
-    class Resource;
-
     std::unique_ptr<DicomUserConnection>  connection_;
     boost::posix_time::ptime              lastUse_;
     boost::posix_time::time_duration      timeout_;
@@ -83,6 +84,19 @@
     void CheckTimeoutInternal();
 
   public:
+    class Resource : public boost::noncopyable
+    {
+    private:
+      TimeoutDicomConnectionManager&  that_;
+
+    public:
+      Resource(TimeoutDicomConnectionManager& that);
+      
+      ~Resource();
+
+      DicomUserConnection& GetConnection();
+    };
+
     TimeoutDicomConnectionManager() :
       timeout_(boost::posix_time::milliseconds(1000))
     {
@@ -96,8 +110,8 @@
 
     void CheckTimeout();
 
-    virtual IResource* AcquireConnection(const std::string& localAet,
-                                         const RemoteModalityParameters& remote);
+    Resource* AcquireConnection(const std::string& localAet,
+                                const RemoteModalityParameters& remote);
   };
 }
 
--- a/Core/JobsEngine/Operations/IJobOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/JobsEngine/Operations/IJobOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -34,7 +34,7 @@
 #pragma once
 
 #include "JobOperationValues.h"
-#include "../../DicomNetworking/IDicomConnectionManager.h"
+#include "../../DicomNetworking/TimeoutDicomConnectionManager.h"
 
 namespace Orthanc
 {
@@ -47,7 +47,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& dicomConnection) = 0;
+                       TimeoutDicomConnectionManager& dicomConnection) = 0;
 
     virtual void Serialize(Json::Value& result) const = 0;
   };
--- a/Core/JobsEngine/Operations/LogJobOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/JobsEngine/Operations/LogJobOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -41,7 +41,7 @@
 {
   void LogJobOperation::Apply(JobOperationValues& outputs,
                               const JobOperationValue& input,
-                              IDicomConnectionManager& connectionManager)
+                              TimeoutDicomConnectionManager& connectionManager)
   {
     switch (input.GetType())
     {
--- a/Core/JobsEngine/Operations/LogJobOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/JobsEngine/Operations/LogJobOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -42,7 +42,7 @@
   public:
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& connectionManager);
+                       TimeoutDicomConnectionManager& connectionManager);
 
     virtual void Serialize(Json::Value& result) const
     {
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -127,7 +127,7 @@
       return currentInput_ >= originalInputs_->GetSize() + workInputs_->GetSize();
     }
 
-    void Step(IDicomConnectionManager& connectionManager)
+    void Step(TimeoutDicomConnectionManager& connectionManager)
     {
       if (IsDone())
       {
--- a/OrthancServer/ServerJobs/Operations/DeleteResourceOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/DeleteResourceOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -44,7 +44,7 @@
 {
   void DeleteResourceOperation::Apply(JobOperationValues& outputs,
                                       const JobOperationValue& input,
-                                      IDicomConnectionManager& connectionManager)
+                                      TimeoutDicomConnectionManager& connectionManager)
   {
     switch (input.GetType())
     {
--- a/OrthancServer/ServerJobs/Operations/DeleteResourceOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/DeleteResourceOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -52,7 +52,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& connectionManager);
+                       TimeoutDicomConnectionManager& connectionManager);
 
     virtual void Serialize(Json::Value& result) const
     {
--- a/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -82,7 +82,7 @@
 
   void ModifyInstanceOperation::Apply(JobOperationValues& outputs,
                                       const JobOperationValue& input,
-                                      IDicomConnectionManager& connectionManager)
+                                      TimeoutDicomConnectionManager& connectionManager)
   {
     if (input.GetType() != JobOperationValue::Type_DicomInstance)
     {
--- a/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -68,7 +68,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& connectionManager);
+                       TimeoutDicomConnectionManager& connectionManager);
 
     virtual void Serialize(Json::Value& target) const;
   };
--- a/OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/StorePeerOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -45,7 +45,7 @@
 {
   void StorePeerOperation::Apply(JobOperationValues& outputs,
                                  const JobOperationValue& input,
-                                 IDicomConnectionManager& connectionManager)
+                                 TimeoutDicomConnectionManager& connectionManager)
   {
     // Configure the HTTP client
     HttpClient client(peer_, "instances");
--- a/OrthancServer/ServerJobs/Operations/StorePeerOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/StorePeerOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -58,7 +58,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& connectionManager);
+                       TimeoutDicomConnectionManager& connectionManager);
 
     virtual void Serialize(Json::Value& result) const;
   };
--- a/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/StoreScuOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -44,9 +44,9 @@
 {
   void StoreScuOperation::Apply(JobOperationValues& outputs,
                                 const JobOperationValue& input,
-                                IDicomConnectionManager& connectionManager)
+                                TimeoutDicomConnectionManager& connectionManager)
   {
-    std::unique_ptr<IDicomConnectionManager::IResource> resource
+    std::unique_ptr<TimeoutDicomConnectionManager::Resource> resource
       (connectionManager.AcquireConnection(localAet_, modality_));
 
     if (resource.get() == NULL)
--- a/OrthancServer/ServerJobs/Operations/StoreScuOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/StoreScuOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -66,7 +66,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& manager);
+                       TimeoutDicomConnectionManager& manager);
 
     virtual void Serialize(Json::Value& result) const;
   };
--- a/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/SystemCallOperation.cpp	Mon Apr 20 14:45:21 2020 +0200
@@ -75,7 +75,7 @@
 
   void SystemCallOperation::Apply(JobOperationValues& outputs,
                                   const JobOperationValue& input,
-                                  IDicomConnectionManager& connectionManager)
+                                  TimeoutDicomConnectionManager& connectionManager)
   {
     std::vector<std::string> arguments = preArguments_;
 
--- a/OrthancServer/ServerJobs/Operations/SystemCallOperation.h	Mon Apr 20 14:24:36 2020 +0200
+++ b/OrthancServer/ServerJobs/Operations/SystemCallOperation.h	Mon Apr 20 14:45:21 2020 +0200
@@ -94,7 +94,7 @@
 
     virtual void Apply(JobOperationValues& outputs,
                        const JobOperationValue& input,
-                       IDicomConnectionManager& connectionManager);
+                       TimeoutDicomConnectionManager& connectionManager);
 
     virtual void Serialize(Json::Value& result) const;
   };