changeset 4582:fb0379abb4a7 db-changes

assume that "GetDatabaseVersion()" can run out of a database transaction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Mar 2021 15:25:17 +0100
parents bb3c82b8f373
children 42a846166fa3
files OrthancServer/Sources/ServerIndex.cpp OrthancServer/Sources/ServerIndex.h
diffstat 2 files changed, 10 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerIndex.cpp	Tue Mar 09 15:22:03 2021 +0100
+++ b/OrthancServer/Sources/ServerIndex.cpp	Tue Mar 09 15:25:17 2021 +0100
@@ -1879,7 +1879,7 @@
                                           /* out */ uint64_t& dicomUncompressedSize, 
                                           const std::string& publicId)
   {
-    class Operations : public ServerIndex::IReadOnlyOperations
+    class Operations : public IReadOnlyOperations
     {
     private:
       ResourceType&      type_;
@@ -1914,7 +1914,7 @@
       {
       }
       
-      virtual void Apply(ServerIndex::ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE
+      virtual void Apply(ReadOnlyTransaction& transaction) ORTHANC_OVERRIDE
       {
         int64_t top;
         if (!transaction.LookupResource(top, type_, publicId_))
@@ -2031,7 +2031,7 @@
     query.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier));
 
 
-    class Operations : public ServerIndex::IReadOnlyOperations
+    class Operations : public IReadOnlyOperations
     {
     private:
       std::vector<std::string>&               result_;
@@ -2271,26 +2271,6 @@
   }
 
 
-  unsigned int ServerIndex::GetDatabaseVersion()
-  {
-    class Operations : public ReadOnlyOperationsT1<unsigned int&>
-    {
-    public:
-      virtual void ApplyTuple(ReadOnlyTransaction& transaction,
-                              const Tuple& tuple) ORTHANC_OVERRIDE
-      {
-        // TODO - CANDIDATE FOR "TransactionType_Implicit"
-        tuple.get<0>() = transaction.GetDatabaseVersion();
-      }
-    };
-
-    unsigned int version;
-    Operations operations;
-    operations.Apply(*this, version);
-    return version;
-  }
-
-
   bool ServerIndex::LookupParent(std::string& target,
                                  const std::string& publicId,
                                  ResourceType parentType)
--- a/OrthancServer/Sources/ServerIndex.h	Tue Mar 09 15:22:03 2021 +0100
+++ b/OrthancServer/Sources/ServerIndex.h	Tue Mar 09 15:25:17 2021 +0100
@@ -108,6 +108,13 @@
     // "count == 0" means no limit on the number of patients
     void SetMaximumPatientCount(unsigned int count);
 
+    // It is assumed that "GetDatabaseVersion()" can run out of a
+    // database transaction
+    unsigned int GetDatabaseVersion()
+    {
+      return db_.GetDatabaseVersion();
+    }
+
 
     
     /***
@@ -190,11 +197,6 @@
         db_.GetChildrenPublicId(target, id);
       }
 
-      unsigned int GetDatabaseVersion()
-      {
-        return db_.GetDatabaseVersion();
-      }
-
       void GetExportedResources(std::list<ExportedResource>& target /*out*/,
                                 bool& done /*out*/,
                                 int64_t since,
@@ -537,8 +539,6 @@
     bool LookupResourceType(ResourceType& type,
                             const std::string& publicId);
 
-    unsigned int GetDatabaseVersion();
-
     bool LookupParent(std::string& target,
                       const std::string& publicId,
                       ResourceType parentType);