diff OrthancServer/ServerJobs/ArchiveJob.cpp @ 2966:10c610e80b15

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Dec 2018 15:27:01 +0100
parents 9c0b0a6d8b54
children cb5d75143da0
line wrap: on
line diff
--- a/OrthancServer/ServerJobs/ArchiveJob.cpp	Wed Dec 05 14:33:47 2018 +0100
+++ b/OrthancServer/ServerJobs/ArchiveJob.cpp	Wed Dec 05 15:27:01 2018 +0100
@@ -778,11 +778,9 @@
   };
 
 
-  ArchiveJob::ArchiveJob(boost::shared_ptr<TemporaryFile>& synchronousTarget,
-                         ServerContext& context,
+  ArchiveJob::ArchiveJob(ServerContext& context,
                          bool isMedia,
                          bool enableExtendedSopClass) :
-    synchronousTarget_(synchronousTarget),
     context_(context),
     archive_(new ArchiveIndex(ResourceType_Patient)),  // root
     isMedia_(isMedia),
@@ -791,10 +789,23 @@
     instancesCount_(0),
     uncompressedSize_(0)
   {
-    if (synchronousTarget.get() == NULL)
+  }
+
+
+  void ArchiveJob::SetSynchronousTarget(boost::shared_ptr<TemporaryFile>& target)
+  {
+    if (target.get() == NULL)
     {
       throw OrthancException(ErrorCode_NullPointer);
     }
+    else if (synchronousTarget_.get() != NULL)
+    {
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
+    }
+    else
+    {
+      synchronousTarget_ = target;
+    }
   }
 
 
@@ -819,6 +830,11 @@
   
   void ArchiveJob::Start()
   {
+    if (synchronousTarget_.get() == NULL)
+    {
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
+    }
+    
     if (writer_.get() != NULL)
     {
       throw OrthancException(ErrorCode_BadSequenceOfCalls);