Skip to content

Commit d90a6d9

Browse files
committed
deprecate Close method in FairSource/Sink
1 parent 84175d0 commit d90a6d9

21 files changed

+49
-47
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8282
* `virtual bool operator<(const FairTimeStamp* rValue) const` changed to `bool operator<(const FairTimeStamp& rValue) const`
8383
* FairModule::svList is gone. This was never intended as a public
8484
API.
85+
* Remove calling `Close()`
86+
* `FairSink::Close()` and `FairSource::Close()` are no longer called in FairRoot.
87+
* Derived classes from `FairSink` and `FairSource` should close the resources automatically in their destructors.
8588
8689
### Deprecations
8790

examples/MQ/pixelDetector/src/FairOnlineSink.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class FairOnlineSink : public FairSink
3333
FairOnlineSink& operator=(const FairOnlineSink&) = delete;
3434

3535
Bool_t InitSink() override { return kTRUE; }
36-
void Close() override {}
3736
void Reset() override {}
3837

3938
Sink_Type GetSinkType() override { return kONLINESINK; }

examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ Int_t PixelDigiBinSource::ReadEvent(UInt_t i)
106106
for (Int_t idata = 0; idata < head[3]; idata++) {
107107
LOG(debug) << " --/" << idata << "/--> " << dataCont[idata * dataSize + 0] << " / "
108108
<< dataCont[idata * dataSize + 1] << " / " << dataCont[idata * dataSize + 2] << " / "
109-
<< dataCont[idata * dataSize + 3] << " / "
110-
<< " 0.";
109+
<< dataCont[idata * dataSize + 3] << " / " << " 0.";
111110
new (fDigis[fNDigis]) PixelDigi(-1,
112111
dataCont[idata * dataSize + 0],
113112
dataCont[idata * dataSize + 1],
@@ -138,11 +137,12 @@ Bool_t PixelDigiBinSource::ActivateObject(TObject** obj, const char* BrName)
138137
return kTRUE;
139138
}
140139

141-
void PixelDigiBinSource::Close() { fInputFile.close(); }
142-
143140
void PixelDigiBinSource::Reset() {}
144141

145-
Int_t PixelDigiBinSource::CheckMaxEventNo(Int_t /*EvtEnd*/) { return -1; }
142+
Int_t PixelDigiBinSource::CheckMaxEventNo(Int_t /*EvtEnd*/)
143+
{
144+
return -1;
145+
}
146146

147147
void PixelDigiBinSource::FillEventHeader(FairEventHeader* feh)
148148
{

examples/MQ/pixelDetector/src/PixelDigiBinSource.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class PixelDigiBinSource : public FairSource
3333
Bool_t Init() override;
3434

3535
Int_t ReadEvent(UInt_t i = 0) override;
36-
void Close() override;
3736
void Reset() override;
3837
Bool_t SpecifyRunId() override
3938
{
@@ -78,6 +77,9 @@ class PixelDigiBinSource : public FairSource
7877
PixelDigiBinSource(const PixelDigiBinSource&);
7978
PixelDigiBinSource& operator=(const PixelDigiBinSource&);
8079

80+
// Private member functions:
81+
void Close() override { fInputFile.close(); }
82+
8183
ClassDefOverride(PixelDigiBinSource, 1);
8284
};
8385

examples/MQ/pixelDetector/src/PixelDigiSource.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ Bool_t PixelDigiSource::ActivateObject(TObject** obj, const char* BrName)
136136
return kTRUE;
137137
}
138138

139-
void PixelDigiSource::Close() { fInputFile.close(); }
140-
141139
void PixelDigiSource::Reset() {}
142140

143-
Int_t PixelDigiSource::CheckMaxEventNo(Int_t /*EvtEnd*/) { return -1; }
141+
Int_t PixelDigiSource::CheckMaxEventNo(Int_t /*EvtEnd*/)
142+
{
143+
return -1;
144+
}
144145

145146
void PixelDigiSource::FillEventHeader(FairEventHeader* feh)
146147
{

examples/MQ/pixelDetector/src/PixelDigiSource.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class PixelDigiSource : public FairSource
3333
Bool_t Init() override;
3434

3535
Int_t ReadEvent(UInt_t i = 0) override;
36-
void Close() override;
3736
void Reset() override;
3837
Bool_t SpecifyRunId() override
3938
{
@@ -78,6 +77,8 @@ class PixelDigiSource : public FairSource
7877
PixelDigiSource(const PixelDigiSource&);
7978
PixelDigiSource& operator=(const PixelDigiSource&);
8079

80+
void Close() override { fInputFile.close(); }
81+
8182
ClassDefOverride(PixelDigiSource, 1);
8283
};
8384

fairroot/base/sim/FairMCApplication.cxx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,6 @@ void FairMCApplication::FinishRunOnWorker()
478478
LOG(debug) << "FairMCApplication::FinishRunOnWorker: ";
479479

480480
FinishRun();
481-
482-
// Close the sink on workers so that the execution of main FairRunSim->Run()
483-
// finishes with the output files properly closed.
484-
fRootManager->CloseSink();
485481
}
486482

487483
//_____________________________________________________________________________

fairroot/base/sink/FairRootFileSink.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void FairRootFileSink::TruncateBranchNames(TBranch* b, TString ffn)
202202

203203
void FairRootFileSink::Close()
204204
{
205-
if (fRootFile) {
205+
if (fRootFile != nullptr) {
206206
fRootFile->Close();
207207
}
208208
}
@@ -251,7 +251,8 @@ void FairRootFileSink::WriteFolder()
251251
}
252252
}
253253

254-
namespace impl {
254+
namespace impl
255+
{
255256
// a helper function to demangle a type_name
256257
inline std::string demangle(const char* name)
257258
{

fairroot/base/sink/FairRootFileSink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class FairRootFileSink : public FairSink
3838
~FairRootFileSink() override = default;
3939

4040
Bool_t InitSink() override;
41-
void Close() override;
4241
void Reset() override;
4342

4443
Sink_Type GetSinkType() override { return kFILESINK; }
@@ -66,6 +65,7 @@ class FairRootFileSink : public FairSink
6665
void WriteGeometry() override;
6766

6867
FairSink* CloneSink() override;
68+
void Close() override;
6969

7070
private:
7171
/** Title of input sink, could be input, background or signal*/

fairroot/base/sink/FairSink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FairSink
4040
virtual ~FairSink();
4141

4242
virtual Bool_t InitSink() = 0;
43-
virtual void Close() = 0;
43+
virtual void Close() {}
4444
virtual void Reset() = 0;
4545

4646
virtual Sink_Type GetSinkType() = 0;

0 commit comments

Comments
 (0)