From bf862d50d1b871e7680f9abc28bef8dddaf2227c Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Thu, 8 Aug 2019 17:38:04 +0800
Subject: [PATCH] WIP: let the headers could be found via the library name.

---
 Simulation/CMakeLists.txt                     | 15 ++++++--
 .../include/DetSimInterface/IDetSimSvc.h      | 36 +++++++++++++++++++
 Simulation/src/DetSimCore/DetSimAlg.h         |  5 ++-
 Simulation/src/DetSimInterface/IDetSimSvc.cpp |  5 +++
 4 files changed, 58 insertions(+), 3 deletions(-)
 create mode 100644 Simulation/include/DetSimInterface/IDetSimSvc.h
 create mode 100644 Simulation/src/DetSimInterface/IDetSimSvc.cpp

diff --git a/Simulation/CMakeLists.txt b/Simulation/CMakeLists.txt
index ebee926f..bf9567ce 100644
--- a/Simulation/CMakeLists.txt
+++ b/Simulation/CMakeLists.txt
@@ -4,6 +4,17 @@ gaudi_subdir(Simulation v0r0)
 find_package(Geant4)
 include(${Geant4_USE_FILE})
 
+# DetSimInterface (headers only)
+set(DetSimInterface_srcs
+    src/DetSimInterface/*.cpp
+)
+
+
+gaudi_add_library(DetSimInterfaces ${DetSimInterface_srcs}
+    INCLUDE_DIRS include
+    PUBLIC_HEADERS include/DetSimInterface
+)
+
 # DetSimCore module
 
 set(DetSimCore_srcs
@@ -11,6 +22,6 @@ set(DetSimCore_srcs
 )
 
 gaudi_add_module(DetSimCore ${DetSimCore_srcs}
-    INCLUDE_DIRS GaudiKernel Geant4
-    LINK_LIBRARIES GaudiKernel Geant4
+    INCLUDE_DIRS DetSimInterfaces GaudiKernel Geant4
+    LINK_LIBRARIES DetSimInterfaces GaudiKernel Geant4
 )
diff --git a/Simulation/include/DetSimInterface/IDetSimSvc.h b/Simulation/include/DetSimInterface/IDetSimSvc.h
new file mode 100644
index 00000000..3e7d078f
--- /dev/null
+++ b/Simulation/include/DetSimInterface/IDetSimSvc.h
@@ -0,0 +1,36 @@
+#ifndef IDetSimSvc_h
+#define IDetSimSvc_h
+
+#include "GaudiKernel/IService.h"
+
+// IDetSimSvc is the interface between Gaudi and Geant4.
+// All the initialization of Run Manager (RM) should be done here, including:
+//   * Detector Construction
+//   * Physics List
+//   * Primary Generator Action
+//   * User Actions
+// Then, the real simulation should be also done by this service via Run Manager.
+//
+// Note, to decouple the Gaudi and Geant4, we keep all these classes still derived from
+// the original Geant4's base classes, while using Gaudi tools to manage these objects.
+
+class G4RunManager;
+
+class IDetSimSvc: virtual public IInterface {
+public:
+    DeclareInterfaceID(IDetSimSvc, 0, 1); // major/minor version
+    
+    virtual ~IDetSimSvc() = 0;
+
+    // Get the Run Manager
+    virtual G4RunManager* getRM() = 0;
+
+    // Control the run manager directly.
+    virtual StatusCode initializeRM() = 0;
+    virtual StatusCode simulateEvent(int i_event) = 0;
+    virtual StatusCode finalizeRM() = 0;
+
+};
+
+
+#endif
diff --git a/Simulation/src/DetSimCore/DetSimAlg.h b/Simulation/src/DetSimCore/DetSimAlg.h
index 4e3152c9..683456f4 100644
--- a/Simulation/src/DetSimCore/DetSimAlg.h
+++ b/Simulation/src/DetSimCore/DetSimAlg.h
@@ -7,7 +7,7 @@
 #include <GaudiKernel/Algorithm.h>
 #include <GaudiKernel/Property.h>
 
-
+#include <DetSimInterface/IDetSimSvc.h>
 
 class DetSimAlg: public Algorithm {
 public:
@@ -17,6 +17,9 @@ public:
     StatusCode execute() override;
     StatusCode finalize() override;
 
+private:
+    SmartIF<IDetSimSvc> m_detsimsvc;
+
 private:
 
     Gaudi::Property<std::vector<std::string>> m_run_macs{this, "RunMacs"};
diff --git a/Simulation/src/DetSimInterface/IDetSimSvc.cpp b/Simulation/src/DetSimInterface/IDetSimSvc.cpp
new file mode 100644
index 00000000..54cfdd6e
--- /dev/null
+++ b/Simulation/src/DetSimInterface/IDetSimSvc.cpp
@@ -0,0 +1,5 @@
+#include "DetSimInterface/IDetSimSvc.h"
+
+IDetSimSvc::~IDetSimSvc() {
+
+}
-- 
GitLab