Logo ROOT  
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 #include "TNamed.h"
27 
28 #include "TString.h"
29 
30 class THashList;
31 class TMap;
32 class TList;
33 class TCollection;
34 class TFileInfo;
35 class TFileInfoMeta;
36 class TObjString;
37 
38 
39 class TFileCollection : public TNamed {
40 
41 private:
42  THashList *fList; //-> list of TFileInfos
43  TList *fMetaDataList; //-> generic list of file meta data object(s)
44  // (summed over entries of fList)
45  TString fDefaultTree; // name of default tree
46  Long64_t fTotalSize; // total size of files in the list
47  Long64_t fNFiles; // number of files ( == fList->GetEntries(), needed
48  // because TFileCollection might be read without fList)
49  Long64_t fNStagedFiles; // number of staged files
50  Long64_t fNCorruptFiles; // number of corrupt files
51 
52  TFileCollection(const TFileCollection&); // not implemented
53  TFileCollection& operator=(const TFileCollection&); // not implemented
54 
55  void PrintDetailed(TString &showOnly) const;
56  void FormatSize(Long64_t bytes, TString &um, Double_t &size) const;
57 
58 public:
59  enum EStatusBits {
60  kRemoteCollection = BIT(15) // the collection is not staged
61  };
62  TFileCollection(const char *name = 0, const char *title = 0,
63  const char *file = 0, Int_t nfiles = -1, Int_t firstfile = 1);
64  virtual ~TFileCollection();
65 
66  Int_t Add(TFileInfo *info);
67  Int_t Add(TFileCollection *coll);
68  Int_t AddFromFile(const char *file, Int_t nfiles = -1, Int_t firstfile = 1);
69  Int_t Add(const char *path);
70  THashList *GetList() { return fList; }
71  void SetList(THashList* list) { fList = list; }
72 
73  TObjString *ExportInfo(const char *name = 0, Int_t popt = 0);
74 
75  Long64_t Merge(TCollection* list);
77  Int_t Update(Long64_t avgsize = -1);
78  void Sort(Bool_t useindex = kFALSE);
79  void SetAnchor(const char *anchor);
80  void Print(Option_t *option = "") const;
81 
82  void SetBitAll(UInt_t f);
83  void ResetBitAll(UInt_t f);
84 
85  Long64_t GetTotalSize() const { return fTotalSize; }
86  Long64_t GetNFiles() const { return fNFiles; }
90  { return (fNFiles > 0) ? 100. * fNStagedFiles / fNFiles : 0; }
92  { return (fNFiles > 0) ? 100. * fNCorruptFiles / fNFiles : 0; }
93 
94  const char *GetDefaultTreeName() const;
95  void SetDefaultTreeName(const char* treeName) { fDefaultTree = treeName; }
96  Long64_t GetTotalEntries(const char *tree) const;
97 
98  TFileInfoMeta *GetMetaData(const char *meta = 0) const;
99  void SetDefaultMetaData(const char *meta);
100  Bool_t AddMetaData(TObject *meta);
101  void RemoveMetaData(const char *meta = 0);
102 
104 
105  TFileCollection *GetFilesOnServer(const char *server);
106  TMap *GetFilesPerServer(const char *exclude = 0, Bool_t curronly = kFALSE);
107 
108  ClassDef(TFileCollection, 3) // Collection of TFileInfo objects
109 };
110 
111 #endif
TFileCollection::AddMetaData
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file collection object.
Definition: TFileCollection.cxx:998
TFileCollection::RemoveDuplicates
Int_t RemoveDuplicates()
Remove duplicates based on the UUID, typically after a verification.
Definition: TFileCollection.cxx:227
TFileCollection::AddFromFile
Int_t AddFromFile(const char *file, Int_t nfiles=-1, Int_t firstfile=1)
Add file names contained in the specified text file.
Definition: TFileCollection.cxx:116
TFileCollection::GetTotalSize
Long64_t GetTotalSize() const
Definition: TFileCollection.h:85
TFileInfo
Class describing a generic file including meta information.
Definition: TFileInfo.h:39
TFileCollection::Sort
void Sort(Bool_t useindex=kFALSE)
Sort the collection.
Definition: TFileCollection.cxx:688
TFileCollection::fList
THashList * fList
Definition: TFileCollection.h:42
TFileCollection::GetTotalEntries
Long64_t GetTotalEntries(const char *tree) const
Returns the number of entries for the specified tree (retrieved from meta data).
Definition: TFileCollection.cxx:622
TFileCollection::fDefaultTree
TString fDefaultTree
Definition: TFileCollection.h:45
TFileCollection::ExportInfo
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().
Definition: TFileCollection.cxx:708
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
TFileCollection::GetMetaData
TFileInfoMeta * GetMetaData(const char *meta=0) const
Returns the meta data object with the specified meta name.
Definition: TFileCollection.cxx:641
TFileCollection::ResetBitAll
void ResetBitAll(UInt_t f)
Reset the bit for all TFileInfos.
Definition: TFileCollection.cxx:586
TFileCollection::SetList
void SetList(THashList *list)
Definition: TFileCollection.h:71
TFileCollection::SetAnchor
void SetAnchor(const char *anchor)
Calls TUrl::SetAnchor() for all URLs contained in all TFileInfos.
Definition: TFileCollection.cxx:553
TFileCollection::PrintDetailed
void PrintDetailed(TString &showOnly) const
Print detailed.
Definition: TFileCollection.cxx:443
TFileCollection::kRemoteCollection
@ kRemoteCollection
Definition: TFileCollection.h:60
tree
Definition: tree.py:1
TFileCollection::~TFileCollection
virtual ~TFileCollection()
Cleanup.
Definition: TFileCollection.cxx:64
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
Float_t
float Float_t
Definition: RtypesCore.h:57
Int_t
int Int_t
Definition: RtypesCore.h:45
TFileCollection::GetNCorruptFiles
Long64_t GetNCorruptFiles() const
Definition: TFileCollection.h:88
TFileCollection::fNFiles
Long64_t fNFiles
Definition: TFileCollection.h:47
TFileCollection::GetStagedPercentage
Float_t GetStagedPercentage() const
Definition: TFileCollection.h:89
TString
Basic string class.
Definition: TString.h:136
TFileCollection::RemoveMetaData
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...
Definition: TFileCollection.cxx:666
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TString.h
TObjString
Collectable string class.
Definition: TObjString.h:28
TFileCollection::Update
Int_t Update(Long64_t avgsize=-1)
Update accumulated information about the elements of the collection (e.g.
Definition: TFileCollection.cxx:312
TFileCollection::TFileCollection
TFileCollection(const TFileCollection &)
TFileCollection::GetNStagedFiles
Long64_t GetNStagedFiles() const
Definition: TFileCollection.h:87
TFileCollection::fTotalSize
Long64_t fTotalSize
Definition: TFileCollection.h:46
TFileCollection::SetBitAll
void SetBitAll(UInt_t f)
Set the bit for all TFileInfos.
Definition: TFileCollection.cxx:572
TFileCollection::FormatSize
void FormatSize(Long64_t bytes, TString &um, Double_t &size) const
Format size.
Definition: TFileCollection.cxx:533
THashList
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
TFileCollection::fNCorruptFiles
Long64_t fNCorruptFiles
Definition: TFileCollection.h:50
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TFileInfoMeta
Definition: TFileInfo.h:108
BIT
#define BIT(n)
Definition: Rtypes.h:85
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TFileCollection::fMetaDataList
TList * fMetaDataList
Definition: TFileCollection.h:43
TFileCollection::EStatusBits
EStatusBits
Definition: TFileCollection.h:59
TFileCollection::Add
Int_t Add(TFileInfo *info)
Add TFileInfo to the collection.
Definition: TFileCollection.cxx:73
TFileCollection::SetDefaultMetaData
void SetDefaultMetaData(const char *meta)
Moves the indicated meta data in the first position, so that it becomes effectively the default.
Definition: TFileCollection.cxx:653
TFileCollection::Merge
Long64_t Merge(TCollection *list)
Merge all TFileCollection objects in li into this TFileCollection object.
Definition: TFileCollection.cxx:280
TFileCollection::operator=
TFileCollection & operator=(const TFileCollection &)
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeant4Unit::um
static constexpr double um
Definition: TGeant4SystemOfUnits.h:106
file
Definition: file.py:1
TFileCollection::GetFilesOnServer
TFileCollection * GetFilesOnServer(const char *server)
Return the subset of files served by 'server'.
Definition: TFileCollection.cxx:771
TFileCollection::GetList
THashList * GetList()
Definition: TFileCollection.h:70
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TFileCollection::fNStagedFiles
Long64_t fNStagedFiles
Definition: TFileCollection.h:49
TFileCollection::GetCorruptedPercentage
Float_t GetCorruptedPercentage() const
Definition: TFileCollection.h:91
TFileCollection::Print
void Print(Option_t *option="") const
Prints the contents of the TFileCollection.
Definition: TFileCollection.cxx:404
TFileCollection::SetDefaultTreeName
void SetDefaultTreeName(const char *treeName)
Definition: TFileCollection.h:95
TFileCollection::GetDefaultTreeName
const char * GetDefaultTreeName() const
Returns the tree set with SetDefaultTreeName if set Returns the name of the first tree in the meta da...
Definition: TFileCollection.cxx:602
TCollection
Collection abstract base class.
Definition: TCollection.h:63
TFileCollection::GetNFiles
Long64_t GetNFiles() const
Definition: TFileCollection.h:86
TFileCollection::GetStagedSubset
TFileCollection * GetStagedSubset()
Creates a subset of the files that have the kStaged & !kCorrupted bit set.
Definition: TFileCollection.cxx:256
TList
A doubly linked list.
Definition: TList.h:44
TFileCollection::GetFilesPerServer
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...
Definition: TFileCollection.cxx:865
TFileCollection
Class that contains a list of TFileInfo's and accumulated meta data information about its entries.
Definition: TFileCollection.h:39
TMap
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40