diff --git a/fairroot/base/sink/FairSink.h b/fairroot/base/sink/FairSink.h index 4be278b77e..3f406e004a 100644 --- a/fairroot/base/sink/FairSink.h +++ b/fairroot/base/sink/FairSink.h @@ -16,16 +16,15 @@ #define FAIRSINK_H #include +#include +#include #include +#include #include // map #include // unique_ptr #include // string #include // type_info -class TObject; -class TFolder; -class TTree; - enum Sink_Type { kONLINESINK, @@ -40,6 +39,12 @@ class FairSink virtual ~FairSink(); virtual Bool_t InitSink() = 0; + + /** + * \note It might be called multiple times, please handle that. + * \note It will be called from the dtor of FairRun. + * Don't interact with FairRun here. + */ virtual void Close() = 0; virtual void Reset() = 0; diff --git a/fairroot/base/source/FairSource.h b/fairroot/base/source/FairSource.h index e76a477e0b..296c66d705 100644 --- a/fairroot/base/source/FairSource.h +++ b/fairroot/base/source/FairSource.h @@ -35,6 +35,12 @@ class FairSource : public TObject virtual Bool_t Init() = 0; virtual Int_t ReadEvent(UInt_t = 0) = 0; virtual Bool_t SpecifyRunId() = 0; + + /** + * \note It might be called multiple times, please handle that. + * \note It will be called from the dtor of FairRun. + * Don't interact with FairRun here. + */ virtual void Close() = 0; virtual void Reset() = 0; virtual Bool_t ActivateObject(TObject**, const char*) { return kFALSE; } diff --git a/fairroot/base/steer/FairRun.cxx b/fairroot/base/steer/FairRun.cxx index acceeadebb..2e4cb3eb81 100644 --- a/fairroot/base/steer/FairRun.cxx +++ b/fairroot/base/steer/FairRun.cxx @@ -82,6 +82,13 @@ FairRun::~FairRun() { LOG(debug) << "Enter Destructor of FairRun"; + if (fSource) { + fSource->Close(); + } + if (fSink) { + fSink->Close(); + } + // So that FairRootManager does not try to delete these, because we will do that: fRootManager->SetSource(nullptr); fRootManager->SetSink(nullptr);