From a844406f48ab12d6bc04d3189626d818834d9b23 Mon Sep 17 00:00:00 2001
From: Hadrien Grasland <grasland@lal.in2p3.fr>
Date: Thu, 8 Mar 2018 17:12:39 +0100
Subject: [PATCH] Try to disable DataHandle::commit()

---
 GaudiHive/src/AlgoExecutionTask.cpp         | 2 ++
 GaudiHive/src/HLTEventLoopMgr.cpp           | 2 ++
 GaudiHive/src/IOBoundAlgTask.cpp            | 2 ++
 GaudiKernel/GaudiKernel/AlgTool.h           | 2 ++
 GaudiKernel/GaudiKernel/Algorithm.h         | 2 ++
 GaudiKernel/GaudiKernel/DataHandle.h        | 7 +++++++
 GaudiKernel/GaudiKernel/IDataHandleHolder.h | 2 ++
 GaudiKernel/src/Lib/AlgTool.cpp             | 2 ++
 GaudiKernel/src/Lib/Algorithm.cpp           | 2 ++
 cmake/GaudiBuildFlags.cmake                 | 3 +++
 10 files changed, 26 insertions(+)

diff --git a/GaudiHive/src/AlgoExecutionTask.cpp b/GaudiHive/src/AlgoExecutionTask.cpp
index 31675fd21b..099d408cb9 100644
--- a/GaudiHive/src/AlgoExecutionTask.cpp
+++ b/GaudiHive/src/AlgoExecutionTask.cpp
@@ -55,8 +55,10 @@ tbb::task* AlgoExecutionTask::execute()
     eventfailed = true;
   }
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
   // Commit all DataHandles
   this_algo->commitHandles();
+#endif
 
   // DP it is important to propagate the failure of an event.
   // We need to stop execution when this happens so that execute run can
diff --git a/GaudiHive/src/HLTEventLoopMgr.cpp b/GaudiHive/src/HLTEventLoopMgr.cpp
index 33236b4bc8..621bffc2cd 100644
--- a/GaudiHive/src/HLTEventLoopMgr.cpp
+++ b/GaudiHive/src/HLTEventLoopMgr.cpp
@@ -548,8 +548,10 @@ tbb::task* HLTEventLoopMgr::HLTExecutionTask::execute()
       eventfailed = true;
     }
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
     // Commit all DataHandles
     this_algo->commitHandles();
+#endif
 
     // DP it is important to propagate the failure of an event.
     // We need to stop execution when this happens so that execute run can
diff --git a/GaudiHive/src/IOBoundAlgTask.cpp b/GaudiHive/src/IOBoundAlgTask.cpp
index 9cd45251dc..57a0df82cf 100644
--- a/GaudiHive/src/IOBoundAlgTask.cpp
+++ b/GaudiHive/src/IOBoundAlgTask.cpp
@@ -56,8 +56,10 @@ StatusCode IOBoundAlgTask::execute()
     eventfailed = true;
   }
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
   // Commit all DataHandles
   this_algo->commitHandles();
+#endif
 
   // DP it is important to propagate the failure of an event.
   // We need to stop execution when this happens so that execute run can
diff --git a/GaudiKernel/GaudiKernel/AlgTool.h b/GaudiKernel/GaudiKernel/AlgTool.h
index ca63d399f6..5744a9cc6c 100644
--- a/GaudiKernel/GaudiKernel/AlgTool.h
+++ b/GaudiKernel/GaudiKernel/AlgTool.h
@@ -209,7 +209,9 @@ public:
 public:
   void acceptDHVisitor( IDataHandleVisitor* ) const override;
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
   void commitHandles() override;
+#endif
 
 public:
   void registerTool( IAlgTool* tool ) const
diff --git a/GaudiKernel/GaudiKernel/Algorithm.h b/GaudiKernel/GaudiKernel/Algorithm.h
index d5e7a066f2..cb3bd24d9e 100644
--- a/GaudiKernel/GaudiKernel/Algorithm.h
+++ b/GaudiKernel/GaudiKernel/Algorithm.h
@@ -439,7 +439,9 @@ public:
 public:
   void acceptDHVisitor( IDataHandleVisitor* ) const override;
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
   void commitHandles() override;
+#endif
 
 public:
   void registerTool( IAlgTool* tool ) const;
diff --git a/GaudiKernel/GaudiKernel/DataHandle.h b/GaudiKernel/GaudiKernel/DataHandle.h
index 725ee3ec57..05f3dd74a8 100644
--- a/GaudiKernel/GaudiKernel/DataHandle.h
+++ b/GaudiKernel/GaudiKernel/DataHandle.h
@@ -50,7 +50,14 @@ namespace Gaudi
     virtual const DataObjID& fullKey() const { return m_key; }
 
     virtual void reset( bool ){};
+
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
+    /// This hook, is called after Algorithm::execute() by GaudiHive's algorithm
+    /// execution tasks. It was meant to allow automatically publishing data
+    /// objects to the whiteboard at the end of algorithm execution. However,
+    /// it is not used anymore, and scheduled for removal.
     virtual StatusCode commit() { return StatusCode::SUCCESS; }
+#endif
 
     virtual std::string pythonRepr() const;
     virtual bool init() { return true; }
diff --git a/GaudiKernel/GaudiKernel/IDataHandleHolder.h b/GaudiKernel/GaudiKernel/IDataHandleHolder.h
index fdb9151ca2..64e02d9fd9 100644
--- a/GaudiKernel/GaudiKernel/IDataHandleHolder.h
+++ b/GaudiKernel/GaudiKernel/IDataHandleHolder.h
@@ -22,7 +22,9 @@ public:
 
   virtual void acceptDHVisitor( IDataHandleVisitor* ) const = 0;
 
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
   virtual void commitHandles() = 0;
+#endif
 
   virtual const DataObjIDColl& inputDataObjs() const  = 0;
   virtual const DataObjIDColl& outputDataObjs() const = 0;
diff --git a/GaudiKernel/src/Lib/AlgTool.cpp b/GaudiKernel/src/Lib/AlgTool.cpp
index 462bea0604..19733e88de 100644
--- a/GaudiKernel/src/Lib/AlgTool.cpp
+++ b/GaudiKernel/src/Lib/AlgTool.cpp
@@ -516,6 +516,7 @@ void AlgTool::acceptDHVisitor( IDataHandleVisitor* vis ) const
 }
 
 //-----------------------------------------------------------------------------
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
 void AlgTool::commitHandles()
 {
   //-----------------------------------------------------------------------------
@@ -527,3 +528,4 @@ void AlgTool::commitHandles()
     if ( at ) at->commitHandles();
   }
 }
+#endif
\ No newline at end of file
diff --git a/GaudiKernel/src/Lib/Algorithm.cpp b/GaudiKernel/src/Lib/Algorithm.cpp
index b253134873..087f01a68e 100644
--- a/GaudiKernel/src/Lib/Algorithm.cpp
+++ b/GaudiKernel/src/Lib/Algorithm.cpp
@@ -957,6 +957,7 @@ SmartIF<IService> Algorithm::service( const std::string& name, const bool create
 }
 
 //-----------------------------------------------------------------------------
+#if defined( GAUDI_V30_DATAHANDLE_COMMIT )
 void Algorithm::commitHandles()
 {
   //-----------------------------------------------------------------------------
@@ -977,6 +978,7 @@ void Algorithm::commitHandles()
     a->commitHandles();
   }
 }
+#endif
 
 void Algorithm::registerTool( IAlgTool* tool ) const
 {
diff --git a/cmake/GaudiBuildFlags.cmake b/cmake/GaudiBuildFlags.cmake
index dbea2807bc..b16f0b549b 100644
--- a/cmake/GaudiBuildFlags.cmake
+++ b/cmake/GaudiBuildFlags.cmake
@@ -104,6 +104,9 @@ option(G22_NEW_SVCLOCATOR
 option(GAUDI_V22
        "enable some API extensions"
        OFF)
+option(GAUDI_V30_DATAHANDLE_COMMIT
+       "enable deprecated DataHandle::commit() hook and associated code"
+       OFF)
 
 if (BINARY_TAG_COMP_NAME STREQUAL "gcc" AND BINARY_TAG_COMP_VERSION VERSION_GREATER "5.0")
   option(GAUDI_SUGGEST_OVERRIDE "enable warnings for missing override keyword" ON)
-- 
GitLab