changeset 4615:b91ed9e7f43c db-changes

minor api improvements in OrthancCDatabasePlugin.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Apr 2021 11:20:05 +0200
parents 67d112ef680f
children 943dea50f358
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h
diffstat 2 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Mon Apr 12 17:04:58 2021 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Wed Apr 14 11:20:05 2021 +0200
@@ -718,9 +718,10 @@
     virtual bool LookupParent(int64_t& parentId,
                               int64_t resourceId) ORTHANC_OVERRIDE
     {
-      CheckSuccess(that_.backend_.lookupParent(transaction_, resourceId));
+      uint8_t existing;
+      CheckSuccess(that_.backend_.lookupParent(transaction_, &existing, &parentId, resourceId));
       CheckNoEvent();
-      return ReadSingleInt64Answer(parentId);      
+      return (existing != 0);
     }
 
     
@@ -747,18 +748,20 @@
     
     virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE
     {
-      CheckSuccess(that_.backend_.selectPatientToRecycle(transaction_));
+      uint8_t available;      
+      CheckSuccess(that_.backend_.selectPatientToRecycle(transaction_, &available, &internalId));
       CheckNoEvent();
-      return ReadSingleInt64Answer(internalId);      
+      return (available != 0);
     }
 
     
     virtual bool SelectPatientToRecycle(int64_t& internalId,
                                         int64_t patientIdToAvoid) ORTHANC_OVERRIDE
     {
-      CheckSuccess(that_.backend_.selectPatientToRecycle2(transaction_, patientIdToAvoid));
+      uint8_t available;      
+      CheckSuccess(that_.backend_.selectPatientToRecycle2(transaction_, &available, &internalId, patientIdToAvoid));
       CheckNoEvent();
-      return ReadSingleInt64Answer(internalId);      
+      return (available != 0);
     }
 
     
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Mon Apr 12 17:04:58 2021 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Wed Apr 14 11:20:05 2021 +0200
@@ -1256,8 +1256,9 @@
                                               int64_t id,
                                               int32_t metadata);
     
-    /* Answer is read using "readAnswerInt64()" -- TODO */
     OrthancPluginErrorCode (*lookupParent) (OrthancPluginDatabaseTransaction* transaction,
+                                            uint8_t* isExisting /* out */,
+                                            int64_t* parentId /* out */,
                                             int64_t id);
     
     OrthancPluginErrorCode (*lookupResource) (OrthancPluginDatabaseTransaction* transaction,
@@ -1281,11 +1282,13 @@
                                                        OrthancPluginResourceType* type /* out */,
                                                        const char* publicId);
 
-    /* Answer is read using "readAnswerInt64()" -- TODO */
-    OrthancPluginErrorCode (*selectPatientToRecycle) (OrthancPluginDatabaseTransaction* transaction);
+    OrthancPluginErrorCode (*selectPatientToRecycle) (OrthancPluginDatabaseTransaction* transaction,
+                                                      uint8_t* patientAvailable /* out */,
+                                                      int64_t* patientId /* out */);
     
-    /* Answer is read using "readAnswerInt64()" -- TODO */
     OrthancPluginErrorCode (*selectPatientToRecycle2) (OrthancPluginDatabaseTransaction* transaction,
+                                                       uint8_t* patientAvailable /* out */,
+                                                       int64_t* patientId /* out */,
                                                        int64_t patientIdToAvoid);
 
     OrthancPluginErrorCode (*setGlobalProperty) (OrthancPluginDatabaseTransaction* transaction,