Logo ROOT  
Reference Guide
TFileInfo.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Andreas-Joachim Peters 20/9/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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_TFileInfo
13 #define ROOT_TFileInfo
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TFileInfo //
18 // //
19 // Class describing a generic file including meta information. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TNamed.h"
24 #include "TList.h"
25 
26 #ifdef R__LESS_INCLUDES
27 class TUrl;
28 class TUUID;
29 class TMD5;
30 #else
31 #include "TUrl.h"
32 #include "TUUID.h"
33 #include "TMD5.h"
34 #endif
35 
36 class TFileInfoMeta;
37 
38 
39 class TFileInfo : public TNamed {
40 
41 private:
42  TUrl *fCurrentUrl; //! current URL to access the file, points to URL
43  // in the fUrlList or 0, if the list end is reached
44  TList *fUrlList; // list of file URLs
45  Long64_t fSize; // file size
46  TUUID *fUUID; //-> uuid of the referenced file
47  TMD5 *fMD5; //-> md5 digest of the file
48  TList *fMetaDataList; // generic list of file meta data object(s)
49 
50  Int_t fIndex; // Index to be used when sorting with index
51 
52  void ParseInput(const char *in);
53 
54  TFileInfo& operator=(const TFileInfo&); // not implemented
55 
56 public:
57  enum EStatusBits {
58  kStaged = BIT(15),
59  kCorrupted = BIT(16),
60  kSortWithIndex = BIT(17) // Use index when sorting (in Compare)
61  };
62 
63  TFileInfo(const char *url = 0, Long64_t size = -1, const char *uuid = 0,
64  const char *md5 = 0, TObject *meta = 0);
65  TFileInfo(const TFileInfo &);
66 
67  virtual ~TFileInfo();
68 
69  void ResetUrl() { fCurrentUrl = (TUrl*)fUrlList->First(); }
70  TUrl *NextUrl();
71  TUrl *GetCurrentUrl() const;
72  TUrl *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
73  TUrl *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
75  Int_t GetNUrls() const { return fUrlList->GetEntries(); }
76 
77  Bool_t SetCurrentUrl(const char *url);
79 
80  Long64_t GetSize() const { return fSize; }
81  TUUID *GetUUID() const { return fUUID; }
82  TMD5 *GetMD5() const { return fMD5; }
83  TList *GetMetaDataList() const { return fMetaDataList; }
84  TFileInfoMeta *GetMetaData(const char *meta = 0) const;
85 
86  void SetSize(Long64_t size) { fSize = size; }
87  void SetUUID(const char *uuid);
88 
89  TUrl *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);
90 
91  Bool_t AddUrl(const char *url, Bool_t infront = kFALSE);
92  Bool_t RemoveUrl(const char *url);
93  Bool_t AddMetaData(TObject *meta);
94  Bool_t RemoveMetaData(const char *meta = 0);
95 
96  Bool_t IsSortable() const { return kTRUE; }
97  Int_t Compare(const TObject *obj) const;
98 
99  Int_t GetIndex() const { return fIndex; }
100  void SetIndex(Int_t idx) { fIndex = idx; }
101 
102  void Print(Option_t *options="") const;
103 
104  ClassDef(TFileInfo,4) // Describes generic file info including meta data information
105 };
106 
107 
108 class TFileInfoMeta : public TNamed {
109 
110 private:
111  Long64_t fEntries; // number of entries in tree or number of objects
112  Long64_t fFirst; // first valid tree entry
113  Long64_t fLast; // last valid tree entry
114  Bool_t fIsTree; // true if type is a TTree (or TTree derived)
115  Long64_t fTotBytes; // uncompressed size in bytes
116  Long64_t fZipBytes; // compressed size in bytes
117 
118  TFileInfoMeta& operator=(const TFileInfoMeta&); // not implemented
119 
120 public:
121  enum EStatusBits { kExternal = BIT(15) };
122 
123  TFileInfoMeta() : fEntries(-1), fFirst(0), fLast(-1),
124  fIsTree(kFALSE), fTotBytes(-1), fZipBytes(-1)
126  TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
127  Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
128  Long64_t totbytes = -1, Long64_t zipbytes = -1);
129  TFileInfoMeta(const char *objPath, const char *objDir,
130  const char *objClass, Long64_t entries = -1,
131  Long64_t first = 0, Long64_t last = -1,
132  Long64_t totbytes = -1, Long64_t zipbytes = -1);
133  TFileInfoMeta(const TFileInfoMeta &m);
134 
135  virtual ~TFileInfoMeta() { }
136 
137  const char *GetObject() const;
138  const char *GetClass() const { return GetTitle(); }
139  const char *GetDirectory() const;
140  Long64_t GetEntries() const { return fEntries; }
141  Long64_t GetFirst() const { return fFirst; }
142  Long64_t GetLast() const { return fLast; }
143  Bool_t IsTree() const { return fIsTree; }
144  Long64_t GetTotBytes() const { return fTotBytes; }
145  Long64_t GetZipBytes() const { return fZipBytes; }
146 
147  void SetEntries(Long64_t entries) { fEntries = entries; }
149  void SetLast(Long64_t last) { fLast = last; }
150  void SetTotBytes(Long64_t tot) { fTotBytes = tot; }
151  void SetZipBytes(Long64_t zip) { fZipBytes = zip; }
152 
153  void Print(Option_t *options="") const;
154 
155  ClassDef(TFileInfoMeta,2) // Describes TFileInfo meta data
156 };
157 
158 #endif
TFileInfoMeta::fIsTree
Bool_t fIsTree
Definition: TFileInfo.h:114
m
auto * m
Definition: textangle.C:8
TFileInfo::fIndex
Int_t fIndex
Definition: TFileInfo.h:50
TFileInfoMeta::operator=
TFileInfoMeta & operator=(const TFileInfoMeta &)
TFileInfoMeta::fTotBytes
Long64_t fTotBytes
Definition: TFileInfo.h:115
first
Definition: first.py:1
TFileInfo
Definition: TFileInfo.h:39
TFileInfoMeta::IsTree
Bool_t IsTree() const
Definition: TFileInfo.h:143
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TFileInfo::SetSize
void SetSize(Long64_t size)
Definition: TFileInfo.h:86
TFileInfo::RemoveUrl
Bool_t RemoveUrl(const char *url)
Remove an URL. Returns kTRUE if successful, kFALSE otherwise.
Definition: TFileInfo.cxx:321
TFileInfo::GetCurrentUrl
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:249
TFileInfo::SetIndex
void SetIndex(Int_t idx)
Definition: TFileInfo.h:100
TFileInfo::AddMetaData
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
Definition: TFileInfo.cxx:385
TFileInfoMeta::~TFileInfoMeta
virtual ~TFileInfoMeta()
Definition: TFileInfo.h:135
TCollection::GetEntries
virtual Int_t GetEntries() const
Definition: TCollection.h:177
TFileInfo::SetUUID
void SetUUID(const char *uuid)
Set the UUID to the value associated to the string 'uuid'.
Definition: TFileInfo.cxx:238
TFileInfo::fUrlList
TList * fUrlList
current URL to access the file, points to URL
Definition: TFileInfo.h:44
TFileInfo::EStatusBits
EStatusBits
Definition: TFileInfo.h:57
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:54
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TFileInfo::Compare
Int_t Compare(const TObject *obj) const
Compare TFileInfo object by their first urls.
Definition: TFileInfo.cxx:444
Int_t
int Int_t
Definition: RtypesCore.h:45
TFileInfo::fMD5
TMD5 * fMD5
Definition: TFileInfo.h:47
TFileInfoMeta::EStatusBits
EStatusBits
Definition: TFileInfo.h:121
TFileInfoMeta::SetEntries
void SetEntries(Long64_t entries)
Definition: TFileInfo.h:147
TFileInfo::ResetUrl
void ResetUrl()
Definition: TFileInfo.h:69
TList.h
TFileInfo::NextUrl
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
Definition: TFileInfo.cxx:261
TFileInfo::GetFirstUrl
TUrl * GetFirstUrl() const
Definition: TFileInfo.h:72
TFileInfo::IsSortable
Bool_t IsSortable() const
Definition: TFileInfo.h:96
TFileInfoMeta::fZipBytes
Long64_t fZipBytes
Definition: TFileInfo.h:116
TFileInfo::SetCurrentUrl
Bool_t SetCurrentUrl(const char *url)
Set 'url' as current URL, if in the list Return kFALSE if not in the list.
Definition: TFileInfo.cxx:355
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TFileInfoMeta::SetFirst
void SetFirst(Long64_t first)
Definition: TFileInfo.h:148
TFileInfo::GetMetaData
TFileInfoMeta * GetMetaData(const char *meta=0) const
Get meta data object with specified name.
Definition: TFileInfo.cxx:425
TFileInfo::FindByUrl
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
Definition: TFileInfo.cxx:277
TFileInfo::fCurrentUrl
TUrl * fCurrentUrl
Definition: TFileInfo.h:42
TFileInfoMeta::SetZipBytes
void SetZipBytes(Long64_t zip)
Definition: TFileInfo.h:151
bool
TFileInfoMeta::GetZipBytes
Long64_t GetZipBytes() const
Definition: TFileInfo.h:145
TUUID.h
TFileInfo::AddUrl
Bool_t AddUrl(const char *url, Bool_t infront=kFALSE)
Add a new URL.
Definition: TFileInfo.cxx:296
TList::First
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:658
TFileInfo::fUUID
TUUID * fUUID
Definition: TFileInfo.h:46
TList::At
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:356
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:171
TFileInfoMeta::SetTotBytes
void SetTotBytes(Long64_t tot)
Definition: TFileInfo.h:150
TFileInfo::kCorrupted
@ kCorrupted
Definition: TFileInfo.h:59
TFileInfoMeta::kExternal
@ kExternal
Definition: TFileInfo.h:121
TFileInfoMeta::GetDirectory
const char * GetDirectory() const
Get the object's directory in the ROOT file.
Definition: TFileInfo.cxx:581
TFileInfoMeta::fEntries
Long64_t fEntries
Definition: TFileInfo.h:111
TFileInfoMeta::GetLast
Long64_t GetLast() const
Definition: TFileInfo.h:142
TFileInfo::GetUrlAt
TUrl * GetUrlAt(Int_t i) const
Definition: TFileInfo.h:73
TFileInfoMeta::GetTotBytes
Long64_t GetTotBytes() const
Definition: TFileInfo.h:144
TNamed
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TFileInfo::RemoveMetaData
Bool_t RemoveMetaData(const char *meta=0)
Remove the metadata object.
Definition: TFileInfo.cxx:402
TFileInfoMeta::GetEntries
Long64_t GetEntries() const
Definition: TFileInfo.h:140
TFileInfo::ParseInput
void ParseInput(const char *in)
Parse the input line to extract init information from 'in'; the input string is tokenized on ' '; the...
Definition: TFileInfo.cxx:157
TFileInfo::GetIndex
Int_t GetIndex() const
Definition: TFileInfo.h:99
TFileInfoMeta
Definition: TFileInfo.h:108
TFileInfo::GetSize
Long64_t GetSize() const
Definition: TFileInfo.h:80
BIT
#define BIT(n)
Definition: Rtypes.h:85
TFileInfoMeta::fFirst
Long64_t fFirst
Definition: TFileInfo.h:112
TUUID
Definition: TUUID.h:42
TMD5
Definition: TMD5.h:44
TUrl
Definition: TUrl.h:33
TFileInfo::RemoveUrlAt
Bool_t RemoveUrlAt(Int_t i)
Remove URL at given position. Returns kTRUE on success, kFALSE on error.
Definition: TFileInfo.cxx:337
TFileInfo::operator=
TFileInfo & operator=(const TFileInfo &)
TFileInfo::GetMD5
TMD5 * GetMD5() const
Definition: TFileInfo.h:82
TFileInfo::GetMetaDataList
TList * GetMetaDataList() const
Definition: TFileInfo.h:83
TFileInfo::kStaged
@ kStaged
Definition: TFileInfo.h:58
TFileInfo::fMetaDataList
TList * fMetaDataList
Definition: TFileInfo.h:48
TFileInfo::fSize
Long64_t fSize
Definition: TFileInfo.h:45
TFileInfo::TFileInfo
TFileInfo(const char *url=0, Long64_t size=-1, const char *uuid=0, const char *md5=0, TObject *meta=0)
Constructor.
Definition: TFileInfo.cxx:32
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TFileInfoMeta::GetClass
const char * GetClass() const
Definition: TFileInfo.h:138
TFileInfoMeta::Print
void Print(Option_t *options="") const
Print information about this object.
Definition: TFileInfo.cxx:598
TFileInfoMeta::SetLast
void SetLast(Long64_t last)
Definition: TFileInfo.h:149
TMD5.h
TFileInfo::GetNUrls
Int_t GetNUrls() const
Definition: TFileInfo.h:75
TFileInfoMeta::GetObject
const char * GetObject() const
Get the object name, with path stripped off.
Definition: TFileInfo.cxx:590
TFileInfo::Print
void Print(Option_t *options="") const
Print information about this object.
Definition: TFileInfo.cxx:478
TFileInfoMeta::fLast
Long64_t fLast
Definition: TFileInfo.h:113
TFileInfo::kSortWithIndex
@ kSortWithIndex
Definition: TFileInfo.h:60
TFileInfoMeta::TFileInfoMeta
TFileInfoMeta()
Definition: TFileInfo.h:123
TUrl.h
TList
Definition: TList.h:44
TFileInfo::GetUUID
TUUID * GetUUID() const
Definition: TFileInfo.h:81
TFileInfoMeta::GetFirst
Long64_t GetFirst() const
Definition: TFileInfo.h:141
int
TFileInfo::~TFileInfo
virtual ~TFileInfo()
Destructor.
Definition: TFileInfo.cxx:120