changeset 4573:f6bd5563b5df db-changes

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Mar 2021 17:47:43 +0100
parents c12d4e5f469b
children 855e43bb293c
files OrthancServer/Sources/ServerIndex.cpp OrthancServer/Sources/ServerIndex.h
diffstat 2 files changed, 28 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerIndex.cpp	Mon Mar 08 17:08:10 2021 +0100
+++ b/OrthancServer/Sources/ServerIndex.cpp	Mon Mar 08 17:47:43 2021 +0100
@@ -1675,8 +1675,9 @@
           
           Transaction transaction(*this, TransactionType_ReadWrite);
           {
-            ReadWriteTransaction t(db_, *this);
-            writeOperations->Apply(t, *listener_);
+            assert(listener_.get() != NULL);
+            ReadWriteTransaction t(db_, *listener_, *this);
+            writeOperations->Apply(t);
           }
           transaction.Commit(0);
         }
@@ -2961,8 +2962,7 @@
         return found_;
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         int64_t id;
         ResourceType type;
@@ -2976,10 +2976,10 @@
           found_ = true;
           transaction.DeleteResource(id);
 
-          if (listener.HasRemainingLevel())
+          if (transaction.GetListener().HasRemainingLevel())
           {
-            ResourceType remainingType = listener.GetRemainingType();
-            const std::string& remainingUuid = listener.GetRemainingPublicId();
+            ResourceType remainingType = transaction.GetListener().GetRemainingType();
+            const std::string& remainingUuid = transaction.GetListener().GetRemainingPublicId();
 
             target_["RemainingAncestor"] = Json::Value(Json::objectValue);
             target_["RemainingAncestor"]["Path"] = GetBasePath(remainingType, remainingUuid);
@@ -3017,8 +3017,7 @@
       {
       }
       
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         int64_t id;
         ResourceType type;
@@ -3126,8 +3125,7 @@
       {
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         // Lookup for the requested resource
         int64_t id;
@@ -3179,8 +3177,7 @@
       {
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         ResourceType rtype;
         int64_t id;
@@ -3222,8 +3219,7 @@
       {
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         ResourceType rtype;
         int64_t id;
@@ -3268,8 +3264,7 @@
         return newValue_;
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         std::string oldString;
 
@@ -3312,8 +3307,7 @@
     class Operations : public IReadWriteOperations
     {
     public:
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         transaction.ClearChanges();
       }
@@ -3329,8 +3323,7 @@
     class Operations : public IReadWriteOperations
     {
     public:
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         transaction.ClearExportedResources();
       }
@@ -3358,8 +3351,7 @@
       {
       }
         
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         transaction.SetGlobalProperty(property_, value_);
       }
@@ -3387,8 +3379,7 @@
       {
       }
         
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         ResourceType rtype;
         int64_t id;
@@ -3430,8 +3421,7 @@
       {
       }
         
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) ORTHANC_OVERRIDE
+      virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
       {
         int64_t id;
         ResourceType type;
--- a/OrthancServer/Sources/ServerIndex.h	Mon Mar 08 17:08:10 2021 +0100
+++ b/OrthancServer/Sources/ServerIndex.h	Mon Mar 08 17:47:43 2021 +0100
@@ -357,16 +357,24 @@
     class ReadWriteTransaction : public ReadOnlyTransaction
     {
     private:
-      ServerIndex&  index_;
+      Listener&  listener_;
+      ServerIndex&  index_;   // TODO - REMOVE
       
     public:
       ReadWriteTransaction(IDatabaseWrapper& db,
+                           Listener& listener,
                            ServerIndex& index) :
         ReadOnlyTransaction(db),
-        index_(index)   // TODO - REMOVE
+        listener_(listener),
+        index_(index)
       {
       }
 
+      Listener& GetListener()
+      {
+        return listener_;
+      }
+
       void ClearChanges()
       {
         db_.ClearChanges();
@@ -446,8 +454,7 @@
       {
       }
 
-      virtual void Apply(ReadWriteTransaction& transaction,
-                         Listener& listener) = 0;
+      virtual void Apply(ReadWriteTransaction& transaction) = 0;
     };
     
   private: