diff Core/DicomNetworking/DicomAssociationParameters.h @ 3875:ea1d32861cfc transcoding

moving timeout from DicomAssocation to DicomAssociationParameters
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 May 2020 14:49:31 +0200
parents 3d1bb2193832
children 661c931f22ad
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomAssociationParameters.h	Thu Apr 30 15:00:20 2020 +0200
+++ b/Core/DicomNetworking/DicomAssociationParameters.h	Mon May 04 14:49:31 2020 +0200
@@ -35,6 +35,8 @@
 
 #include "RemoteModalityParameters.h"
 
+#include <json/value.h>
+
 class OFCondition;  // From DCMTK
 
 namespace Orthanc
@@ -42,14 +44,13 @@
   class DicomAssociationParameters
   {
   private:
-    std::string           localAet_;
-    std::string           remoteAet_;
-    std::string           remoteHost_;
-    uint16_t              remotePort_;
-    ModalityManufacturer  manufacturer_;
-    uint32_t              timeout_;
+    std::string               localAet_;
+    RemoteModalityParameters  remote_;
+    uint32_t                  timeout_;
 
-    void ReadDefaultTimeout();
+    static void CheckHost(const std::string& host);
+
+    static uint32_t GetDefaultTimeout();
 
   public:
     DicomAssociationParameters();
@@ -62,56 +63,39 @@
       return localAet_;
     }
 
-    const std::string& GetRemoteApplicationEntityTitle() const
-    {
-      return remoteAet_;
-    }
-
-    const std::string& GetRemoteHost() const
-    {
-      return remoteHost_;
-    }
-
-    uint16_t GetRemotePort() const
-    {
-      return remotePort_;
-    }
-
-    ModalityManufacturer GetRemoteManufacturer() const
-    {
-      return manufacturer_;
-    }
-
     void SetLocalApplicationEntityTitle(const std::string& aet)
     {
       localAet_ = aet;
     }
 
+    const RemoteModalityParameters& GetRemoteModality() const
+    {
+      return remote_;
+    }
+
+    void SetRemoteModality(const RemoteModalityParameters& parameters);
+    
     void SetRemoteApplicationEntityTitle(const std::string& aet)
     {
-      remoteAet_ = aet;
+      remote_.SetApplicationEntityTitle(aet);
     }
 
     void SetRemoteHost(const std::string& host);
 
     void SetRemotePort(uint16_t port)
     {
-      remotePort_ = port;
+      remote_.SetPortNumber(port);
     }
 
     void SetRemoteManufacturer(ModalityManufacturer manufacturer)
     {
-      manufacturer_ = manufacturer;
+      remote_.SetManufacturer(manufacturer);
     }
 
-    void SetRemoteModality(const RemoteModalityParameters& parameters);
-
     bool IsEqual(const DicomAssociationParameters& other) const;
 
-    void SetTimeout(uint32_t seconds)
-    {
-      timeout_ = seconds;
-    }
+    // Setting it to "0" disables the timeout (infinite wait)
+    void SetTimeout(uint32_t seconds);
 
     uint32_t GetTimeout() const
     {
@@ -122,6 +106,10 @@
     {
       return timeout_ != 0;
     }
+
+    void SerializeJob(Json::Value& target) const;
+    
+    static DicomAssociationParameters UnserializeJob(const Json::Value& serialized);
     
     static void SetDefaultTimeout(uint32_t seconds);
   };