From f7ae2b3226150b142adaacb696d72d4e9bc1ac7a Mon Sep 17 00:00:00 2001 From: jchudoba Date: Tue, 16 Jul 2002 13:48:39 +0000 Subject: [PATCH] Add methods to get access to names of files used in merging. Correct memory leak in dtor (thanks to Yves Schutz.) --- STEER/AliStream.cxx | 21 ++++++++++++++++++++- STEER/AliStream.h | 7 +++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/STEER/AliStream.cxx b/STEER/AliStream.cxx index 8fa30c95e50..2f893781623 100644 --- a/STEER/AliStream.cxx +++ b/STEER/AliStream.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.5 2002/04/09 13:38:47 jchudoba +Add const to the filename argument + Revision 1.4 2001/12/03 07:10:13 jchudoba Default ctor cannot create new objects, create dummy default ctor which leaves object in not well defined state - to be used only by root for I/O @@ -77,7 +80,10 @@ AliStream::AliStream(Option_t *option) AliStream::~AliStream() { // default dtor - if (fFileNames) delete fFileNames; + if (fFileNames) { + fFileNames->Delete(); + delete fFileNames; + } } //////////////////////////////////////////////////////////////////////// @@ -172,3 +178,16 @@ Bool_t AliStream::ImportgAlice() if (!gAlice) return kFALSE; return kTRUE; } +//////////////////////////////////////////////////////////////////////// +TString AliStream::GetFileName(const Int_t order) const +// returns name of the order-th file +// returns empty string if such file does not exist +// first file in the input stream is 0 +{ + TString fileName(""); + if (order > fFileNames->GetLast()) return fileName; + TObjString *fileNameStored = dynamic_cast(fFileNames->At(order)); + if (fileNameStored) fileName = fileNameStored->GetString(); + return fileName; +} +//////////////////////////////////////////////////////////////////////// diff --git a/STEER/AliStream.h b/STEER/AliStream.h index 32e4bc7e918..426e9d44fe7 100644 --- a/STEER/AliStream.h +++ b/STEER/AliStream.h @@ -16,6 +16,7 @@ // --- ROOT system --- #include "TNamed.h" #include "TObjString.h" +#include "TString.h" #include "TArrayI.h" #include "TClonesArray.h" #include "TFile.h" @@ -34,15 +35,17 @@ public: Bool_t ImportgAlice(); TFile* CurrentFile() { return fCurrentFile;} void ChangeMode(Option_t* option); // reset READ or UPDATE mode + Int_t GetNInputFiles() const {return fFileNames->GetLast()+1;} + TString GetFileName(const Int_t order) const; private: Int_t fLastEventSerialNr; Int_t fLastEventNr; Int_t fCurrentFileIndex; Int_t fEvents; //! nr. of events in the current file - TString fMode; // = 0 for READONLY, = 1 for READWRITE + TString fMode; // = 0 for READONLY, = 1 for READWRITE TFile *fCurrentFile; //! pointer to current open file - TObjArray * fFileNames; + TObjArray * fFileNames; // storage for TStrings with file names ClassDef(AliStream,1) }; -- 2.43.0