Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
24 #include "TNamed.h"
25 #endif
26 
27 #ifndef ROOT_Turl
28 #include "TUrl.h"
29 #endif
30 
31 #ifndef ROOT_TUUID
32 #include "TUUID.h"
33 #endif
34 
35 #ifndef ROOT_TMD5
36 #include "TMD5.h"
37 #endif
38 
39 #ifndef ROOT_TObjString
40 #include "TObjString.h"
41 #endif
42 
43 #ifndef ROOT_TList
44 #include "TList.h"
45 #endif
46 
47 class TFileInfoMeta;
48 
49 
50 class TFileInfo : public TNamed {
51 
52 private:
53  TUrl *fCurrentUrl; //! current URL to access the file, points to URL
54  // in the fUrlList or 0, if the list end is reached
55  TList *fUrlList; // list of file URLs
56  Long64_t fSize; // file size
57  TUUID *fUUID; //-> uuid of the referenced file
58  TMD5 *fMD5; //-> md5 digest of the file
59  TList *fMetaDataList; // generic list of file meta data object(s)
60 
61  Int_t fIndex; // Index to be used when sorting with index
62 
63  void ParseInput(const char *in);
64 
65  TFileInfo& operator=(const TFileInfo&); // not implemented
66 
67 public:
68  enum EStatusBits {
69  kStaged = BIT(15),
70  kCorrupted = BIT(16),
71  kSortWithIndex = BIT(17) // Use index when sorting (in Compare)
72  };
73 
74  TFileInfo(const char *url = 0, Long64_t size = -1, const char *uuid = 0,
75  const char *md5 = 0, TObject *meta = 0);
76  TFileInfo(const TFileInfo &);
77 
78  virtual ~TFileInfo();
79 
80  void ResetUrl() { fCurrentUrl = (TUrl*)fUrlList->First(); }
81  TUrl *NextUrl();
82  TUrl *GetCurrentUrl() const;
83  TUrl *GetFirstUrl() const { return (TUrl*)fUrlList->First(); }
84  TUrl *GetUrlAt(Int_t i) const { return (TUrl*)fUrlList->At(i); }
86  Int_t GetNUrls() const { return fUrlList->GetEntries(); }
87 
88  Bool_t SetCurrentUrl(const char *url);
90 
91  Long64_t GetSize() const { return fSize; }
92  TUUID *GetUUID() const { return fUUID; }
93  TMD5 *GetMD5() const { return fMD5; }
94  TList *GetMetaDataList() const { return fMetaDataList; }
95  TFileInfoMeta *GetMetaData(const char *meta = 0) const;
96 
97  void SetSize(Long64_t size) { fSize = size; }
98  void SetUUID(const char *uuid);
99 
100  TUrl *FindByUrl(const char *url, Bool_t withDeflt = kFALSE);
101 
102  Bool_t AddUrl(const char *url, Bool_t infront = kFALSE);
103  Bool_t RemoveUrl(const char *url);
104  Bool_t AddMetaData(TObject *meta);
105  Bool_t RemoveMetaData(const char *meta = 0);
106 
107  Bool_t IsSortable() const { return kTRUE; }
108  Int_t Compare(const TObject *obj) const;
109 
110  Int_t GetIndex() const { return fIndex; }
111  void SetIndex(Int_t idx) { fIndex = idx; }
112 
113  void Print(Option_t *options="") const;
114 
115  ClassDef(TFileInfo,4) // Describes generic file info including meta data information
116 };
117 
118 
119 class TFileInfoMeta : public TNamed {
120 
121 private:
122  Long64_t fEntries; // number of entries in tree or number of objects
123  Long64_t fFirst; // first valid tree entry
124  Long64_t fLast; // last valid tree entry
125  Bool_t fIsTree; // true if type is a TTree (or TTree derived)
126  Long64_t fTotBytes; // uncompressed size in bytes
127  Long64_t fZipBytes; // compressed size in bytes
128 
129  TFileInfoMeta& operator=(const TFileInfoMeta&); // not implemented
130 
131 public:
132  enum EStatusBits { kExternal = BIT(15) };
133 
134  TFileInfoMeta() : fEntries(-1), fFirst(0), fLast(-1),
135  fIsTree(kFALSE), fTotBytes(-1), fZipBytes(-1)
137  TFileInfoMeta(const char *objPath, const char *objClass = "TTree",
138  Long64_t entries = -1, Long64_t first = 0, Long64_t last = -1,
139  Long64_t totbytes = -1, Long64_t zipbytes = -1);
140  TFileInfoMeta(const char *objPath, const char *objDir,
141  const char *objClass, Long64_t entries = -1,
142  Long64_t first = 0, Long64_t last = -1,
143  Long64_t totbytes = -1, Long64_t zipbytes = -1);
144  TFileInfoMeta(const TFileInfoMeta &m);
145 
146  virtual ~TFileInfoMeta() { }
147 
148  const char *GetObject() const;
149  const char *GetClass() const { return GetTitle(); }
150  const char *GetDirectory() const;
151  Long64_t GetEntries() const { return fEntries; }
152  Long64_t GetFirst() const { return fFirst; }
153  Long64_t GetLast() const { return fLast; }
154  Bool_t IsTree() const { return fIsTree; }
155  Long64_t GetTotBytes() const { return fTotBytes; }
156  Long64_t GetZipBytes() const { return fZipBytes; }
157 
158  void SetEntries(Long64_t entries) { fEntries = entries; }
159  void SetFirst(Long64_t first) { fFirst = first; }
160  void SetLast(Long64_t last) { fLast = last; }
161  void SetTotBytes(Long64_t tot) { fTotBytes = tot; }
162  void SetZipBytes(Long64_t zip) { fZipBytes = zip; }
163 
164  void Print(Option_t *options="") const;
165 
166  ClassDef(TFileInfoMeta,2) // Describes TFileInfo meta data
167 };
168 
169 #endif
TUUID * GetUUID() const
Definition: TFileInfo.h:92
virtual ~TFileInfo()
Destructor.
Definition: TFileInfo.cxx:119
long long Long64_t
Definition: RtypesCore.h:69
Int_t Compare(const TObject *obj) const
Compare TFileInfo object by their first urls.
Definition: TFileInfo.cxx:443
void SetUUID(const char *uuid)
Set the UUID to the value associated to the string 'uuid'.
Definition: TFileInfo.cxx:237
TMD5 * fMD5
Definition: TFileInfo.h:58
Long64_t GetFirst() const
Definition: TFileInfo.h:152
const char Option_t
Definition: RtypesCore.h:62
void Print(Option_t *options="") const
Print information about this object.
Definition: TFileInfo.cxx:477
This class represents a WWW compatible URL.
Definition: TUrl.h:41
Bool_t RemoveUrl(const char *url)
Remove an URL. Returns kTRUE if successful, kFALSE otherwise.
Definition: TFileInfo.cxx:320
TUrl * GetCurrentUrl() const
Return the current url.
Definition: TFileInfo.cxx:248
TFileInfo(const char *url=0, Long64_t size=-1, const char *uuid=0, const char *md5=0, TObject *meta=0)
Constructor.
Definition: TFileInfo.cxx:31
#define BIT(n)
Definition: Rtypes.h:120
TUrl * NextUrl()
Iterator function, start iteration by calling ResetUrl().
Definition: TFileInfo.cxx:260
void SetEntries(Long64_t entries)
Definition: TFileInfo.h:158
virtual Int_t GetEntries() const
Definition: TCollection.h:92
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void SetIndex(Int_t idx)
Definition: TFileInfo.h:111
Bool_t AddUrl(const char *url, Bool_t infront=kFALSE)
Add a new URL.
Definition: TFileInfo.cxx:295
TUrl * GetUrlAt(Int_t i) const
Definition: TFileInfo.h:84
Int_t GetIndex() const
Definition: TFileInfo.h:110
Long64_t GetEntries() const
Definition: TFileInfo.h:151
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:44
Long64_t fTotBytes
Definition: TFileInfo.h:126
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t AddMetaData(TObject *meta)
Add's a meta data object to the file info object.
Definition: TFileInfo.cxx:384
Int_t GetNUrls() const
Definition: TFileInfo.h:86
This code implements the MD5 message-digest algorithm.
Definition: TMD5.h:46
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TUrl * GetFirstUrl() const
Definition: TFileInfo.h:83
void SetSize(Long64_t size)
Definition: TFileInfo.h:97
Bool_t IsSortable() const
Definition: TFileInfo.h:107
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:354
TUrl * fCurrentUrl
Definition: TFileInfo.h:53
TUrl * FindByUrl(const char *url, Bool_t withDeflt=kFALSE)
Find an element from a URL. Returns 0 if not found.
Definition: TFileInfo.cxx:276
void SetFirst(Long64_t first)
Definition: TFileInfo.h:159
Long64_t fEntries
Definition: TFileInfo.h:122
A doubly linked list.
Definition: TList.h:47
TFileInfoMeta * GetMetaData(const char *meta=0) const
Get meta data object with specified name.
Definition: TFileInfo.cxx:424
Long64_t GetZipBytes() const
Definition: TFileInfo.h:156
TList * fUrlList
current URL to access the file, points to URL
Definition: TFileInfo.h:55
Long64_t fFirst
Definition: TFileInfo.h:123
Long64_t fSize
Definition: TFileInfo.h:56
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:156
Int_t fIndex
Definition: TFileInfo.h:61
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
Bool_t RemoveUrlAt(Int_t i)
Remove URL at given position. Returns kTRUE on success, kFALSE on error.
Definition: TFileInfo.cxx:336
void SetLast(Long64_t last)
Definition: TFileInfo.h:160
Long64_t fLast
Definition: TFileInfo.h:124
TMarker * m
Definition: textangle.C:8
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:311
Long64_t GetLast() const
Definition: TFileInfo.h:153
Long64_t fZipBytes
Definition: TFileInfo.h:127
Bool_t IsTree() const
Definition: TFileInfo.h:154
TFileInfo & operator=(const TFileInfo &)
Bool_t fIsTree
Definition: TFileInfo.h:125
TMD5 * GetMD5() const
Definition: TFileInfo.h:93
void ResetUrl()
Definition: TFileInfo.h:80
Mother of all ROOT objects.
Definition: TObject.h:37
Long64_t GetTotBytes() const
Definition: TFileInfo.h:155
void SetTotBytes(Long64_t tot)
Definition: TFileInfo.h:161
Bool_t RemoveMetaData(const char *meta=0)
Remove the metadata object.
Definition: TFileInfo.cxx:401
virtual ~TFileInfoMeta()
Definition: TFileInfo.h:146
void SetZipBytes(Long64_t zip)
Definition: TFileInfo.h:162
TList * fMetaDataList
Definition: TFileInfo.h:59
Class describing a generic file including meta information.
Definition: TFileInfo.h:50
void ResetBit(UInt_t f)
Definition: TObject.h:156
Definition: first.py:1
const Bool_t kTRUE
Definition: Rtypes.h:91
TUUID * fUUID
Definition: TFileInfo.h:57
const char * GetClass() const
Definition: TFileInfo.h:149
Long64_t GetSize() const
Definition: TFileInfo.h:91
TList * GetMetaDataList() const
Definition: TFileInfo.h:94
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
T1 fFirst
Definition: X11Events.mm:86