ROOT logo
// @(#)root/base:$Id$
// Author: Andreas-Joachim Peters   20/9/2005

/*************************************************************************
 * Copyright (C) 1995-2005, 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_TFileInfo
#define ROOT_TFileInfo

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TFileInfo                                                            //
//                                                                      //
// Class describing a generic file including meta information.          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

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

#ifndef ROOT_Turl
#include "TUrl.h"
#endif

#ifndef ROOT_TUUID
#include "TUUID.h"
#endif

#ifndef ROOT_TMD5
#include "TMD5.h"
#endif

#ifndef ROOT_TObjString
#include "TObjString.h"
#endif

#ifndef ROOT_TList
#include "TList.h"
#endif

class TFileInfoMeta;


class TFileInfo : public TNamed {

private:
   TUrl            *fCurrentUrl;     //! current URL to access the file, points to URL
                                     //  in the fUrlList or 0, if the list end is reached
   TList           *fUrlList;        // list of file URLs
   Long64_t         fSize;           // file size
   TUUID           *fUUID;           //-> uuid of the referenced file
   TMD5            *fMD5;            //-> md5 digest of the file
   TList           *fMetaDataList;   // generic list of file meta data object(s)

   Int_t            fIndex;          // Index to be used when sorting with index

   void             ParseInput(const char *in);

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

public:
   enum EStatusBits {
      kStaged    = BIT(15),
      kCorrupted = BIT(16),
      kSortWithIndex  = BIT(17)     // Use index when sorting (in Compare)
   };

   TFileInfo(const char *url = 0, Long64_t size = -1, const char *uuid = 0,
             const char *md5 = 0, TObject *meta = 0);
   TFileInfo(const TFileInfo &);

   virtual ~TFileInfo();

   void            ResetUrl() { fCurrentUrl = (TUrl*)fUrlList->First(); }
   TUrl           *NextUrl();
   TUrl           *GetCurrentUrl() const;
   TUrl           *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
   TUrl           *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
   Bool_t          RemoveUrlAt(Int_t i);
   Int_t           GetNUrls() const    { return fUrlList->GetEntries(); }

   Bool_t          SetCurrentUrl(const char *url);
   Bool_t          SetCurrentUrl(TUrl *url);

   Long64_t        GetSize() const         { return fSize; }
   TUUID          *GetUUID() const         { return fUUID; }
   TMD5           *GetMD5() const          { return fMD5; }
   TList          *GetMetaDataList() const { return fMetaDataList; }
   TFileInfoMeta  *GetMetaData(const char *meta = 0) const;

   void            SetSize(Long64_t size)  { fSize = size; }
   void            SetUUID(const char *uuid);

   TUrl           *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);

   Bool_t          AddUrl(const char *url, Bool_t infront = kFALSE);
   Bool_t          RemoveUrl(const char *url);
   Bool_t          AddMetaData(TObject *meta);
   Bool_t          RemoveMetaData(const char *meta = 0);

   Bool_t          IsSortable() const { return kTRUE; }
   Int_t           Compare(const TObject *obj) const;

   Int_t           GetIndex() const { return fIndex; }
   void            SetIndex(Int_t idx) { fIndex = idx; }

   void            Print(Option_t *options="") const;

   ClassDef(TFileInfo,4)   // Describes generic file info including meta data information
};


class TFileInfoMeta : public TNamed {

private:
   Long64_t      fEntries;    // number of entries in tree or number of objects
   Long64_t      fFirst;      // first valid tree entry
   Long64_t      fLast;       // last valid tree entry
   Bool_t        fIsTree;     // true if type is a TTree (or TTree derived)
   Long64_t      fTotBytes;   // uncompressed size in bytes
   Long64_t      fZipBytes;   // compressed size in bytes

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

public:
   enum EStatusBits { kExternal  = BIT(15) };

   TFileInfoMeta() : fEntries(-1), fFirst(0), fLast(-1),
                     fIsTree(kFALSE), fTotBytes(-1), fZipBytes(-1)
                     { ResetBit(TFileInfoMeta::kExternal); }
   TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
                 Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
                 Long64_t totbytes = -1, Long64_t zipbytes = -1);
   TFileInfoMeta(const char *objPath, const char *objDir,
                 const char *objClass, Long64_t entries = -1,
                 Long64_t first = 0, Long64_t last = -1,
                 Long64_t totbytes = -1, Long64_t zipbytes = -1);
   TFileInfoMeta(const TFileInfoMeta &m);

   virtual ~TFileInfoMeta() { }

   const char     *GetObject() const;
   const char     *GetClass() const        { return GetTitle(); }
   const char     *GetDirectory() const;
   Long64_t        GetEntries() const      { return fEntries; }
   Long64_t        GetFirst() const        { return fFirst; }
   Long64_t        GetLast() const         { return fLast; }
   Bool_t          IsTree() const          { return fIsTree; }
   Long64_t        GetTotBytes() const     { return fTotBytes; }
   Long64_t        GetZipBytes() const     { return fZipBytes; }

   void            SetEntries(Long64_t entries) { fEntries = entries; }
   void            SetFirst(Long64_t first)     { fFirst = first; }
   void            SetLast(Long64_t last)       { fLast = last; }
   void            SetTotBytes(Long64_t tot)    { fTotBytes = tot; }
   void            SetZipBytes(Long64_t zip)    { fZipBytes = zip; }

   void            Print(Option_t *options="") const;

   ClassDef(TFileInfoMeta,2)   // Describes TFileInfo meta data
};

#endif
 TFileInfo.h:1
 TFileInfo.h:2
 TFileInfo.h:3
 TFileInfo.h:4
 TFileInfo.h:5
 TFileInfo.h:6
 TFileInfo.h:7
 TFileInfo.h:8
 TFileInfo.h:9
 TFileInfo.h:10
 TFileInfo.h:11
 TFileInfo.h:12
 TFileInfo.h:13
 TFileInfo.h:14
 TFileInfo.h:15
 TFileInfo.h:16
 TFileInfo.h:17
 TFileInfo.h:18
 TFileInfo.h:19
 TFileInfo.h:20
 TFileInfo.h:21
 TFileInfo.h:22
 TFileInfo.h:23
 TFileInfo.h:24
 TFileInfo.h:25
 TFileInfo.h:26
 TFileInfo.h:27
 TFileInfo.h:28
 TFileInfo.h:29
 TFileInfo.h:30
 TFileInfo.h:31
 TFileInfo.h:32
 TFileInfo.h:33
 TFileInfo.h:34
 TFileInfo.h:35
 TFileInfo.h:36
 TFileInfo.h:37
 TFileInfo.h:38
 TFileInfo.h:39
 TFileInfo.h:40
 TFileInfo.h:41
 TFileInfo.h:42
 TFileInfo.h:43
 TFileInfo.h:44
 TFileInfo.h:45
 TFileInfo.h:46
 TFileInfo.h:47
 TFileInfo.h:48
 TFileInfo.h:49
 TFileInfo.h:50
 TFileInfo.h:51
 TFileInfo.h:52
 TFileInfo.h:53
 TFileInfo.h:54
 TFileInfo.h:55
 TFileInfo.h:56
 TFileInfo.h:57
 TFileInfo.h:58
 TFileInfo.h:59
 TFileInfo.h:60
 TFileInfo.h:61
 TFileInfo.h:62
 TFileInfo.h:63
 TFileInfo.h:64
 TFileInfo.h:65
 TFileInfo.h:66
 TFileInfo.h:67
 TFileInfo.h:68
 TFileInfo.h:69
 TFileInfo.h:70
 TFileInfo.h:71
 TFileInfo.h:72
 TFileInfo.h:73
 TFileInfo.h:74
 TFileInfo.h:75
 TFileInfo.h:76
 TFileInfo.h:77
 TFileInfo.h:78
 TFileInfo.h:79
 TFileInfo.h:80
 TFileInfo.h:81
 TFileInfo.h:82
 TFileInfo.h:83
 TFileInfo.h:84
 TFileInfo.h:85
 TFileInfo.h:86
 TFileInfo.h:87
 TFileInfo.h:88
 TFileInfo.h:89
 TFileInfo.h:90
 TFileInfo.h:91
 TFileInfo.h:92
 TFileInfo.h:93
 TFileInfo.h:94
 TFileInfo.h:95
 TFileInfo.h:96
 TFileInfo.h:97
 TFileInfo.h:98
 TFileInfo.h:99
 TFileInfo.h:100
 TFileInfo.h:101
 TFileInfo.h:102
 TFileInfo.h:103
 TFileInfo.h:104
 TFileInfo.h:105
 TFileInfo.h:106
 TFileInfo.h:107
 TFileInfo.h:108
 TFileInfo.h:109
 TFileInfo.h:110
 TFileInfo.h:111
 TFileInfo.h:112
 TFileInfo.h:113
 TFileInfo.h:114
 TFileInfo.h:115
 TFileInfo.h:116
 TFileInfo.h:117
 TFileInfo.h:118
 TFileInfo.h:119
 TFileInfo.h:120
 TFileInfo.h:121
 TFileInfo.h:122
 TFileInfo.h:123
 TFileInfo.h:124
 TFileInfo.h:125
 TFileInfo.h:126
 TFileInfo.h:127
 TFileInfo.h:128
 TFileInfo.h:129
 TFileInfo.h:130
 TFileInfo.h:131
 TFileInfo.h:132
 TFileInfo.h:133
 TFileInfo.h:134
 TFileInfo.h:135
 TFileInfo.h:136
 TFileInfo.h:137
 TFileInfo.h:138
 TFileInfo.h:139
 TFileInfo.h:140
 TFileInfo.h:141
 TFileInfo.h:142
 TFileInfo.h:143
 TFileInfo.h:144
 TFileInfo.h:145
 TFileInfo.h:146
 TFileInfo.h:147
 TFileInfo.h:148
 TFileInfo.h:149
 TFileInfo.h:150
 TFileInfo.h:151
 TFileInfo.h:152
 TFileInfo.h:153
 TFileInfo.h:154
 TFileInfo.h:155
 TFileInfo.h:156
 TFileInfo.h:157
 TFileInfo.h:158
 TFileInfo.h:159
 TFileInfo.h:160
 TFileInfo.h:161
 TFileInfo.h:162
 TFileInfo.h:163
 TFileInfo.h:164
 TFileInfo.h:165
 TFileInfo.h:166
 TFileInfo.h:167
 TFileInfo.h:168
 TFileInfo.h:169