00001 // @(#)root/base:$Id: TFileCollection.h 36629 2010-11-12 14:46:35Z brun $ 00002 // Author: Jan Fiete Grosse-Oetringhaus 01/06/07 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef ROOT_TFileCollection 00013 #define ROOT_TFileCollection 00014 00015 ////////////////////////////////////////////////////////////////////////// 00016 // // 00017 // TFileCollection // 00018 // // 00019 // Class that contains a list of TFileInfo's and accumulated meta // 00020 // data information about its entries. This class is used to describe // 00021 // file sets as stored by Grid file catalogs, by PROOF or any other // 00022 // collection of TFile names. // 00023 // // 00024 ////////////////////////////////////////////////////////////////////////// 00025 00026 #ifndef ROOT_TNamed 00027 #include "TNamed.h" 00028 #endif 00029 00030 #ifndef ROOT_TString 00031 #include "TString.h" 00032 #endif 00033 00034 class THashList; 00035 class TMap; 00036 class TList; 00037 class TCollection; 00038 class TFileInfo; 00039 class TFileInfoMeta; 00040 class TObjString; 00041 00042 00043 class TFileCollection : public TNamed { 00044 00045 private: 00046 THashList *fList; //-> list of TFileInfos 00047 TList *fMetaDataList; //-> generic list of file meta data object(s) 00048 // (summed over entries of fList) 00049 TString fDefaultTree; // name of default tree 00050 Long64_t fTotalSize; // total size of files in the list 00051 Long64_t fNFiles; // number of files ( == fList->GetEntries(), needed 00052 // because TFileCollection might be read without fList) 00053 Long64_t fNStagedFiles; // number of staged files 00054 Long64_t fNCorruptFiles; // number of corrupt files 00055 00056 TFileCollection(const TFileCollection&); // not implemented 00057 TFileCollection& operator=(const TFileCollection&); // not implemented 00058 00059 public: 00060 enum EStatusBits { 00061 kRemoteCollection = BIT(15) // the collection is not staged 00062 }; 00063 TFileCollection(const char *name = 0, const char *title = 0, 00064 const char *file = 0, Int_t nfiles = -1, Int_t firstfile = 1); 00065 virtual ~TFileCollection(); 00066 00067 Int_t Add(TFileInfo *info); 00068 Int_t Add(TFileCollection *coll); 00069 Int_t AddFromFile(const char *file, Int_t nfiles = -1, Int_t firstfile = 1); 00070 Int_t Add(const char *path); 00071 THashList *GetList() { return fList; } 00072 void SetList(THashList* list) { fList = list; } 00073 00074 TObjString *ExportInfo(const char *name = 0, Int_t popt = 0); 00075 00076 Long64_t Merge(TCollection* list); 00077 Int_t RemoveDuplicates(); 00078 Int_t Update(Long64_t avgsize = -1); 00079 void Sort(); 00080 void SetAnchor(const char *anchor); 00081 void Print(Option_t *option = "") const; 00082 00083 void SetBitAll(UInt_t f); 00084 void ResetBitAll(UInt_t f); 00085 00086 Long64_t GetTotalSize() const { return fTotalSize; } 00087 Long64_t GetNFiles() const { return fNFiles; } 00088 Long64_t GetNStagedFiles() const { return fNStagedFiles; } 00089 Long64_t GetNCorruptFiles() const { return fNCorruptFiles; } 00090 Float_t GetStagedPercentage() const 00091 { return (fNFiles > 0) ? 100. * fNStagedFiles / fNFiles : 0; } 00092 Float_t GetCorruptedPercentage() const 00093 { return (fNFiles > 0) ? 100. * fNCorruptFiles / fNFiles : 0; } 00094 00095 const char *GetDefaultTreeName() const; 00096 void SetDefaultTreeName(const char* treeName) { fDefaultTree = treeName; } 00097 Long64_t GetTotalEntries(const char *tree) const; 00098 00099 TFileInfoMeta *GetMetaData(const char *meta = 0) const; 00100 void SetDefaultMetaData(const char *meta); 00101 Bool_t AddMetaData(TObject *meta); 00102 void RemoveMetaData(const char *meta = 0); 00103 00104 TFileCollection *GetStagedSubset(); 00105 00106 TFileCollection *GetFilesOnServer(const char *server); 00107 TMap *GetFilesPerServer(const char *exclude = 0); 00108 00109 ClassDef(TFileCollection, 3) // Collection of TFileInfo objects 00110 }; 00111 00112 #endif