Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:46

0001 // @(#)root/base:$Id$
0002 // Author: Jan Fiete Grosse-Oetringhaus  01/06/07
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TFileCollection
0013 #define ROOT_TFileCollection
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TFileCollection                                                      //
0018 //                                                                      //
0019 // Class that contains a list of TFileInfo's and accumulated meta       //
0020 // data information about its entries. This class is used to describe   //
0021 // file sets as stored by Grid file catalogs, by PROOF or any other     //
0022 // collection of TFile names.                                           //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "TNamed.h"
0027 
0028 #include "TString.h"
0029 
0030 class THashList;
0031 class TMap;
0032 class TList;
0033 class TCollection;
0034 class TFileInfo;
0035 class TFileInfoMeta;
0036 class TObjString;
0037 
0038 
0039 class TFileCollection : public TNamed {
0040 
0041 private:
0042    THashList  *fList;               //-> list of TFileInfos
0043    TList      *fMetaDataList;       //-> generic list of file meta data object(s)
0044                                     //  (summed over entries of fList)
0045    TString     fDefaultTree;        // name of default tree
0046    Long64_t    fTotalSize;          // total size of files in the list
0047    Long64_t    fNFiles;             // number of files ( == fList->GetEntries(), needed
0048                                     // because TFileCollection might be read without fList)
0049    Long64_t    fNStagedFiles;       // number of staged files
0050    Long64_t    fNCorruptFiles;      // number of corrupt files
0051 
0052    TFileCollection(const TFileCollection&) = delete;
0053    TFileCollection& operator=(const TFileCollection&) = delete;
0054 
0055    void PrintDetailed(TString &showOnly) const;
0056    void FormatSize(Long64_t bytes, TString &um, Double_t &size) const;
0057 
0058 public:
0059    enum EStatusBits {
0060       kRemoteCollection = BIT(15)   // the collection is not staged
0061    };
0062    TFileCollection(const char *name = nullptr, const char *title = nullptr,
0063                    const char *file = nullptr, Int_t nfiles = -1, Int_t firstfile = 1);
0064    virtual ~TFileCollection();
0065 
0066    Int_t           Add(TFileInfo *info);
0067    Int_t           Add(TFileCollection *coll);
0068    Int_t           AddFromFile(const char *file, Int_t nfiles = -1, Int_t firstfile = 1);
0069    Int_t           Add(const char *path);
0070    THashList      *GetList() { return fList; }
0071    void            SetList(THashList* list) { fList = list; }
0072 
0073    TObjString     *ExportInfo(const char *name = nullptr, Int_t popt = 0);
0074 
0075    Long64_t        Merge(TCollection* list);
0076    Int_t           RemoveDuplicates();
0077    Int_t           Update(Long64_t avgsize = -1);
0078    void            Sort(Bool_t useindex = kFALSE);
0079    void            SetAnchor(const char *anchor);
0080    void            Print(Option_t *option = "") const override;
0081 
0082    void            SetBitAll(UInt_t f);
0083    void            ResetBitAll(UInt_t f);
0084 
0085    Long64_t        GetTotalSize() const           { return fTotalSize; }
0086    Long64_t        GetNFiles() const              { return fNFiles; }
0087    Long64_t        GetNStagedFiles() const        { return fNStagedFiles; }
0088    Long64_t        GetNCorruptFiles() const       { return fNCorruptFiles; }
0089    Float_t         GetStagedPercentage() const
0090                    { return (fNFiles > 0) ? 100. * fNStagedFiles / fNFiles : 0; }
0091    Float_t         GetCorruptedPercentage() const
0092                    { return (fNFiles > 0) ? 100. * fNCorruptFiles / fNFiles : 0; }
0093 
0094    const char     *GetDefaultTreeName() const;
0095    void            SetDefaultTreeName(const char* treeName) { fDefaultTree = treeName; }
0096    Long64_t        GetTotalEntries(const char *tree) const;
0097 
0098    TFileInfoMeta  *GetMetaData(const char *meta = nullptr) const;
0099    void            SetDefaultMetaData(const char *meta);
0100    Bool_t          AddMetaData(TObject *meta);
0101    void            RemoveMetaData(const char *meta = nullptr);
0102 
0103    TFileCollection *GetStagedSubset();
0104 
0105    TFileCollection *GetFilesOnServer(const char *server);
0106    TMap            *GetFilesPerServer(const char *exclude = nullptr, Bool_t curronly =  kFALSE);
0107 
0108    ClassDefOverride(TFileCollection, 3)  // Collection of TFileInfo objects
0109 };
0110 
0111 #endif