Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TFileInfo.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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