Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:30:20

0001 // @(#)root/base:$Id$
0002 // Author: Andreas-Joachim Peters   20/9/2005
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2005, 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_TFileInfo
0013 #define ROOT_TFileInfo
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TFileInfo                                                            //
0018 //                                                                      //
0019 // Class describing a generic file including meta information.          //
0020 //                                                                      //
0021 //////////////////////////////////////////////////////////////////////////
0022 
0023 #include "TNamed.h"
0024 #include "TList.h"
0025 
0026 #ifdef R__LESS_INCLUDES
0027 class TUrl;
0028 class TUUID;
0029 class TMD5;
0030 #else
0031 #include "TUrl.h"
0032 #include "TUUID.h"
0033 #include "TMD5.h"
0034 #endif
0035 
0036 class TFileInfoMeta;
0037 
0038 
0039 class TFileInfo : public TNamed {
0040 
0041 private:
0042    TUrl            *fCurrentUrl;     ///<! current URL to access the file, points to URL in the fUrlList or 0, if the list end is reached
0043    TList           *fUrlList;        // list of file URLs
0044    Long64_t         fSize;           // file size
0045    TUUID           *fUUID;           //-> uuid of the referenced file
0046    TMD5            *fMD5;            //-> md5 digest of the file
0047    TList           *fMetaDataList;   // generic list of file meta data object(s)
0048 
0049    Int_t            fIndex;          // Index to be used when sorting with index
0050 
0051    void             ParseInput(const char *in);
0052 
0053    TFileInfo& operator=(const TFileInfo&) = delete;
0054 
0055 public:
0056    enum EStatusBits {
0057       kStaged    = BIT(15),
0058       kCorrupted = BIT(16),
0059       kSortWithIndex  = BIT(17)     // Use index when sorting (in Compare)
0060    };
0061 
0062    TFileInfo(const char *url = nullptr, Long64_t size = -1, const char *uuid = nullptr,
0063              const char *md5 = nullptr, TObject *meta = nullptr);
0064    TFileInfo(const TFileInfo &);
0065 
0066    virtual ~TFileInfo();
0067 
0068    void            ResetUrl() { fCurrentUrl = (TUrl*)fUrlList->First(); }
0069    TUrl           *NextUrl();
0070    TUrl           *GetCurrentUrl() const;
0071    TUrl           *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
0072    TUrl           *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
0073    Bool_t          RemoveUrlAt(Int_t i);
0074    Int_t           GetNUrls() const    { return fUrlList->GetEntries(); }
0075 
0076    Bool_t          SetCurrentUrl(const char *url);
0077    Bool_t          SetCurrentUrl(TUrl *url);
0078 
0079    Long64_t        GetSize() const         { return fSize; }
0080    TUUID          *GetUUID() const         { return fUUID; }
0081    TMD5           *GetMD5() const          { return fMD5; }
0082    TList          *GetMetaDataList() const { return fMetaDataList; }
0083    TFileInfoMeta  *GetMetaData(const char *meta = nullptr) const;
0084 
0085    void            SetSize(Long64_t size)  { fSize = size; }
0086    void            SetUUID(const char *uuid);
0087 
0088    TUrl           *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);
0089 
0090    Bool_t          AddUrl(const char *url, Bool_t infront = kFALSE);
0091    Bool_t          RemoveUrl(const char *url);
0092    Bool_t          AddMetaData(TObject *meta);
0093    Bool_t          RemoveMetaData(const char *meta = nullptr);
0094 
0095    Bool_t          IsSortable() const override { return kTRUE; }
0096    Int_t           Compare(const TObject *obj) const override;
0097 
0098    Int_t           GetIndex() const { return fIndex; }
0099    void            SetIndex(Int_t idx) { fIndex = idx; }
0100 
0101    void            Print(Option_t *options="") const override;
0102 
0103    ClassDefOverride(TFileInfo,4)   // Describes generic file info including meta data information
0104 };
0105 
0106 
0107 class TFileInfoMeta : public TNamed {
0108 
0109 private:
0110    Long64_t      fEntries;    // number of entries in tree or number of objects
0111    Long64_t      fFirst;      // first valid tree entry
0112    Long64_t      fLast;       // last valid tree entry
0113    Bool_t        fIsTree;     // true if type is a TTree (or TTree derived)
0114    Long64_t      fTotBytes;   // uncompressed size in bytes
0115    Long64_t      fZipBytes;   // compressed size in bytes
0116 
0117    TFileInfoMeta& operator=(const TFileInfoMeta &) = delete;
0118 
0119 public:
0120    enum EStatusBits { kExternal  = BIT(15) };
0121 
0122    TFileInfoMeta() : fEntries(-1), fFirst(0), fLast(-1),
0123                      fIsTree(kFALSE), fTotBytes(-1), fZipBytes(-1)
0124                      { ResetBit(TFileInfoMeta::kExternal); }
0125    TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
0126                  Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
0127                  Long64_t totbytes = -1, Long64_t zipbytes = -1);
0128    TFileInfoMeta(const char *objPath, const char *objDir,
0129                  const char *objClass, Long64_t entries = -1,
0130                  Long64_t first = 0, Long64_t last = -1,
0131                  Long64_t totbytes = -1, Long64_t zipbytes = -1);
0132    TFileInfoMeta(const TFileInfoMeta &m);
0133 
0134    virtual ~TFileInfoMeta() { }
0135 
0136    const char     *GetObject() const;
0137    const char     *GetClass() const        { return GetTitle(); }
0138    const char     *GetDirectory() const;
0139    Long64_t        GetEntries() const      { return fEntries; }
0140    Long64_t        GetFirst() const        { return fFirst; }
0141    Long64_t        GetLast() const         { return fLast; }
0142    Bool_t          IsTree() const          { return fIsTree; }
0143    Long64_t        GetTotBytes() const     { return fTotBytes; }
0144    Long64_t        GetZipBytes() const     { return fZipBytes; }
0145 
0146    void            SetEntries(Long64_t entries) { fEntries = entries; }
0147    void            SetFirst(Long64_t first)     { fFirst = first; }
0148    void            SetLast(Long64_t last)       { fLast = last; }
0149    void            SetTotBytes(Long64_t tot)    { fTotBytes = tot; }
0150    void            SetZipBytes(Long64_t zip)    { fZipBytes = zip; }
0151 
0152    void            Print(Option_t *options="") const override;
0153 
0154    ClassDefOverride(TFileInfoMeta,2)   // Describes TFileInfo meta data
0155 };
0156 
0157 #endif