ROOT logo
// @(#)root/base:$Id: TFileCollection.h 38735 2011-04-05 09:41:14Z rdm $
// Author: Jan Fiete Grosse-Oetringhaus  01/06/07

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TFileCollection
#define ROOT_TFileCollection

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFileCollection                                                      //
//                                                                      //
// Class that contains a list of TFileInfo's and accumulated meta       //
// data information about its entries. This class is used to describe   //
// file sets as stored by Grid file catalogs, by PROOF or any other     //
// collection of TFile names.                                           //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

#ifndef ROOT_TString
#include "TString.h"
#endif

class THashList;
class TMap;
class TList;
class TCollection;
class TFileInfo;
class TFileInfoMeta;
class TObjString;


class TFileCollection : public TNamed {

private:
   THashList  *fList;               //-> list of TFileInfos
   TList      *fMetaDataList;       //-> generic list of file meta data object(s)
                                    //  (summed over entries of fList)
   TString     fDefaultTree;        // name of default tree
   Long64_t    fTotalSize;          // total size of files in the list
   Long64_t    fNFiles;             // number of files ( == fList->GetEntries(), needed
                                    // because TFileCollection might be read without fList)
   Long64_t    fNStagedFiles;       // number of staged files
   Long64_t    fNCorruptFiles;      // number of corrupt files

   TFileCollection(const TFileCollection&);             // not implemented
   TFileCollection& operator=(const TFileCollection&);  // not implemented

public:
   enum EStatusBits {
      kRemoteCollection = BIT(15)   // the collection is not staged
   };
   TFileCollection(const char *name = 0, const char *title = 0,
                   const char *file = 0, Int_t nfiles = -1, Int_t firstfile = 1);
   virtual ~TFileCollection();

   Int_t           Add(TFileInfo *info);
   Int_t           Add(TFileCollection *coll);
   Int_t           AddFromFile(const char *file, Int_t nfiles = -1, Int_t firstfile = 1);
   Int_t           Add(const char *path);
   THashList      *GetList() { return fList; }
   void            SetList(THashList* list) { fList = list; }

   TObjString     *ExportInfo(const char *name = 0, Int_t popt = 0);

   Long64_t        Merge(TCollection* list);
   Int_t           RemoveDuplicates();
   Int_t           Update(Long64_t avgsize = -1);
   void            Sort();
   void            SetAnchor(const char *anchor);
   void            Print(Option_t *option = "") const;

   void            SetBitAll(UInt_t f);
   void            ResetBitAll(UInt_t f);

   Long64_t        GetTotalSize() const           { return fTotalSize; }
   Long64_t        GetNFiles() const              { return fNFiles; }
   Long64_t        GetNStagedFiles() const        { return fNStagedFiles; }
   Long64_t        GetNCorruptFiles() const       { return fNCorruptFiles; }
   Float_t         GetStagedPercentage() const
                   { return (fNFiles > 0) ? 100. * fNStagedFiles / fNFiles : 0; }
   Float_t         GetCorruptedPercentage() const
                   { return (fNFiles > 0) ? 100. * fNCorruptFiles / fNFiles : 0; }

   const char     *GetDefaultTreeName() const;
   void            SetDefaultTreeName(const char* treeName) { fDefaultTree = treeName; }
   Long64_t        GetTotalEntries(const char *tree) const;

   TFileInfoMeta  *GetMetaData(const char *meta = 0) const;
   void            SetDefaultMetaData(const char *meta);
   Bool_t          AddMetaData(TObject *meta);
   void            RemoveMetaData(const char *meta = 0);

   TFileCollection *GetStagedSubset();

   TFileCollection *GetFilesOnServer(const char *server);
   TMap            *GetFilesPerServer(const char *exclude = 0, Bool_t curronly =  kFALSE);

   ClassDef(TFileCollection, 3)  // Collection of TFileInfo objects
};

#endif
 TFileCollection.h:1
 TFileCollection.h:2
 TFileCollection.h:3
 TFileCollection.h:4
 TFileCollection.h:5
 TFileCollection.h:6
 TFileCollection.h:7
 TFileCollection.h:8
 TFileCollection.h:9
 TFileCollection.h:10
 TFileCollection.h:11
 TFileCollection.h:12
 TFileCollection.h:13
 TFileCollection.h:14
 TFileCollection.h:15
 TFileCollection.h:16
 TFileCollection.h:17
 TFileCollection.h:18
 TFileCollection.h:19
 TFileCollection.h:20
 TFileCollection.h:21
 TFileCollection.h:22
 TFileCollection.h:23
 TFileCollection.h:24
 TFileCollection.h:25
 TFileCollection.h:26
 TFileCollection.h:27
 TFileCollection.h:28
 TFileCollection.h:29
 TFileCollection.h:30
 TFileCollection.h:31
 TFileCollection.h:32
 TFileCollection.h:33
 TFileCollection.h:34
 TFileCollection.h:35
 TFileCollection.h:36
 TFileCollection.h:37
 TFileCollection.h:38
 TFileCollection.h:39
 TFileCollection.h:40
 TFileCollection.h:41
 TFileCollection.h:42
 TFileCollection.h:43
 TFileCollection.h:44
 TFileCollection.h:45
 TFileCollection.h:46
 TFileCollection.h:47
 TFileCollection.h:48
 TFileCollection.h:49
 TFileCollection.h:50
 TFileCollection.h:51
 TFileCollection.h:52
 TFileCollection.h:53
 TFileCollection.h:54
 TFileCollection.h:55
 TFileCollection.h:56
 TFileCollection.h:57
 TFileCollection.h:58
 TFileCollection.h:59
 TFileCollection.h:60
 TFileCollection.h:61
 TFileCollection.h:62
 TFileCollection.h:63
 TFileCollection.h:64
 TFileCollection.h:65
 TFileCollection.h:66
 TFileCollection.h:67
 TFileCollection.h:68
 TFileCollection.h:69
 TFileCollection.h:70
 TFileCollection.h:71
 TFileCollection.h:72
 TFileCollection.h:73
 TFileCollection.h:74
 TFileCollection.h:75
 TFileCollection.h:76
 TFileCollection.h:77
 TFileCollection.h:78
 TFileCollection.h:79
 TFileCollection.h:80
 TFileCollection.h:81
 TFileCollection.h:82
 TFileCollection.h:83
 TFileCollection.h:84
 TFileCollection.h:85
 TFileCollection.h:86
 TFileCollection.h:87
 TFileCollection.h:88
 TFileCollection.h:89
 TFileCollection.h:90
 TFileCollection.h:91
 TFileCollection.h:92
 TFileCollection.h:93
 TFileCollection.h:94
 TFileCollection.h:95
 TFileCollection.h:96
 TFileCollection.h:97
 TFileCollection.h:98
 TFileCollection.h:99
 TFileCollection.h:100
 TFileCollection.h:101
 TFileCollection.h:102
 TFileCollection.h:103
 TFileCollection.h:104
 TFileCollection.h:105
 TFileCollection.h:106
 TFileCollection.h:107
 TFileCollection.h:108
 TFileCollection.h:109
 TFileCollection.h:110
 TFileCollection.h:111
 TFileCollection.h:112