Logo ROOT   6.08/07
Reference Guide
TFileCollection.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Jan Fiete Grosse-Oetringhaus 01/06/07
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TFileCollection
13 #define ROOT_TFileCollection
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TFileCollection //
18 // //
19 // Class that contains a list of TFileInfo's and accumulated meta //
20 // data information about its entries. This class is used to describe //
21 // file sets as stored by Grid file catalogs, by PROOF or any other //
22 // collection of TFile names. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #ifndef ROOT_TNamed
27 #include "TNamed.h"
28 #endif
29 
30 #ifndef ROOT_TString
31 #include "TString.h"
32 #endif
33 
34 class THashList;
35 class TMap;
36 class TList;
37 class TCollection;
38 class TFileInfo;
39 class TFileInfoMeta;
40 class TObjString;
41 
42 
43 class TFileCollection : public TNamed {
44 
45 private:
46  THashList *fList; //-> list of TFileInfos
47  TList *fMetaDataList; //-> generic list of file meta data object(s)
48  // (summed over entries of fList)
49  TString fDefaultTree; // name of default tree
50  Long64_t fTotalSize; // total size of files in the list
51  Long64_t fNFiles; // number of files ( == fList->GetEntries(), needed
52  // because TFileCollection might be read without fList)
53  Long64_t fNStagedFiles; // number of staged files
54  Long64_t fNCorruptFiles; // number of corrupt files
55 
56  TFileCollection(const TFileCollection&); // not implemented
57  TFileCollection& operator=(const TFileCollection&); // not implemented
58 
59  void PrintDetailed(TString &showOnly) const;
60  void FormatSize(Long64_t bytes, TString &um, Double_t &size) const;
61 
62 public:
63  enum EStatusBits {
64  kRemoteCollection = BIT(15) // the collection is not staged
65  };
66  TFileCollection(const char *name = 0, const char *title = 0,
67  const char *file = 0, Int_t nfiles = -1, Int_t firstfile = 1);
68  virtual ~TFileCollection();
69 
70  Int_t Add(TFileInfo *info);
71  Int_t Add(TFileCollection *coll);
72  Int_t AddFromFile(const char *file, Int_t nfiles = -1, Int_t firstfile = 1);
73  Int_t Add(const char *path);
74  THashList *GetList() { return fList; }
75  void SetList(THashList* list) { fList = list; }
76 
77  TObjString *ExportInfo(const char *name = 0, Int_t popt = 0);
78 
79  Long64_t Merge(TCollection* list);
81  Int_t Update(Long64_t avgsize = -1);
82  void Sort(Bool_t useindex = kFALSE);
83  void SetAnchor(const char *anchor);
84  void Print(Option_t *option = "") const;
85 
86  void SetBitAll(UInt_t f);
87  void ResetBitAll(UInt_t f);
88 
89  Long64_t GetTotalSize() const { return fTotalSize; }
90  Long64_t GetNFiles() const { return fNFiles; }
94  { return (fNFiles > 0) ? 100. * fNStagedFiles / fNFiles : 0; }
96  { return (fNFiles > 0) ? 100. * fNCorruptFiles / fNFiles : 0; }
97 
98  const char *GetDefaultTreeName() const;
99  void SetDefaultTreeName(const char* treeName) { fDefaultTree = treeName; }
100  Long64_t GetTotalEntries(const char *tree) const;
101 
102  TFileInfoMeta *GetMetaData(const char *meta = 0) const;
103  void SetDefaultMetaData(const char *meta);
104  Bool_t AddMetaData(TObject *meta);
105  void RemoveMetaData(const char *meta = 0);
106 
108 
109  TFileCollection *GetFilesOnServer(const char *server);
110  TMap *GetFilesPerServer(const char *exclude = 0, Bool_t curronly = kFALSE);
111 
112  ClassDef(TFileCollection, 3) // Collection of TFileInfo objects
113 };
114 
115 #endif
TFileInfoMeta * GetMetaData(const char *meta=0) const
Returns the meta data object with the specified meta name.
TFileCollection * GetFilesOnServer(const char *server)
Return the subset of files served by 'server'.
const char * GetDefaultTreeName() const
Returns the tree set with SetDefaultTreeName if set Returns the name of the first tree in the meta da...
long long Long64_t
Definition: RtypesCore.h:69
void SetAnchor(const char *anchor)
Calls TUrl::SetAnchor() for all URLs contained in all TFileInfos.
Collectable string class.
Definition: TObjString.h:32
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Long64_t GetTotalSize() const
Float_t GetStagedPercentage() const
#define BIT(n)
Definition: Rtypes.h:120
Long64_t GetTotalEntries(const char *tree) const
Returns the number of entries for the specified tree (retrieved from meta data).
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Long64_t fNStagedFiles
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TFileCollection * GetStagedSubset()
Creates a subset of the files that have the kStaged & !kCorrupted bit set.
void RemoveMetaData(const char *meta=0)
Removes the indicated meta data object in all TFileInfos and this object If no name is given all meta...
Long64_t Merge(TCollection *list)
Merge all TFileCollection objects in li into this TFileCollection object.
A doubly linked list.
Definition: TList.h:47
TFileCollection & operator=(const TFileCollection &)
void Sort(Bool_t useindex=kFALSE)
Sort the collection.
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file collection object.
TObjString * ExportInfo(const char *name=0, Int_t popt=0)
Export the relevant info as a string; use 'name' as collection name, if defined, else use GetName()...
Int_t RemoveDuplicates()
Remove duplicates based on the UUID, typically after a verification.
THashList * GetList()
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
Long64_t GetNFiles() const
void Print(Option_t *option="") const
Prints the contents of the TFileCollection.
Collection abstract base class.
Definition: TCollection.h:48
unsigned int UInt_t
Definition: RtypesCore.h:42
void FormatSize(Long64_t bytes, TString &um, Double_t &size) const
Format size.
THashList * fList
TFileCollection(const TFileCollection &)
void SetDefaultTreeName(const char *treeName)
double f(double x)
double Double_t
Definition: RtypesCore.h:55
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t AddFromFile(const char *file, Int_t nfiles=-1, Int_t firstfile=1)
Add file names contained in the specified text file.
void SetDefaultMetaData(const char *meta)
Moves the indicated meta data in the first position, so that it becomes effectively the default...
void PrintDetailed(TString &showOnly) const
Print detailed.
Long64_t fNCorruptFiles
virtual ~TFileCollection()
Cleanup.
Class that contains a list of TFileInfo's and accumulated meta data information about its entries...
Definition: file.py:1
void ResetBitAll(UInt_t f)
Reset the bit for all TFileInfos.
Float_t GetCorruptedPercentage() const
Definition: tree.py:1
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
Long64_t GetNCorruptFiles() const
TMap * GetFilesPerServer(const char *exclude=0, Bool_t curronly=kFALSE)
Return a map of TFileCollections with the files on each data server, excluding servers in the comma-s...
void SetBitAll(UInt_t f)
Set the bit for all TFileInfos.
Long64_t GetNStagedFiles() const
char name[80]
Definition: TGX11.cxx:109
void SetList(THashList *list)